Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127386 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 A09C11A00BC for ; Thu, 15 May 2025 20:11:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1747339778; bh=LVrcNY27DwszosFG/6fg59i8i93XyLkgc0sjXr21CpM=; h=Date:From:To:In-Reply-To:References:Subject:From; b=PmazH0rMvQvGJFvrxApwGC85/VVYdi70fWv9o+CQyhCGVNMGU2IFA8uhJrMBFs7Ru sNequ2WK8TDcmJLyhzdB2+mRQgVEBIvTqAjGppMVkd20TobYbe84RMWUAteBzYDqLY ErL3tc5YQcDrQQ5ehr2NS5ul0B11aWPXobo4yaW44tPGMl/4uNWLtQWD9Py9hO19MU KaqsFjvzpfL4pcVUxIRmKaKf6TOZgP4bOJuYbTf6RPeq2WwBjFlE4paEUJzoecKWHu YClkiXE2fyhSWfb2pRiq650NLhvfx/bJpnh51R7+xtggTO034S40Obf+xgTlrjG+dH WBYgFP/c1B9Gg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 49D7B180068 for ; Thu, 15 May 2025 20:09:37 +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_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,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-a2-smtp.messagingengine.com (fout-a2-smtp.messagingengine.com [103.168.172.145]) (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 20:09:37 +0000 (UTC) Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfout.phl.internal (Postfix) with ESMTP id 3AE1B138009C for ; Thu, 15 May 2025 16:11:47 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-10.internal (MEProxy); Thu, 15 May 2025 16:11:47 -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=1747339907; x=1747426307; bh=uOuEMWtM4/93LyTfPZzxi UVdNKyWeG3GHh1VQncYXpc=; b=D1E/ZRN1dWLrj3PJDj+JlMb7rMQe8HVwZyBPt xrE5nvDZIO6mFS/TVEJhqz4hmJHI6SYk10ACo4oWTpDv1CMQwf+WaJB64noXtXH9 eTS1eksfmJjOF9cYw7AGn+7YQs5gxMg435n3ZLicfW3Oha5ROZOPGUbnGoe25l1Q slHNRBfsBtX7R4sMaVbsdhrnTTG3/kOu71F5RXKvet9RIlWpPQUXDf/jmEOmFB8j 2SuqGbEQGlJCTs4thgFeExzm9LgJ2rcObWmN8gain77nm66q9RV3R2gC6eFVTHwB t9R0Wv0S90H551LtEBUwriuH50IqeNSNgufBbEYdG5qzwCA6w== 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=1747339907; x=1747426307; bh=u OuEMWtM4/93LyTfPZzxiUVdNKyWeG3GHh1VQncYXpc=; b=D98ZSZhk/EaP2tCcr WyYgEjIWhmu8FrCWgvu1vKFv4iK2WKhnEQCYq0iukM9DrCTdj8Sfs/Q3jCJ094EP H1Mss/u4jT1gHNc3soC3V3fODBfw/f2XnJ7rrfTPejzDI+AUvyrPau6Ud3XFOzFR wlUbnKQaP4eu/WXfU9UybwAmWv8bERA9zlJ2L7f2Aw8vwX8wO38v/BQhdd9h+EIM Az4DaU/yC23kb+XqV+rDci4Fki6bGwVI8XdXWLylt6Ah+Wg0PByRursR7wzwG0G8 TMsGgnDm1Sd5kmwMFwtwCTUuAd792R6H8sixWeMncrhvCLxk5WmVPQkpzMObufdE 7iLng== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdefuddtjeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnecujfgurhepofggfffhvffkjghfufgtgfesthhqredtredt jeenucfhrhhomhepfdfnrghrrhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrh hfihgvlhguthgvtghhrdgtohhmqeenucggtffrrghtthgvrhhnpeffieeivdfhvdeguddt tdegteeiueegvefhteehfeeffeetudeitdehtdegjeeuieenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlught vggthhdrtghomhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtg hpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id D400F70005E; Thu, 15 May 2025 16:11:46 -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: Thu, 15 May 2025 15:11:13 -0500 To: "php internals" Message-ID: In-Reply-To: <9c9d0541-381c-4fa9-8267-2492113f6fa2@app.fastmail.com> References: <266FA35A-15B0-435E-BBFE-1C6926EB0B7E@koalephant.com> <74fde04e-1cbf-423c-8b50-7d7eb156a056@app.fastmail.com> <9c9d0541-381c-4fa9-8267-2492113f6fa2@app.fastmail.com> Subject: Re: [PHP-DEV] [RFC] Clone with v2 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Thu, May 15, 2025, at 2:56 PM, Rob Landers wrote: > 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 ens= ure=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 abl= e 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 = the=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=20 > the clone, it may register various states to ensure the patches are=20 > accurate from that point. That's just one example, though, and it=20 > suggests calling __clone *before* setting the values is the right=20 > answer. > > I think Larry's idea of just using hooks for validation is also pretty=20 > good. As Larry said, the only thing you can really do is throw an=20 > exception, and the same would be true in a constructor as well. > > =E2=80=94 Rob The limit of hooks is that they're single-property. So depending on how= your derived properties are implemented, it may be insufficient. I cou= ld easily write such an example (the hooks RFC included some), but how c= ontrived they are, I don't know. --Larry Garfield