1.2.1015. Raised Access Level¶
A visibility may be lowered, but not raised. Visibilities apply to properties, methods and class constants.
This error may be detected by PHP when the classes are in the same file, and declared in the right order : then, PHP reports a compilation error. However, when the classes are separated in different files, as it is customary, PHP won’t check this at linting time, yielding a fatal error at execution time.
<?php
class Foo {
public $publicProperty;
protected $protectedProperty;
private $privateProperty;
}
class Bar extends Foo {
private $publicProperty;
private $protectedProperty;
private $privateProperty; // This one is OK
}
?>
See also Visibility and Understanding the concept of visibility in object oriented php.
1.2.1015.2. Connex PHP features¶
1.2.1015.2.1. Suggestions¶
Lower the visibility in the child class
Raise the visibility in the parent class
1.2.1015.2.2. Specs¶
Short name |
Classes/RaisedAccessLevel |
Rulesets |
|
Exakat since |
0.10.0 |
PHP Version |
All |
Severity |
Critical |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Note |
This issue may lint but will not run |
Available in |