Attempt to assign property “%s” on null
Description
null is not an object, and it can’t be used as such. Until PHP 8.0, the engine would automatically create a stdClass object, and replace the null value with it. This is not the case anymore.
Example
<?php
$a = null;
$a->b = 1;
?>
Literal Examples
- Attempt to assign property “b” on null
Alternatives
- Instantiate any object and replace
nullwith it. - Explicitly instantiate a
stdClassobject and replacenullwith it. - Remove the property usage.
- Use another variable to use this property.
In previous PHP versions, this error message used to be :ref:creating-default-object-from-empty-value.