1.2.899. Overwritten Class Constants¶
Those class constants are overwriting a parent class’s constant. This may lead to confusion, as the value of the constant may change depending on the way it is called.
<?php
class foo {
const C = 1;
}
class bar extends foo {
const C = 2;
function x() {
// depending on the access to C, value is different.
print self::C.' '.static::C.' '.parent::C;
}
}
?>
1.2.899.2. Connex PHP features¶
1.2.899.2.1. Suggestions¶
Remove the constant in the interface
Remove the constant in the class
Rename one of the constants
1.2.899.2.2. Specs¶
Short name |
Classes/OverwrittenConst |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
|
Time To Fix |
|
Precision |
High |
Available in |