On Tue, Apr 11, 2023 at 9:18 AM Robert Landers <landers.rob...@gmail.com>
wrote:

> > You can add `#[AllowDynamicProperties]` to classes where you want to
> allow
> > dynamic properties.
>
> I don't think that will work in PHP 9?
>
>
In Niki's earliest draft, he wanted to completely remove dynamic properties
from *default* class handlers in 9.0, as this would simplify the most
common use-case for classes and objects and improve their runtime
efficiency.  Even in this case, however, the stdClass specialization would
have dynamic properties implemented in a way which would allow an escape
hatch for user classes via extending stdClass.

We wound up with the attribute approach instead, which means that the logic
for dynamic properties, as well as the allocation overhead, still has to
exist in all userland classes.  All approaches however, came with stdClass
working as expected out of the box, and a low-effort, forward-compatible
escape hatch for those rare cases where dynamic properties are needed on
custom classes.

This is because PHP's dedication to stability IS, AND REMAINS, steadfast
and fanatical.

-Sara

Reply via email to