Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127359 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 998E01A00BC for ; Wed, 14 May 2025 19:55:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1747252371; bh=yDB/HK+cJL36YXnk0Dgyox5Ij4BZ2ZEWbQDIwkMr0Sc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=eTnoJF0+U++wquQIH2NwyhWvPi3vQYAz4kL0I7r1Fmi+JEO6VAP5wnRJseaSYe3iE xSn1C+ep9pyzH4MdAzR9NwS2/XJxILPTz9I9U06QrqyH45Uh/xmYf2px8CtfEFXyin 7eOLOhndgm/ltZ1BVcKzaw+yzioh6xvEGgWCENRai+aZdRVTItaSO0mnNswRp1e0td RLFJ/AyQAonRp35+L6scRs4c7UQm8w3zmKEgAsdrgnRGMIPJ3SahQD/PLwCNDOMBnu DO6rHNPSvvfuSLs/KO5jP7dTxSZ7YsnfmXmrybT1tLsZEX56KB3wRtmsqWGz9RralI JnnUFNB4d4B9Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8A415180084 for ; Wed, 14 May 2025 19:52:50 +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.2 required=5.0 tests=BAYES_40,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-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (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 ; Wed, 14 May 2025 19:52:50 +0000 (UTC) Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-acb5ec407b1so29789166b.1 for ; Wed, 14 May 2025 12:55:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tideways-gmbh.com; s=google; t=1747252500; x=1747857300; 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=e+VcXN5fq3gNo+oDYPQThlqloGUEMyP76znECGLQQds=; b=bQa1NgotvpgMzncFXIy99zv3t9k7V9IxezrzztDLu1fuCJqVTg0B0uKyLbc5f4vUuJ nqEVJuTfHnlxfJbKmx+47YiYaSDD1UU7rr+piAv5mQStgiygh/NpZP/uSg2pKmMTucDF 4mRNjG5vzcakOMGfv/v1k4qVO6XbWw9S9vbUxcmFFNvq0lEhZlP/lFyTFv7I9QsHONoZ Ckm91csisOEQMBH9tYMimh1Z2ieALRIPWrWN1Exf2iVcO0dAJG1elvQM1EvsJ6OFNkd6 MqqtBfzx10F7Tv3wQRS2YXgtYsneI5lwQyX0k88J0ba7yJRJZ/v53HiA6o4tHcFdrnMC wL3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747252500; x=1747857300; 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=e+VcXN5fq3gNo+oDYPQThlqloGUEMyP76znECGLQQds=; b=RGwjITf9u4AJK0Kod7KCDsPWrGjAHz3h43AJii4oe6M3rQdcrR726DFvw4DlV/s2LN QciREWY7+nu4fYrP19EfyahbG9c8RVVGrV1ztJgIoFmlGNzWTRf0tf+GoYnandhItms9 dPpLdrJf245ugTfcBPyPtEbZBh+lyhiCC2ibQtlUrlwpnHbKuOlcfVswyBBbY/+QNFdR Ce0oxGKK7CHKUaILzaYdMquK2o6fmaXy5LjnQrYeQ6xYywZKjc0jItYQeFZsLGmaBlgj QtwCeYpR3dDWd499RZOvNQBFLM/8NfsndK2e1H24VG2p/2EW71lIoqKoFMfbwerVpB0w svOA== X-Gm-Message-State: AOJu0Yxz1RvdGnx/nyzqsC28DAYIvU+1srTBv0yotHeB411mhcWDQTIi gBLFwvz4bQ38k63an3zcft1F07efcYNl8PrV6C5I7+9o0ZJ9P1AuV9vX0GhnXmWLNNCkynsnIqA 3lFlzrAz5eUd/jnhxpmNDkeliTMHkekQR/suy59HfTQ8OZfZuqJk= X-Gm-Gg: ASbGncua086GpwdI2FFAzy8v0Oe0BpFQWsMiENVNO72TciAkKSsWQIvE9ibU2B7GAJh ebTb82n47Y5Nyoe6UINhtdK9yc2iqBZV5cu0K7wFgk/+hYDhBsXZ4JWXYxzWbv2L24eOcMhwtyg xBG0Tv3Buf0bmx67F76HfTaBn9rNZ7K9I1Num1O9uYQaz1/wO6Qms3GT5ayquQ7QrIZnSakO63 X-Google-Smtp-Source: AGHT+IHFDPCDF3W5mfzWw2kgDqZgyycqr5kR+fyB0mN2VxTWUWFBfMIq8+ILYdNIAcUjvzRI0QoR8piqcuHkpotmy8c= X-Received: by 2002:a17:906:f588:b0:ad2:3577:38fb with SMTP id a640c23a62f3a-ad4f7153c65mr441301166b.30.1747252499796; Wed, 14 May 2025 12:54:59 -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: <533ea02a-dd69-4de9-8526-f808c5a9f4a1@app.fastmail.com> Date: Wed, 14 May 2025 21:54:47 +0200 X-Gm-Features: AX0GCFtM2Pe0_tEzkXf9uMlKhNQX-4jjDUihILFRYzbtjFKnF75xHt0S14OAxxs Message-ID: Subject: Re: [PHP-DEV] [RFC] Clone with v2 To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="000000000000956d2006351dec73" From: volker@tideways-gmbh.com (Volker Dusch) --000000000000956d2006351dec73 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, May 14, 2025 at 5:40=E2=80=AFPM Larry Garfield wrote: >> A magic __clone() method will be called before the new properties are assigned. > Why before and not after? I could probably make a good argument either direction, but we should be explicit about why we're making whatever decision. From a user-facing perspective, calling __clone() before makes it easy to know which state the object is in; all parameters are how they've been before the clone operation started and are therefore consistent. When calling __clone() afterward access to the new properties would already be set and the old ones gone, making this potentially harder to work with and harder to adapt existing implementations. So we chose the one that causes fewer potential issues and gotchas. > The last example, on readonly, is a bit confusing. It looks like it should work, but the comments say "but if we did this other thing we'd get this error." Just make it two separate classes and show one works and one doesn't. That makes it easier to follow. I've added the output to the var_dump statements to show what works. Standalone examples for the "missing" (set) felt more confusing than showing the difference in context and because its behavior is unaffected by the RFC and mostly documented in case someone isn't familiar with this detail in PHP, which I assume readers here will be. >> Alternatively, we could drop the variadic syntax and instead only accept an array as the second parameter. We're looking for feedback here in the discussion. > Oh lord please no. :-) Not using an array here is what I like about this syntax. An __object parameter is fine with me as a workaround. One shouldn't be using a named argument for that anyway. Thank you for your feedback! I'm looking forward to hearing what other people say as well, but it's nice to get a range of voices giving input here :) Let me just reiterate here that I find the difference to be minor to negligible. IDE/Tooling support needs to be built explicitly either way and is not harder or easier to do, and the ergonomics are quite unaffected in my opinion. So the worst outcome, for me, would be that we get hung up on the syntax here. > One shouldn't be using a named argument for that anyway. I'm not sure what you mean by that. Just so we're clear: `...["__object" = =3D> "foo"]` would also not work with the current implementation, as that's the same thing as a `__object: $value` named argument. (Should we decide to name the first parameter __object here). Sorry if I'm misunderstanding. Kind Regards, Volker --=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 --000000000000956d2006351dec73 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Wed,= May 14, 2025 at 5:40=E2=80=AFPM Larry Garfield <larry@garfieldtech.com> wrote:<= /div>
>> A magic __clone() metho= d will be called before the new properties are assigned.
> Why before and not after?=C2=A0 I could proba= bly make a good argument either direction, but we should be explicit about = why we're making whatever decision.

