Cannot unset readonly property %s::$%s¶
Description¶
Once a readonly
property has been set, it cannot be unset. That would defeat the whoe purpose of readonly
.
Example¶
<?php
class X {
public readonly $property;
function __construct($a) {
$this->property = $a;
unset($this->property);
}
}
?>
Literal Examples¶
Cannot unset readonly property X::$property
Solutions¶
Use clone to create a new object, and have a chance to change that value.
Remove the
unset
call.Remove the
readonly
property.