Re: [PHP-DEV] [RFC] Deprecate dynamic properties

This is only part of a thread. view whole thread
August 25, 2021 10:55 (Marco Pivetta)
Hey Nikita

On Wed, Aug 25, 2021 at 12:03 PM Nikita Popov> wrote:

> Hi internals, > > 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): > > > > This has been discussed in various forms in the past, e.g. in > as a class modifier and > / > > > as a declare directive. > > This RFC takes the more direct route of deprecating this functionality > entirely. I expect that this will have relatively little impact on modern > code (e.g. in Symfony I could fix the vast majority of deprecation warnings > with a three-line diff), but may have a big impact on legacy code that > doesn't declare properties at all. >
I'm totally on board with this! Others in the thread have mentioned that these dynamic properties can be used for lazy-loading purposes, but I think we've demonstrated (over the years) that this can be achieved in a type-safe way anyway, and dynamic properties are not needed at all. Over the past decade, I've not seen a single valid use of dynamic properties either. If this passes, I'll also deprecate and discontinue experiments like Greets, Marco Pivetta