Cannot indirectly modify readonly property %s::$%s¶
Description¶
A readonly property cannot be changed after it was set. This includes trying to reach the property via a reference.
Example¶
<?php
class X {
readonly public string $property;
public function __construct() {
$this->property = 'A';
}
}
$object = new X;
$variable =& $object->property;
?>
Literal Examples¶
Cannot indirectly modify readonly property X::$property
Solutions¶
Do not create a reference to a readonly property.