Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125959 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 6591A1A00BD for ; Thu, 14 Nov 2024 17:25:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1731605257; bh=g7pCElmI73uJFXHE0ZRkR+raDj6Tx26ZggfddV3eqAw=; h=Date:From:To:In-Reply-To:References:Subject:From; b=W1eBQ4WgUi7anYBHdlH7k24Yq2rMieTNsK1qGcMGbxlF/iEECrqrewRLvTgtQg2Kw 2Cf2QLTBHUNNdtH+RxxBLahR+rgOZ/CG+3V2IoDVGLQwmfLfoC5TsQXK6VxD7b+ZCO iP9C5kyfEPHvORrUS0QUsbnPQ4Lz0XkhByCdrhbdtNkTcMUs/dd5jJzeBj6hH2qzTp ZuZqIdMaHXdutiLUeeYkU+FBm/NGl0C4aXO+k3vUmdVW/iSsAG02meHhQa2p7aBeB9 zafhgzo+Nn3tn9/E9XXLjrCH5fAbndFJtQonvat/RhrThy97fnzHwpzj0jV5s+84Us xH8ArQG1sSJBw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AE4A5180068 for ; Thu, 14 Nov 2024 17:27:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh-b7-smtp.messagingengine.com (fhigh-b7-smtp.messagingengine.com [202.12.124.158]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 14 Nov 2024 17:27:36 +0000 (UTC) Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfhigh.stl.internal (Postfix) with ESMTP id 29BBD254013D for ; Thu, 14 Nov 2024 12:24:59 -0500 (EST) Received: from phl-imap-06 ([10.202.2.83]) by phl-compute-01.internal (MEProxy); Thu, 14 Nov 2024 12:24:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to; s=fm3; t=1731605099; x=1731691499; bh=RBYPfa0FnuBv2+IGiypWY he+waom4D5qRYV2tSNyst4=; b=jfuIkl8x2JwqSLWB+fy5i1jWqIHpQDKBdka1O 1jQbAWOa5C5JbanVP1y2enRFjp623IXIGSNc7KEb1jC7q7sofTSUSVkcsG2X2OAG jDv/hr1gqy0Kw9K8mjfEI0D8ZvMazLW8JJUOzY8UoFMEgCzklHdDlmN378yZFd7c mjdqgMeXJRyLRI/MEpbJYmiRSs8yJeBUJxCorVr2lu26u4loM1AQTtzDPA+TlHbB ngXN10bhHzopy2Pj2O0lSB8pSLq4ZI7liNDPaMHQhI408v6H+xXgI6PAkqnzAN1y VYdaaEfWS2sXJRmvKIlHMmZtUTYCLI33oQ/DLV4nJOH/nhFmA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1731605099; x=1731691499; bh=R BYPfa0FnuBv2+IGiypWYhe+waom4D5qRYV2tSNyst4=; b=YNd1cu//N/BC5ezDQ zo6JQP3cKz0qg2AyxU9yb/XrtdfFH/KGn1g+IiawjWglywhToKGJqSAfeAm9YopG 9T/Q2WpHyeQEvqDnahAkM6NB8/DyIoD7bGcuEuYElum/Cn+MnixuXasZWxLRUq7f 0QOUl1sF3FDy6w9+mvOeuZfjoTY8wuybwVgKN7lMEtapjaIdWuHUo3t8ao6PFoxx OC8nxHkQ8k3VtyOhqZka5YPWlfBd7v+s4dI+kUtolpOcDmA1kiXhUsqqkGeayQQ5 Z2trxv5dTOPGARK0s01Tjsln8EmuPtb4hlF7+oZYhoF2L0g8x/bB73eZdNtYfKda q/l5Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrvddvgddutddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepofggfffhvffkjghfufgtgfesthhqredtredtjeen ucfhrhhomhepfdfnrghrrhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfih gvlhguthgvtghhrdgtohhmqeenucggtffrrghtthgvrhhnpeehjeefvefgfeduteffffdv heeiudekieefleevvdduiefgkeehvdevheffvdegteenucffohhmrghinhepghhithhhuh gsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhho mheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmpdhnsggprhgtphhtthhope dupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhssehlihhs thhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 92E2A29C0072; Thu, 14 Nov 2024 12:24:58 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Thu, 14 Nov 2024 11:24:38 -0600 To: "php internals" Message-ID: <3dcc5393-6ce7-465c-abe6-ecb687b0f369@app.fastmail.com> In-Reply-To: References: Subject: Re: [PHP-DEV] [Discussion] Make objects unpackable by default Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Thu, Nov 14, 2024, at 7:37 AM, Christian Schneider wrote: > Am 14.11.2024 um 10:59 schrieb Marco Pivetta : >> On Thu, 14 Nov 2024, 11:29 MrMeshok, wrote: >>> Hello, Internals! >>>=20 >>> 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 w= as advised to see opinions on this here. >>> So, what do you think? And does this change require RFC? >>=20 >> TBH, foreach on objects is already quite an abomination in itself =F0= =9F=98=AC > > 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 sa= ying ;-) > > - Chris Judging how one should use a language is a core component of language de= sign. I'm with Marco on this one, and I'd be more than happy to get rid of for= each($object), too. It's way, way more complicated a topic than you thi= nk. How does visibility play into it? Should hooks be invoked or no? Do references play into anything? Those are some of the questions we had to deal with for hooks and foreac= h(). It's non-trivial. You'd need to address all the same edgy issues = here, too. And that's assuming it's even a good idea, which I don't think it is. I= f you are using a value object to define unordered arguments, just pass = the value object itself. If the receiving function can't handle that, t= hen it is simple enough that you don't need a value object. If that's n= ot the case, then your code design is bad and the language should not tr= y to paper over that for you. Either simplify the function or adapt it = to use a value object directly. (With union types you can even do so in= a BC fashion much of the time.) --Larry Garfield