Skip to content

Section 9: Apply the private instead of protected rule to enum constants#151

Merged
Crell merged 1 commit into
php-fig:masterfrom
rodrigoprimo:apply-private-rule-to-enum-constants-section-9
Jun 25, 2026
Merged

Section 9: Apply the private instead of protected rule to enum constants#151
Crell merged 1 commit into
php-fig:masterfrom
rodrigoprimo:apply-private-rule-to-enum-constants-section-9

Conversation

@rodrigoprimo

Copy link
Copy Markdown
Contributor

Section 9 required non-public enum methods to use private instead of protected but said nothing about constants. The rationale that enums do not support inheritance, so protected is meaningless, applies equally to constants, so the omission was likely an oversight (see issue #150).

While broadening the rule, I also dropped the "Methods in enums MUST follow the same guidelines as methods in classes" sentence. I first considered just adding constants to it, but that sentence was already redundant with the opening line, which states that enums follow the guidelines for classes. Spelling out "methods and constants" would only have made the duplication more obvious. So instead I collapsed it into the opening line, which now mentions class methods and constants explicitly to preserve that emphasis. Happy to drop this second change if there is no consensus that this is an improvement to make this PR focused only on what was discussed in #150.

Fixes #150

Section 9 required non-public enum methods to use `private` instead of
`protected` but said nothing about constants. The rationale that enums
do not support inheritance so `protected` is meaningless applies equally
to constants, so the omission was likely an oversight (see issue 150).

While broadening the rule, I also dropped the "Methods in enums MUST
follow the same guidelines as methods in classes" sentence. I first
considered just adding constants to it, but that sentence was already
redundant with the opening line, which states that enums follow the
guidelines for classes. Spelling out "methods and constants" would only
have made the duplication more obvious. So instead I collapsed it into
the opening line, which now mentions class methods and constants
explicitly to preserve that emphasis.
@Crell

Crell commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

I'm good with this, but giving it a few days for the rest of the WG to comment.

@Crell Crell merged commit 73c085b into php-fig:master Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Section 9: should non-public enum constants follow the same private instead protected rule as methods?

2 participants