(a) When declaratory relief is sought, all persons who have or claim any interest that would be affected by the declaration must be made parties. A declaration does not prejudice the rights of a person not a party to the proceeding.
(b) In any proceeding that involves the validity of a municipal ordinance or franchise, the municipality must be made a party and is entitled to be heard, and if the statute, ordinance, or franchise is alleged to be unconstitutional, the attorney general of the state must also be served with a copy of the proceeding and is entitled to be heard.