As of PHP 8.2.0, the declaration is required unless the class uses
this attribute. Creating an undeclared property
on such a class emits a deprecation notice.
<?php
class InvalidExample { }
$obj = new InvalidExample();
$obj->myUnknownProperty = 1234;
?>
Output of the above example in PHP 8.2:
Deprecated: Creation of dynamic property InvalidExample::$myUnknownProperty is deprecated in file on line 5