Re: [RFC] Deprecate dynamic properties

From: Date: Wed, 25 Aug 2021 10:45:27 +0000
Subject: Re: [RFC] Deprecate dynamic properties
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-115802@lists.php.net to get a copy of this message
On 25/08/2021 11:02, Nikita Popov wrote:
I'd like to propose the deprecation of "dynamic properties", that is properties that have not been declared in the class (stdClass and __get/__set excluded, of course): https://wiki.php.net/rfc/deprecate_dynamic_properties
This is a bold move, and in principle seems sensible, although I'm slightly scared how many places will need fixing in legacy code bases. I have a couple of concerns with using stdClass as the opt-in mechanism: * The name of that class already leads to a lot of confusion about its purpose - it's not actually "standard" in any way, and new users seeing it as a base class are even more likely to mistake it as some kind of "universal ancestor". Would it be feasible to introduce an alias like "DynamicObject" which more clearly defines its role? * Adding a parent to an existing class isn't always possible, if it already inherits from something else. Perhaps the behaviour could also be available as a trait, which defined stub __get and __set methods, allowing for the replacement of the internal implementation as you've described? Regards, -- Rowan Tommins [IMSoP]

« previous php.internals (#115802) next »