Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127383 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 DA01A1A00BC for ; Thu, 15 May 2025 17:07:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1747328730; bh=HH1MQQOGPsusE22oG2cQ1MgSvCt1wnBbDDUJCa4hPwM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=OQnvwpK4rGgBt8Zc3Pe57gxVsYq7zp4O9quz0NPJBIz8hmJEf0HlkOabkUxRMVo9F trM/lTzUx+iKcF/J5yHPl/U0f19XKcNVCNrmp/5y1IXJEKkzjvosVXLL9FpnbTOfeK sezYFIlTYIc1ETJHBpN41v42pfkUZvtziI9U/TJn4qWyY9JwDjb7WGIWbWdj20wLJm SrBV97pEkF7eoGOhzByFIauQf1GeUbKwndbVADhCmDP2QXQ3hRixgyg2iWWhoR9irg LHimKlB1R6wOjp0e1hR54PIvieyKEV/ocNNv+DLHt7ZfNVlrJAOIfziITJgKTYuDzp TKBgE3WY3Yjjg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 424D21801DE for ; Thu, 15 May 2025 17:05:30 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS 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 mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (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, 15 May 2025 17:05:30 +0000 (UTC) Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-ad4ffb005d8so221418166b.1 for ; Thu, 15 May 2025 10:07:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tideways-gmbh.com; s=google; t=1747328859; x=1747933659; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Cscu6w+UqGRM30baiQj0i7NkP17Iv2WgwhJTdf2SWhw=; b=NLr4yuHEP5Hc2Xsnvi4G4553l7B4CDF4uWjh7KNXNSWf4YqyuFKr/VJK0L6MX3hhhY JczuJtFQ+F4OQdtw7jgEz0OVTJV9xTrbQWRQEXYAkC3xE6eTHVbunZTKaRO058yvtgkY 9wb0eZR0mKKEciJzUhuI3RiBHb4IhnV/uJjj/uXzlKUG2ajOnVmt5TZNIqR0u9ENmYKd hWozFNyYWG1BiRDwD68bxv3fhZ+Divbk+bLrY5oH1A+A3H6S/tvdGo8LooD+6pH0tAt7 IajsmX/IJsmfTfwo5YquDlchRRbL6E1a267XMBuFJqX5j8vwUjvdxnkkEW2m+k/IdNHM OMpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747328859; x=1747933659; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Cscu6w+UqGRM30baiQj0i7NkP17Iv2WgwhJTdf2SWhw=; b=B6+fPgVjaEPZ13hIlIm8rmqmaNbeKXOG73LBAvoufOCwsh01Tef4B2OG02znOPqHSK LkHEa+v6hLRnglfyHWifHPrSamgwWapvBf545j9OXkI1zgOK5gL7JW64X2xRG5wSdWPK wxp3gNSO801GTEn+eogS/L6ZrcM2mPmxTCdWcwXJVZvEeODBxhg/422rP1gH4uJxZwQ/ uci+oeu0bdEN5Ph0HYGWeIyNmy9Tu2C8ikA4KXuT8JqD2GmSPy/eSsYFNcfoOxUN22zq aKxxBykHpeDBehyW6A1Teytj91PM8NCL1rhWrxOzZoN7iTObP7ZrKz4LW1B6C76qsq2L 4qnA== X-Gm-Message-State: AOJu0YwExNiO03BLTx55e4DoifnYaq/QwyeSj7PWK+CCZ21p92Q5CYHd eeqHbcHC6/cyfed0XEdexOYb3GsxbCKF5hqTpfoE5/gnQo34qU4Tre6opOc5IggXqYvSqCeu0qw oFXGvxFoQDIxyJY2QaB/qVgAw5ALN8lEmaYyCUSZK3rrWNwzTOQr0CmxbaQ== X-Gm-Gg: ASbGncuIFjV+rlyhfwTbTDcCfUU4G/9YQhoP3T01LDmqbXV5wAqwdFIQ4chIlFw1AQr brurPTZO0f23zQ5tvlbn+lofXUSB9P4HUw9doNxWIiPCGY9rcTnHOmArqNukdRAi4t2FomCbZDh NBxg+YgrwxMap6R+RKg7b1FtU/amod0qnUSoqP3se/LunS9Sukeio59HwKUUXNiz7/E2DysjY7 X-Google-Smtp-Source: AGHT+IG0pVfm/hxBIaxflzUemZUyieQW2d74EYtptnyVOudbeXYcHDjurCu5GGpxWi9atQFMEq5ENTxNBE9oBoJJmDU= X-Received: by 2002:a17:907:80b:b0:ad2:47a6:b309 with SMTP id a640c23a62f3a-ad52d49d8e8mr54475566b.17.1747328859106; Thu, 15 May 2025 10:07:39 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <533ea02a-dd69-4de9-8526-f808c5a9f4a1@app.fastmail.com> In-Reply-To: Date: Thu, 15 May 2025 19:07:26 +0200 X-Gm-Features: AX0GCFvOsisYVjzZybto2yQbI_9h3-7z_ckUO_1xordx1tM2sUTjZGmC2I0NLnI Message-ID: Subject: Re: [PHP-DEV] [RFC] Clone with v2 To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="000000000000f4089d06352fb3dd" From: volker@tideways-gmbh.com (Volker Dusch) --000000000000f4089d06352fb3dd Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 15, 2025 at 12:10=E2=80=AFAM Larry Garfield wrote: > Please include this in the RFC. Done > The concern is someone calling clone($foo, object: new Thingie()), which would complain that "object" is defined twice. Making the first argument named __object sidesteps that issue > If someone then calls clone(prop: 'new val', __object: $foo), that... I suppose would technically compile, but one should never do that, and I am perfectly happy if that breaks. Similar for if someone called clone(prop: 'new val', object: $foo) if we didn't rename that parameter. No one should be doing that and I am fine if that breaks Yes. I think we're on the same page here. But just to be clear, I'll restate it again with my own words: Whatever the first parameter (the to-be-cloned object) of the clone() function is called will be completely inaccessible as a property name. clone($foo, __object: "bar") will fail (Named parameter overwrites previous argument) clone($foo, ...["__object" =3D> "bar"]) will also fail. While `clone(prop: 'new val', __object: $foo)` just works. For example, using the current implementation where the parameter is named `object`: ``` class Foo { public int $bar; } $x =3D new Foo(); var_dump(clone(bar: 5, object: $x)); // object(Foo)#2 (1) { // ["bar"]=3D> // int(5) // } ``` --=20 Volker Dusch Head of Engineering Tideways GmbH K=C3=B6nigswinterer Str. 116 53227 Bonn https://tideways.io/imprint Sitz der Gesellschaft: Bonn Gesch=C3=A4ftsf=C3=BChrer: Benjamin Au=C3=9Fenhofer (geb. Eberlei) Registergericht: Amtsgericht Bonn, HRB 22127 --000000000000f4089d06352fb3dd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, May 15, 2025 at 12:10=E2=80=AFAM = Larry Garfield <larry@garfield= tech.com> wrote:
> Please include this in t= he RFC.

Done

> The concern is someone calling clo= ne($foo, object: new Thingie()), which would complain that "object&quo= t; is defined twice.=C2=A0 Making the first argument named __object sideste= ps that issue
&g= t; If someone then calls clone(prop: 'new val', __object: $foo), th= at... I suppose would technically compile, but one should never do that, an= d I am perfectly happy if that breaks.=C2=A0 Similar for if someone called = clone(prop: 'new val', object: $foo) if we didn't rename that p= arameter.=C2=A0 No one should be doing that and I am fine if that breaks

Yes. I think we're on the same page here. But ju= st to be clear, I'll restate it again with my own words:

=
Whatever the first parameter (the to-be-cloned object) of the cl= one() function is called will be completely inaccessible as a property name= .=C2=A0

clone($foo, __object: "bar") wil= l fail (Named parameter overwrites previous argument)
clone($foo,= ...["__object" =3D> "bar"]) will also fail.=C2=A0

While `clone(prop: 'new val', __object: $fo= o)` just works.

For example, using the current imp= lementation where the parameter is named `object`:
```
= class Foo {
=C2=A0 =C2=A0 public int $bar;
}
$x =3D new Foo();
= var_dump(clone(bar: 5, object: $x));

// obje= ct(Foo)#2 (1) {
//=C2=A0 =C2=A0["bar"]=3D>
//=C2=A0 =C2= =A0int(5)
// }
```

--
Volker Dusch
Head of Engineering
Tideways GmbH
K=C3=B6nigswinterer Str. 116
53227 = Bonn
=
Sitz der Gesellschaft: Bonn
Gesch=C3=A4ftsf=C3=BCh= rer: Benjamin Au=C3=9Fenhofer (geb. Eberlei)
Registergericht: Amt= sgericht Bonn, HRB 22127
--000000000000f4089d06352fb3dd--