Cannot override final property %s::$%s¶
Description¶
A property that is private for writing, is automatically considered final
. That is, it cannot be redeclared in a child class, with a different visibility.
Example¶
<?php
class X {
public private(set) int $property;
}
class Y extends X {
public int $property;
}
new Y;
?>
Literal Examples¶
Cannot override final property X::$property
Solutions¶
Remove the asymmetric visibility from the parent class.
Remove the property declaration from the child class.
Add the
final
keyword to the property declaration in the parent (and adapt the children).