Re: [RFC] Undefined Property Error Promotion

From: Date: Wed, 06 Apr 2022 13:36:47 +0000
Subject: Re: [RFC] Undefined Property Error Promotion
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-117484@lists.php.net to get a copy of this message
On Wed, Apr 6, 2022 at 2:37 PM Robert Landers <landers.robert@gmail.com> wrote: > > FWIW, I'd like to see option 2 only because of custom serializers > and/or object proxies and also because: > > > This RFC proposes that accessing an undefined property is rendered > illegal behaviour > > StdClass has *no* defined properties and thus would always throw. But > I also guess it depends on what you define "undefined" as. Does simply > doing $obj->prop "define" the property "prop"? > The RFC doesn't change the current meaning of "undefined" (or "defined", or "declared"...), just proposes to throw an Error (while it currently triggers an E_WARNING). First sentence of the introduction: "Undefined properties are those that have not yet been defined either by the presence of a property declaration, or by adding them to the properties hashmap through direct assignment, or by having them assigned by an internal function such as json_decode." $obj->prop alone doesn't define the property "prop", but `$obj->prop = whatever` does. Regards, -- Guilliam Xavier

« previous php.internals (#117484) next »