Requiring an extension of stdClass would allow us to actually remove the “dynamic properties” concept from the language in the future: stdClass would effectively just provide very optimized implementations of _get() and _set(). This is a big win for the ecosystem, but it does not have much effect on the overall complexity of the language or implementation, as dynamic properties still need to be supported on arbitrary classes. The difference between these approaches is in the end goal: # requires making classes that rely on dynamic properties explicit and prevents accidental use of dynamic properties. A previous version of this proposal instead suggested to extend from stdClass, and make stdClass the only class with first-class dynamic property support. This RFC offers # as a way to opt-in to the use of dynamic properties. All used properties should be declared in the class declaration.Ĭlass Foo Ī declared property that has been unset remains a declared property, and will not result in a dynamic property when it is reinitialized. The creation of dynamic properties on classes that aren't marked with the # attribute is deprecated in PHP 8.2 and becomes an Error exception in PHP 9.0.
0 Comments
Leave a Reply. |