Hey Mark,
On Wed, 6 Apr 2022 at 14:04, Mark Randall <marand...@php.net> wrote: > Internals, > > Part 2 of the undefined behaviour improvements, this time focusing on > properties. > > https://wiki.php.net/rfc/undefined_property_error_promotion > > This RFC draws heavily from the just passed undefined variables error > promotion RFC, and is intended to compliment both it, and the 8.2 > Deprecate Dynamic Properties RFC. > > The arguments in favour are the same as the last one, reading things > which don't exist will often lead to the program entering an unintended > state, and is likely the result of a programming error. > > There is a difference though that we do explicitly provide an object > that is designed to be dynamic, and that is stdClass which is the > typical output from json_decode and array to object casts. > > I would expect we might want to discuss special-casing the accessing of > properties on stdClass and leave them as a warning. > > However, I personally think that for the sake of consistency we should > make undefined properties throw across the board, including stdClass. > > We already have fully backwards compatible mechanisms built into the > language (isset, empty, null coalesce, property_exists) to safely handle > cases of the property not being defined, even on objects that do not > have a fixed structure. > > I was originally going to include a section for discussion about > potentially using AllowDynamicProperties to pull double duty, allowing > reads without an error as well, but I do not believe that would be in > the best interests of the language, and so removed it. > > Mark Randall > Perhaps worth mentioning that magic methods keep working? Marco Pivetta https://twitter.com/Ocramius https://ocramius.github.io/