1.2.1033. Redefined Private Property¶
Private properties are local to their defined class. PHP doesn’t forbid the re-declaration of a private property in a child class.
However, having two or more properties with the same name, in the class hierarchy tends to be error prone. Methods will be accessing properties with the same name, but with different values.
<?php
class A {
private $isReady = true;
}
class B {
private $isReady = false;
}
?>
1.2.1033.1. Connex PHP features¶
1.2.1033.1.1. Suggestions¶
Remove the property in the children classes
Rename the property in the children classes
Change the visibility in the parent class
1.2.1033.1.2. Specs¶
Short name |
Classes/RedefinedPrivateProperty |
Rulesets |
|
Exakat since |
1.2.3 |
PHP Version |
All |
Severity |
Major |
Time To Fix |
Slow (1 hour) |
Precision |
Very high |
Examples |
|
Available in |