From a user-facing perspective,= calling __clone() before makes it easy to know which state the object is i= n; all parameters are how they've been before the clone operation start= ed and are therefore consistent. When calling __clone() afterward access to= the new properties would already be set and the old ones gone, making this= potentially harder to work with and harder to adapt existing implementatio= ns. So we chose the one that causes fewer potential issues and gotchas.=C2= =A0=C2=A0

> The last example, on readonly, is a bit conf= using.=C2=A0 It looks like it should work, but the comments say "but i= f we did this other thing we'd get this error."=C2=A0 Just make it= two separate classes and show one works and one doesn't.=C2=A0 That ma= kes it easier to follow.
I've added the = output to the var_dump statements to show what works. Standalone examples f= or the "missing" (set) felt more confusing than showing the diffe= rence in context and because its behavior is unaffected by the RFC and most= ly documented in case someone isn't familiar with this detail in PHP, w= hich I assume readers here will be.

>> Alternatively, we could drop the varia= dic syntax and instead only accept an array as the second parameter. We'= ;re looking for feedback here in the discussion.
> Oh lord please no. :-)=C2=A0 Not using an array here is what I li= ke about this syntax.=C2=A0 An __object parameter is fine with me as a work= around.=C2=A0 One shouldn't be using a named argument for that anyway.<= /div>

Thank yo= u for your feedback! I'm looking forward to hearing what other people s= ay as well, but it's nice to get a range of voices giving input here :)= =C2=A0

L= et me just reiterate here that I find the difference to be minor to negligi= ble. IDE/Tooling support needs to be built explicitly either way and is not= harder or easier to do, and the ergonomics are quite unaffected in my opin= ion. So the worst outcome, for me, would be that we get hung up on the synt= ax here.

>=C2=A0 One shouldn't be usi= ng a named argument for that anyway.

I'm not s= ure what you mean by that. Just so we're clear: `...["__object&quo= t; =3D> "foo"]` would also not work with the current implement= ation, as that's the same thing as a `__object: $value` named argument.= (Should we decide to name the first parameter __object here). Sorry if I&#= 39;m misunderstanding.

Kind Regards,
Vol= ker

--
Volker = Dusch
Head of Engineering
Tideways GmbH
K=C3=B6nigswinterer Str. 116
53227 Bonn

Sitz der Gese= llschaft: Bonn
Gesch=C3=A4ftsf=C3=BChrer: Benjamin Au=C3=9Fenhofe= r (geb. Eberlei)
Registergericht: Amtsgericht Bonn, HRB 22127
--000000000000956d2006351dec73--