Re: [Discussion] Make objects unpackable by default

From: Date: Thu, 21 Nov 2024 10:05:14 +0000
Subject: Re: [Discussion] Make objects unpackable by default
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-126018@lists.php.net to get a copy of this message
Am 14.11.2024 um 22:27 schrieb Gina P. Banyard <internals@gpb.moe>: > Agreed, this bites us constantly when needing to reason about what an "object" is in > PHP. > Similar to array it mixes the concept of a struct, with that of a reference value, and > "overloading" various behaviours (e.g. iterators and ArrayAccess). > It is *extremely* simple to go from foreach ($object as $prop) {} to > forearch(get_object_vars($object) as $prop) {} > and mandating this would resolve a lot of complexity, be that from the perspective of what is > "possible" or not to do, and from an engine PoV. Is there (currently) a difference between foreach ($obj ...) and foreach (get_object_vars($obj) ...)? If there is then the migration is not always "extremely" simple, no? If there isn't then we can simply define that from now on the former is equivalent to the second one and ignore future changes to visibility, hooks etc. My main point is that over the last years a lot of (for our code unnecessary) complexity was added but I hardly complained because other people have other needs. I just ask for similar consideration in return when stripping stuff. Regards, - Chris

« previous php.internals (#126018) next »