PhpStorm
 
Get PhpStorm
You are viewing the documentation for an earlier version of PhpStorm.

Code Inspection: Typed property might be uninitialized

Last modified: 16 May 2022

Reports the attempts to read from an uninitialized typed property. Such attempts will result in TypeError.

Typed properties should be initialized in any of the following ways:

  • by a default value

  • in the constructor

  • by the __get() magic getter

  • in-place, at the moment of usage

See Uninitialized and Unset Properties (php.net) for details.

In the following example, the $prop property is accessed before being initialized, which will result in a PHP Fatal error: