Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127385 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 A27661A00BC for ; Thu, 15 May 2025 19:57:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1747338908; bh=d0WWdgnEJBPV9lsuvxUk4FQJeKuzOWDWxULrX+0Eyps=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=EgNeEnhMhwJrHo//gFzAbdyiqYlSmJDXzW+s54Ecnf/LlfR50dXXsdlUTzKK4rA/i eGnh3Df+Jv1fiWLj+9heA4wGAZf9fKQDvM7CZx6em4N5PPQaXEt+Gvl/oVtudlHABp uMk5qCXXjaqUdT6xZhQ3lojAODOJtH8SZWQVjO8MR9FxJ/S11y/lCZUqpnoyQw61vp hUYXN+6S0jyskCkb4NKuzqF3tgD4Y/qVl7Gu9vaVUG6dalklrvCLZk4lv6xfGdRrjW fPjCyMwR2yrh1p3llodGiNphO1+C1PUfWhf9jGjSD6PhfwJOi9qIk2A5BFTUfNpXwv SJPco9qkTrmKg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3E3BE180051 for ; Thu, 15 May 2025 19:55:07 +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,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, 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 fout-a1-smtp.messagingengine.com (fout-a1-smtp.messagingengine.com [103.168.172.144]) (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 19:54:56 +0000 (UTC) Received: from phl-compute-05.internal (phl-compute-05.phl.internal [10.202.2.45]) by mailfout.phl.internal (Postfix) with ESMTP id AAD7D13803CE; Thu, 15 May 2025 15:57:06 -0400 (EDT) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-05.internal (MEProxy); Thu, 15 May 2025 15:57:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:cc: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=fm1; t=1747339026; x= 1747425426; bh=d0WWdgnEJBPV9lsuvxUk4FQJeKuzOWDWxULrX+0Eyps=; b=r H4oUuJJhypnZIwYcoXofnrBxQ3K2phDZKatKuFiZTxdZQepIC40BwT07xTDe2DY3 hAn5Uu0I6O54diuoeJ/hv8m5u9+zAZFkz9T5YWPKZ3eY++f0p5Q+A7c3uev6f4rD 5hJq8Fv+qSPgHJOPoVBRZCdl5y2kJ95giZehMTMUUK5caV1pzrlsTVo/yPeEda5l Vj9xhZVvV6SUfzC+vHN7pY344MH6CgB9kDJ8/qPk5P7jnSD3CCoP+KTiUgOcQ9AJ yLZulm4wK/ei3MnySsEfaJIxbZTYRJvkLeYJSKfadqgsTARA0JYd8IXCr7VyxPSm dPet1cxZcCkiNthkW9fFg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc: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= 1747339026; x=1747425426; bh=d0WWdgnEJBPV9lsuvxUk4FQJeKuzOWDWxUL rX+0Eyps=; b=nW/8q9h6ALy512J2aKfs0HmCl4kdzK6PgYF1GUP7kz9BVOuZ3ep KilVuW/IKfxCBd1YvE4CkO/auD1dTHvZqJjicHDzhIy4LjJB8/XvzVzRbuRBMp21 ETLa8bk4kqiOtQ+Cm0zpq6VDAULnxnxMUj3FWL0xk7iDbRexYQli2EUBf42aet8W CCJA92pVEfI19KXp0PIpCsjE7Lx6Gy3PkD6/EH+rSahogqsN/96XTLDJmcnm6cM7 uvL3Rm8yv9CPet9LnAqXq9wE2GT7ydkmi6BS03lervDVokK7Q2XJpsw3hB4Y0UMz 0ThOx7uuRsyqifCNyV68ooLZ+q/ETO6PTzg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdefuddtjeejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnecujfgurhepofggfffhvfevkfgjfhfutgesrgdtreerredt jeenucfhrhhomhepfdftohgsucfnrghnuggvrhhsfdcuoehrohgssegsohhtthhlvggurd gtohguvghsqeenucggtffrrghtthgvrhhnpeeiueethedvvdefjefhgfeiheelheehtdfh feekjefflefgvedvkeduteejjedttdenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpehrohgssegsohhtthhlvggurdgtohguvghspdhnsggprhgt phhtthhopeeipdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehtihhmsegsrghsth gvlhhsthhurdgsvgdprhgtphhtthhopegrnhgurhgvrghsseguqhigthgvtghhrdhnvght pdhrtghpthhtohepmhifvghivghrohhphhhinhhnvgihsehgmhgrihhlrdgtohhmpdhrtg hpthhtohepphhhphdqlhhishhtsheskhhorghlvghphhgrnhhtrdgtohhmpdhrtghpthht ohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvthdprhgtphhtthhopehvoh hlkhgvrhesthhiuggvfigrhihsqdhgmhgshhdrtghomh X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 03E48302005E; Thu, 15 May 2025 15:57:05 -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: Ta3b79d818733aba6 Date: Thu, 15 May 2025 21:56:30 +0200 To: =?UTF-8?Q?Tim_D=C3=BCsterhus?= Cc: "Stephen Reay" , "Andreas Hennings" , "Volker Dusch" , "Matthew Weier O'Phinney" , "php internals" Message-ID: <9c9d0541-381c-4fa9-8267-2492113f6fa2@app.fastmail.com> In-Reply-To: References: <266FA35A-15B0-435E-BBFE-1C6926EB0B7E@koalephant.com> <74fde04e-1cbf-423c-8b50-7d7eb156a056@app.fastmail.com> Subject: Re: [PHP-DEV] [RFC] Clone with v2 Content-Type: multipart/alternative; boundary=e065fa7b3bdb423f9471f44e0b3d673b From: rob@bottled.codes ("Rob Landers") --e065fa7b3bdb423f9471f44e0b3d673b Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Thu, May 15, 2025, at 17:32, Tim D=C3=BCsterhus wrote: > Hi >=20 > Am 2025-05-15 14:14, schrieb Rob Landers: > > For example, if you have a Money type, you'd want to be able to ensu= re=20 > > it cannot be negative when updating via `with()`. This is super=20 > > important for ensuring constraints are met during the clone. >=20 > That's why the assignments during cloning work exactly like regular=20 > property assignments, observing visibility and property hooks. >=20 > The only tiny difference is that an =E2=80=9Coutsider=E2=80=9D is able= to change a=20 > `public(set) readonly` property after a `__clone()` method ran to=20 > completion and relied on the property in question not changing on the=20 > cloned object after it observed its value. This seems not to be=20 > something relevant in practice, because why would the exact value of t= he=20 > property only matter during cloning, but not at any other time? >=20 > Best regards > Tim D=C3=BCsterhus >=20 Hey Tim, > why would the exact value of the=20 > property only matter during cloning, but not at any other time? For example, queueing up patches to store/db to commit later; during the= clone, it may register various states to ensure the patches are accurat= e from that point. That's just one example, though, and it suggests call= ing __clone *before* setting the values is the right answer. I think Larry's idea of just using hooks for validation is also pretty g= ood. As Larry said, the only thing you can really do is throw an excepti= on, and the same would be true in a constructor as well. =E2=80=94 Rob --e065fa7b3bdb423f9471f44e0b3d673b Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable


On Thu, May 15, 2025, at 17:32, Tim D=C3=BCsterhus wro= te:
Hi

Am 2025-05-15 14:14, schrieb Rob Landers:
>= ; For example, if you have a Money type, you'd want to be able to ensure=  
> it cannot be negative when updating via `with()`. = This is super 
> important for ensuring constraints ar= e met during the clone.

That's why the assignme= nts during cloning work exactly like regular 
property as= signments, observing visibility and property hooks.

=
The only tiny difference is that an =E2=80=9Coutsider=E2=80=9D is a= ble to change a 
`public(set) readonly` property after a = `__clone()` method ran to 
completion and relied on the p= roperty in question not changing on the 
cloned object af= ter it observed its value. This seems not to be 
somethin= g relevant in practice, because why would the exact value of the 
property only matter during cloning, but not at any other time?=

Best regards
Tim D=C3=BCsterhus


Hey Tim,

=
why would the = exact value of the 
property only matter during cloning, = but not at any other time?

For exa= mple, queueing up patches to store/db to commit later; during the clone,= it may register various states to ensure the patches are accurate from = that point. That's just one example, though, and it suggests calling __c= lone before setting the values is the right answer.

I think Larry's idea of just using hooks for validation= is also pretty good. As Larry said, the only thing you can really do is= throw an exception, and the same would be true in a constructor as well= .

=E2=80=94 Rob
--e065fa7b3bdb423f9471f44e0b3d673b--