Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127420 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 lists.php.net (Postfix) with ESMTPS id 9F3451A00BC for ; Thu, 22 May 2025 04:28:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1747887964; bh=iykbOTMG9/agav9MR2zJz8NmdN/snCy44hFPOcsfnL8=; h=Date:From:To:In-Reply-To:References:Subject:From; b=KP+5EfrhcDsPsLIRXKM3GnS7wbaTQIDoeiCUjt+G9CnTwJy6vTqq4+4fUSy2oPJ+/ W29vcC9VNMXpmXuQx5j/pHg0cFhWLXt5irE+RquQuDZmcGxQ4vM0G5FjQnrF6ulLBw 4eqRSypEgFWVca94IWg+QsMODt0cbNcHPBd4uppwkQspScE2aEpJxjl5of87ntdU/a kWo/mOHUuSlnsgZd+XDoZxpJ82dLepg1XqQ2pxgkT44/z6k5GlH29oFb7zLLSa3Kkq 0YI4PRzgbMudKPnC0+VArxasWwchdguaOkR+R1KTr9P/S8UnETpXFkBnhHf3L+Z5NY TttEVzH49HVnA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E47A6180047 for ; Thu, 22 May 2025 04:26:02 +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.9 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fout-b6-smtp.messagingengine.com (fout-b6-smtp.messagingengine.com [202.12.124.149]) (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, 22 May 2025 04:26:02 +0000 (UTC) Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfout.stl.internal (Postfix) with ESMTP id 97B7B11403DB for ; Thu, 22 May 2025 00:28:10 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-10.internal (MEProxy); Thu, 22 May 2025 00:28:10 -0400 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=1747888090; x=1747974490; bh=RoDP6wj1JfO9Cs+tJe0o0 fRsl9AOgnwgwo9YMVZ/UOw=; b=LsBK5IsAeZ4+jar3vydLE9+88ciN7XKI9AszY gLIt9b7C7M1q2XnxW9wjix0CrTzC8w53leFTye7FmoeXuEHU13ZupUZkvx2KeATh HdnMtTM3DWIjxhSB3YXW4oRNd6JH/8RLLpLJKak0oaYIT/LTG0DSIIsrKPqZg+3A W2IUzASVh2Wh1tsYXNpw1Hc6Yu7mnrer1EWLbzRv2T4bBrIzeKGF7n0Ke7Ki3J/7 euvnBU77ccEgZ8IeHRLKLXWI4fIBq7tcsN2YiP3NTGob9riVuofehiDT4P4h5K7N KQNQ2XtGFa+gKk2suGKheuYQskODU+0OM1PxrGacGhacKn4zw== 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=1747888090; x=1747974490; bh=R oDP6wj1JfO9Cs+tJe0o0fRsl9AOgnwgwo9YMVZ/UOw=; b=prDoxguTmQ5qh8jNF z/p/wX2xoRV2/RQDcMVHYIN7lzntBh7Wxh3ImljSineOag1qCUll4EchmhOLwsxW MXdMZRWzR6Mo7oL3+L6UIH7qXO/bD79jA2wR+DInDAWw9t1kVq6miqoUtJCFGVyn k4eLYdXzIAWLUoN6TS1uAIoZHO8LT6Hh0dQR01CLKl1IevHAMycxVTR7ogvWCmhI F100CEWHu67FUyn/NVPn4oGDLE37tiKERm+xLpZtWdwbJL5VtWyPAvLGRHVbXN1B fAjHdS40Fd1tmd1g4kgApcfq01W7jAjZWG1iPnSKaRox/+eiac1b0LkroV6+23r2 D0ktg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtddtgdegleelucdltddurdegfedvrddttd dmucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgf nhhsuhgsshgtrhhisggvpdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttd enucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepofggfffhvffkjghf ufgtgfesthhqredtredtjeenucfhrhhomhepfdfnrghrrhihucfirghrfhhivghlugdfuc eolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmqeenucggtffrrghtthgvrhhn peeluddvudelkeeijeekueekgfdvieefleevveejfefhfedtuefgudeiueehffelkeenuc ffohhmrghinhepphhhphdrnhgvthdpghhithhhuhgsrdgtohhmnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlh guthgvtghhrdgtohhmpdhnsggprhgtphhtthhopedupdhmohguvgepshhmthhpohhuthdp rhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 20BF4700061; Thu, 22 May 2025 00:28:10 -0400 (EDT) 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 X-ThreadId: T11f5e8d0f54ccf80 Date: Wed, 21 May 2025 23:27:48 -0500 To: "php internals" Message-ID: <9aa91498-b224-4a46-8c7e-21ae8a9c58a7@app.fastmail.com> In-Reply-To: <2f30cae4add309021e18d0f359a1814e@bastelstu.be> References: <2f30cae4add309021e18d0f359a1814e@bastelstu.be> Subject: Re: [PHP-DEV] Re: [RFC] Clone with v2 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Wed, May 21, 2025, at 9:13 AM, Tim D=C3=BCsterhus wrote: > Hi > > Am 2025-05-19 12:48, schrieb Volker Dusch: >> We're still looking for feedback on the ...variadic approach to the=20 >> Syntax: >> https://wiki.php.net/rfc/clone_with_v2#open_issues, as we only got one >> reply so far on the topic. > > I was hoping for some additional opinions here before adding my own, b= ut=20 > since this does not appear to happen, adding my personal opinion on th= is=20 > matter now: > > *Some* property name being completely incompatible with =E2=80=9Cclone= with=E2=80=9D (no=20 > matter how the first parameter is going to be called) is a limitation=20 > that should not exist, it feels like a feature that is broken by desig= n=20 > and I think I really would hate it if the documentation of this RFC=20 > would need a =E2=80=9CCaution: It is not possible to reassign a proper= ty called=20 > '$object', due to a parameter name conflict=E2=80=9D. I completely disagree here. The __ prefix is sufficient to solve the is= sue. A double underscore prefix has been understood to mean "internal t= o PHP, magic here" for at least 20 years. The chances of someone having= a property called $__object are virtually nil, and if they do, they're = already treading on naming that's reserved for PHP's use anyway so if it= breaks, it's their own fault. > Adjusting the signature to `clone(object $object, array=20 > $withProperties)` would not have this problem and I don't consider the=20 > additional verbosity of an array literal to be a problem. Static=20 > analysis tools already understand array shapes and would need=20 > adjustments either way to understand the semantics. > > From an implementation PoV a regular array parameter would also be=20 > simpler, since the implementation would be able to simply pass along t= he=20 > input array, whereas the =E2=80=9Cvariadic=E2=80=9D syntax needs speci= al handling to=20 > combine positional parameters with named parameters into a single arra= y=20 > that is then used in the cloning process. > > Syntax-wise there might also be a middle-ground. Similarly to how this=20 > RFC turns `clone()` into a function, the `array()` syntax also looks=20 > like a function call and would naturally extend to named parameters.=20 > While mixing positional and named parameters would probably get comple= x,=20 > allowing purely named parameters would trivially be possible (without=20 > any function call overhead). It would also allow using the=20 > first-class-callable syntax with `array(...)`, something I would liked=20 > to have in the past. A proof of concept PR is at: > > https://github.com/php/php-src/pull/18613 > > Combining named-parameter `array()` syntax with clone taking a array a= s=20 > the second parameter would allow for the following, which might combin= e=20 > the best of both worlds? > > clone($obj, array(foo: 1, bar: "baz", object: "this is not=20 > blocked")); I completely disagree here as well. I actively dislike using an array h= ere, as I do find quoting all the keys to be cumbersome. And I don't th= ink we should go with a worse syntax in the hopes of it being improved l= ater, when there may well be other unforeseen challenges there. (Eg, I = have no idea if bare array keys would cause issues with constants.) Mor= eover, we have 15 years of training and coding standards and automation = tools that say to never use array(), always []. Reversing that would be= far more disruptive for the ecosystem, even if it turns out to be not t= oo disruptive to the code. I strongly prefer the current syntax, and if the RFC changed to require = an array I would strongly consider voting No on those grounds alone. --Larry Garfield