PHP_CodeSniffer
PHP_CodeSniffer copied to clipboard
Modernize: add constant visibility
Description
Constant visibility is available in PHP since PHP 7.1. This commit adds the visibility to all class constants currently in the codebase and starts enforcing constant visibility being required.
In most cases, the visibility remains the same as before, i.e. public, however, there are a couple of exceptions, which could be considered a breaking change:
-
PHP_CodeSniffer\Generators\HTML::STYLESHEET(waspublic, nowprivate)- Even though the class is not
final, theConfigonly allows for requesting a PHPCS nativeGeneratorclass, so the chances of the class being extended are very slim. - On top of that, this was a function local variable until a few months ago, so chances of any external access to the constant being active are also slim based on the timing.
- Even though the class is not
-
PHP_CodeSniffer\Util\Timing::MINUTE_IN_MSandPHP_CodeSniffer\Util\Timing::SECOND_IN_MS(werepublic, nowprivate)- These properties were introduced about six months ago and only ever intended for use by the class itself.
Aside from the above, there are some visibility changes for class constants which are part of the PHPCS native test suite, so not in the public API.
Suggested changelog entry
Changed:
- The
PHP_CodeSniffer\Generators\HTML::STYLESHEET,PHP_CodeSniffer\Util\Timing::MINUTE_IN_MSandPHP_CodeSniffer\Util\Timing::SECOND_IN_MSclass constants are no longerpublic.