Typed static property x::$y must not be accessed before initialization¶
Description¶
When a property is typed, it starts its existence in an ‘undefined’ state, which cannot be compared to anything else. The property must be assigned before a read access can happen. The same applies to both property types, static or not.
Example¶
<?php
class x {
static int $y;
}
var_dump(x::$y);
?>
Solutions¶
Ensure that the property receives a value before reading it.
Use empty() or isset() to check if the property has been set, before reading.