Attempt to unset static property %s::$%s¶
Description¶
It is not possible to unset a static property.
This 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.
This 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 X::$x
unset(X::$y);
//Attempt to unset static property X::$z
unset(X::$z);
X::$z = 2;
//Attempt to unset static property X::$x
unset(X::$z);
?>
Literal Examples¶
Attempt to unset static property X::$x
Solutions¶
Set the property to null.
Set the property to a value that represents removal.