1.2.578. Inherited Property Type Must Match¶
Properties that are inherited between classes must match.
This affect public and protected properties. Private properties are immune to this rule, as they actually are distinct properties.
<?php
class A {
private A $a;
protected array $b;
public $c;
}
class B extends A {
private A $a; // OK, as it is private
protected int $b; // type must match with the previous definition
public $c; // no type behaves just like a type : it must match too.
}
?>
See also Properties.
1.2.578.2. Connex PHP features¶
1.2.578.2.1. Suggestions¶
Remove the definition in the child class
Synchronize the definition of the property in the child class
1.2.578.2.2. Specs¶
Short name |
Classes/InheritedPropertyMustMatch |
Rulesets |
All, Analyze, Changed Behavior, Class Review, LintButWontExec |
Exakat since |
2.2.2 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Note |
This issue may lint but will not run |
Available in |