Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127390 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 906231A00BC for ; Fri, 16 May 2025 19:40:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1747424279; bh=cfBfejEQbDHwWe773YexyTpQlerFAf3w8bVut5v+FJs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=bDaeJhYWX/D85OENO2ruKdJro345E1jc94n6k/4Xb9q9/TwgK1caxljosYuRrHxHr +0jpO56BUSvxUe6eou3mKM+Y3MG00XmVCz1+ZDHsvud3pqI/BzwwW/LtABdShKeK8Y sGbnVLRTmzTto0kh6a9dggIz2sDw4my7mPiYW9vZtbUgzbUe40zhCFBL+dgM3eveaq +g4GnL1M7BONiWTrbYeUN7J1UiynSopo6Dp0/1lXQNFC39VP47K9gw752v0zwZP4Q7 8sOBTjpWkJNi7EojuSFMY3XSomD0PH/AezBHVXZsNV89Xz9H3P4LNJpjKeThH9b0Jc XdFYIWYvGvkGw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F3DB9180057 for ; Fri, 16 May 2025 19:37:57 +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_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (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 ; Fri, 16 May 2025 19:37:54 +0000 (UTC) Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-54fc9e3564cso3189268e87.2 for ; Fri, 16 May 2025 12:40:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747424403; x=1748029203; 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=qk6cIofBFky10Sw7V53V1JmTkUI4gq5oiBrfEiLN0ao=; b=e5Wt6Yvr0ZnUco3mFgfoYJPph4aV2hdY7jw+A/eL66eAGbGPPOudIXCU4+fCMGdmQO b+A1rCTQl6I4rzxkM4IyEXhjEXypHkKPnAKYzKdO7urU1k1FefGtSUuWrAXxDyIydY2k oDkYCJ49zx6yRFEoEWQHw71jMB9o7Nzyp3SmA9us8JpfdFc+GrMq3zaTi9aULpEmiT8P 2tI2VqUV4fr/Q7ZBxn5HvKYGvjFOXoEbNnZo1vPibvC48lQpGj0xOsnAZ+4Roqn1hkWP Lrh2txdNaKYeSDrjOqsAgbF53qi9j3smHNR83XK6RNu0Po0IKG7gDrv3xZD52wnPQdQj /0Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747424403; x=1748029203; 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=qk6cIofBFky10Sw7V53V1JmTkUI4gq5oiBrfEiLN0ao=; b=q1ksD0a0kuEZzCiZQ3TXWrop8vBloXMwCoIfj9lTorQJvJbZ1u782Nmi0ASgc1S1Ex TaK0ZBdQysS59iu4veoIb/gNxZtbnTUNkeJepGjovYaoF27p75qKR9seCTnAfVDJLOXq /FbQQiwltVSGKfwBMCcuR17uQ3dlF61wHmdYGa7EIGMAld33IVMkUiCkKleal5SU52Il AAzMzqQ3XUmr9hNylJ/wxFoYC5RwENgnc8jc5jfbzTY/kro+QszC2fWPVrQSUo/MH6id tYU2f6cGdW+NnBV2dmmRSP0R1QRy1Iz4eIX7wh6GgMkIBRFTyVgMs0sq3fdg4OZaD0mY 0G+Q== X-Forwarded-Encrypted: i=1; AJvYcCUou8CPKlVR6cyero51sq0/vglnHtEIuiDJux2Rurn0+QjvtiP5aV5+Ksw+avnJPdARBzRd20K+Ivo=@lists.php.net X-Gm-Message-State: AOJu0YxGnT35w+FaUAvyj58nlfZU8TZtgnfRVt8rqodluS7kIBQ18S/b YQxrau4+gfk/06sQJbrcEqFlPL5TRwk/a6AiHbvGIm1HA73TwOlMqAt4wYjWiQju97yEpES7yWf nIWDyK/HoOBU2SoQmZbPJZrIiH5Nxygai/09y X-Gm-Gg: ASbGncvXngfqtukSZPCq125zJiUAOhBGWP/s0vzIrlokwZBViO7/J4yH1RKY8ysc7Ti +yiFoIkacVhJn/Sufc+lsr/ksRSDkTdQnNB9cGXv3dB7l93uCywx7Lau1HpgAKlqy0udmWtYBby yTdUhSToQOkrLPTgsYEVw/hwh80MZ/wPBVWr+3jUqBqUw= X-Google-Smtp-Source: AGHT+IGBPGejNTGMDyhUccmyXuqlJ7itiNwCUddJS8txBNHxlSKmNngHf3hWrHwpZq61oUYZ6Pa+eWPDduf29cVyX9Q= X-Received: by 2002:a05:6512:3e02:b0:550:e648:1821 with SMTP id 2adb3069b0e04-550e7255e03mr1584758e87.52.1747424402995; Fri, 16 May 2025 12:40:02 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <4a703db4174763586d84b9bf5606ff31@bastelstu.be> <956887e5b66e2b43459b999ebac2069d@bastelstu.be> In-Reply-To: <956887e5b66e2b43459b999ebac2069d@bastelstu.be> Date: Fri, 16 May 2025 21:39:51 +0200 X-Gm-Features: AX0GCFtVtWBoi4uG6PNKbLjWIOuiQypszwYem2yod-bgA_M4RwNcEFew3_Xw2nE Message-ID: Subject: Re: [PHP-DEV] [RFC] Clone with v2 To: =?UTF-8?Q?Tim_D=C3=BCsterhus?= Cc: Larry Garfield , php internals Content-Type: multipart/alternative; boundary="000000000000cffc9e063545f2e9" From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --000000000000cffc9e063545f2e9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Le jeu. 15 mai 2025 =C3=A0 15:55, Tim D=C3=BCsterhus a = =C3=A9crit : > Hi > > Am 2025-05-15 00:04, schrieb Larry Garfield: > > Subtle point here. If the __clone() method touches a readonly > > property, does that make the property inaccessible to the new > > clone-with? > > Yes. Quoting from the RFC: > > > The currently linked implementation =E2=80=9Clocks=E2=80=9D a property = if it modified > > within __clone(), if this is useful is up for debate. > > - > > > A single unlock block would be confusing to me. > > We=E2=80=99ve implemented it like that, because it felt most in line with= what > was decided in > > https://wiki.php.net/rfc/readonly_amendments#proposal_2readonly_propertie= s_can_be_reinitialized_during_cloning, > > which says: > > > Reinitialization of each property is possible once and only once: > > We expect =E2=80=9Cpublic(set) readonly=E2=80=9D + =E2=80=9C__clone()=E2= =80=9D to be rare and from > within the class, the author knows how their `__clone()` implementation > works and can make sure it is compatible with whatever properties they > might want to update during cloning. The lack of =E2=80=9Cuse cases=E2=80= =9D is the > primary reason we made the more conservative choice, but we are not > particularly attached to this specific behavior. > > Being able to update a readonly property even if __clone already touched it looks critical to me because otherwise, it'd mean that adding a __clone method after publishing a first version of some class that has no __clone method would be a BC break. Nicolas --000000000000cffc9e063545f2e9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Le=C2=A0jeu. 15= mai 2025 =C3=A0=C2=A015:55, Tim D=C3=BCsterhus <tim@bastelstu.be> a =C3=A9crit=C2=A0:
Hi

Am 2025-05-15 00:04, schrieb Larry Garfield:
> Subtle point here.=C2=A0 If the __clone() method touches a readonly > property, does that make the property inaccessible to the new
> clone-with?

Yes. Quoting from the RFC:

> The currently linked implementation =E2=80=9Clocks=E2=80=9D a property= if it modified
> within __clone(), if this is useful is up for debate.

-

> A single unlock block would be confusing to me.

We=E2=80=99ve implemented it like that, because it felt most in line with w= hat
was decided in
https://wiki.php.net/rfc/readonly_amendments#proposal_2readonly= _properties_can_be_reinitialized_during_cloning,
which says:

> Reinitialization of each property is possible once and only once:

We expect =E2=80=9Cpublic(set) readonly=E2=80=9D + =E2=80=9C__clone()=E2=80= =9D to be rare and from
within the class, the author knows how their `__clone()` implementation works and can make sure it is compatible with whatever properties they
might want to update during cloning. The lack of =E2=80=9Cuse cases=E2=80= =9D is the
primary reason we made the more conservative choice, but we are not
particularly attached to this specific behavior.


Being able to update a readonly proper= ty even if __clone already touched it looks critical to me because otherwis= e, it'd mean that adding a __clone method after publishing a first vers= ion of some class that has no __clone method would be a BC break.

Nicolas

--000000000000cffc9e063545f2e9--