PHPCon Poland 2024

The AllowDynamicProperties class

(PHP 8 >= 8.2.0)


This attribute is used to mark classes that allow dynamic properties.

Sinopsis de la Clase

final class AllowDynamicProperties {
/* Métodos */
public __construct()


Dynamic properties are deprecated as of PHP 8.2.0, thus using them without marking the class with this attribute will emit a deprecation notice.

class DefaultBehaviour { }

ClassAllowsDynamicProperties { }

$o1 = new DefaultBehaviour();
$o2 = new ClassAllowsDynamicProperties();

$o1->nonExistingProp = true;
$o2->nonExistingProp = true;

Output of the above example in PHP 8.2:

Deprecated: Creation of dynamic property DefaultBehaviour::$nonExistingProp is deprecated in file on line 10

Ver también

Attributes overview

Tabla de contenidos

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top