Repository navigation
Conversation
| <documentation title="Constant Visibility"> | ||
| <standard> | ||
| <![CDATA[ | ||
| Visibility must be declared on all class constants if your project PHP minimum version supports class constant visibilities (PHP 7.1 or later). |
There was a problem hiding this comment.
Is it "class constants" ? Or all OO constants ? Constants can also be declared on interfaces, traits (PHP 8.2+) and enums, after all.
Also not sure if the "class" needs to be repeated.
| Visibility must be declared on all class constants if your project PHP minimum version supports class constant visibilities (PHP 7.1 or later). | |
| Visibility must be declared on all class constants if your project PHP minimum version supports constant visibilities (PHP 7.1 or later). |
There was a problem hiding this comment.
Well, the documentation states
The term "class" refers to all classes, interfaces, and traits.
That's why I opted to use that term.
I added the 'class' to distinguish them from defined constants.
There was a problem hiding this comment.
Well, the documentation states
The term "class" refers to all classes, interfaces, and traits.
That's why I opted to use that term.
I added the 'class' to distinguish them from
defined constants.
I fully understand (and support) why it was added, I just wonder if the right term was added. After all, the PSR12 definition is not available from within the PHPCS docs.
There was a problem hiding this comment.
I've added this to the documentation description, I think it should help to avoid misunderstandings.
There was a problem hiding this comment.
Thanks @dingo-d ! LGTM.
Only thing I'm wondering about is whether the "The term "class" refers to all classes, interfaces, and traits." phrase should also mention enums ?
Enums didn't exist when PSR12 was written, but the sniff does apply the rule to enums too.
Good catch! Will update this to add enums as well. |
Add enums to the 'class' list
* Add the documentation for the PSR12 Constant Visiblity sniff
The PR contains the documentation for the PSR12/Properties/ConstantVisiblity sniff.
Description
This PR will add the documentation for the above-mentioned sniff, according to the official standard definitions.
Suggested changelog entry
Add documentation for the PSR12 ConstantVisiblity sniff
Related issues/external references
Part of #148
Types of changes
PR checklist