| Sniff basics |
- |
| Fixable for PHP: |
5.0+ |
| Sniff type: |
Modernize |
| Fixer type: |
Safe (review recommended) |
Short description of the sniff
Prior to PHP 5, the var keyword had to be used to declare class properties and all properties were public. As of PHP 5.0, there is a choice between declaring properties as public, protected or private.
Related PHPCompatibility sniff(s):
PHP manual references:
Example code:
Detect the following code pattern(s):
class OldStyle {
var $myproperty = 'abc';
}
And fix these to:
class OldStyle {
public $myproperty = 'abc';
}
Notes for implementation of the sniff:
Short description of the sniff
Prior to PHP 5, the
varkeyword had to be used to declare class properties and all properties were public. As of PHP 5.0, there is a choice between declaring properties aspublic,protectedorprivate.Related PHPCompatibility sniff(s):
PHP manual references:
http://php.net/manual/en/language.oop5.properties.php
http://php.net/manual/en/language.oop5.visibility.php
Example code:
Detect the following code pattern(s):
And fix these to:
Notes for implementation of the sniff: