Re: [Discussion] Make objects unpackable by default

From: Date: Thu, 14 Nov 2024 13:37:46 +0000
Subject: Re: [Discussion] Make objects unpackable by default
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-125958@lists.php.net to get a copy of this message
Am 14.11.2024 um 10:59 schrieb Marco Pivetta <ocramius@gmail.com>: > On Thu, 14 Nov 2024, 11:29 MrMeshok, <ilyaorlov124@gmail.com> wrote: >> Hello, Internals! >> >> As you know if you try to unpack a regular object >> (...$object) you will get an error: Only arrays and Traversables can >> be unpacked. >> I don't really see a reason for this restriction, because foreach on objects works >> perfectly fine, so I made a feature request on GitHub to change this behavior >> (https://github.com/php/php-src/issues/16038) and was advised to see opinions on this here. >> So, what do you think? And does this change require RFC? > > TBH, foreach on objects is already quite an abomination in itself 😬 It is a bit less weird if you use value objects or json data in object form. I would be careful to judge how other people use the language, just saying ;-) - Chris

« previous php.internals (#125958) next »