Prior to PHP 7.1, class constants could not have visibility declared and would always be public. As of PHP 7.1, there is a choice between declaring class constants as public, protected or private.
Related PHPCompatibility sniff(s):
NewConstVisibility
PHP manual references:
As of PHP 7.1.0, class constants may be defined as public, private, or protected. Constants declared without any explicit visibility keyword are defined as public.
Short description of the sniff
Prior to PHP 7.1, class constants could not have visibility declared and would always be public. As of PHP 7.1, there is a choice between declaring class constants as
public
,protected
orprivate
.Related PHPCompatibility sniff(s):
NewConstVisibility
PHP manual references:
http://php.net/manual/en/language.oop5.visibility.php#language.oop5.visiblity-constants
Example code:
Detect the following code pattern(s):
And fix these to:
Notes for implementation of the sniff:
const
keyword will need to be carefully checked.