Attempt to unset static property X::$x¶
Description¶
It is not possible to unset a static property.nThis applies to typed and not typed static properties. It also only applies to static properties that are already set, such as in the illustration: PHP complains about uninitialized state first, and later, about removing static properties.nThis does not apply to properties, which may be removed.
Example¶
<?php
class x {
public static $y = 1;
public static int $z;
}
//Attempt to unset static property A::$x
unset(x::$y);
//Attempt to unset static property x::$z
unset(x::$z);
x::$z = 2;
//Attempt to unset static property A::$x
unset(x::$z);
?>
Solutions¶
Set the property to null.
Set the property to a value that represents removal.