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

This is only part of a thread. view whole thread
August 25, 2021 22:05 (Paul Crovella)
On Wed, Aug 25, 2021 at 3:03 AM 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. > > Regards, > Nikita
I'd like to see a section (or just a paragraph) in the RFC summarizing the benefits of making this change. Right now the introduction says that using dynamic properties in modern code "is rarely done intentionally" implying that it's typically done unintentionally, however I can't remember the last time I saw unintentional use either. Is this a common cause of bugs? The internal impact section mentions saving 8 bytes per object plus an unspecified "dramatic" amount for an object iterated over via `foreach` which sounds nice but leaves me guesstimating at real-world impact. I don't much care for dynamic properties, but I also don't much see them outside legacy code so they're not bringing me troubles either. Breaking working code, however, would.