Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127389 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 D1A9D1A00BC for ; Fri, 16 May 2025 18:45:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1747420979; bh=y/PZeVSk6Sl2EORSYswSPWgRsNqnAZnXvEwOB7XvTb4=; h=Date:Subject:To:References:From:In-Reply-To:From; b=kkFB6l5mGYAVouRiirBfEcLvI87Td4ST+CSD/39VNS6I0cXPWw5Chii+b61LXn+0M KscpFNl4T5OFZDp1F/wFP4Wi6lHs9+qbpQZl8ROItId25fWLJb3FF8ozbD/1cEg+7T RQwYOX9SvikVYSbpwvz99NBIqMCelvqN0bGZ7iL1G3gNhyrXnwHgDSJm5Su94muFLM A6pI1BX9BU18wX+GFV6BrKmJl6GQ5tW1BohlwjVxvWufBNn6GwlcvIMPAqbVT1TMvB bVEorFx2dMe29p1De1AK7W1D5D2BkH4r9uc0qq5+2vpgM5R2qa19SGVDewrVLwZBdp d/ta0fOwGL5mQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A427118006A for ; Fri, 16 May 2025 18:42: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=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, 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-b7-smtp.messagingengine.com (fout-b7-smtp.messagingengine.com [202.12.124.150]) (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 18:42:47 +0000 (UTC) Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfout.stl.internal (Postfix) with ESMTP id E1068114017A for ; Fri, 16 May 2025 14:44:56 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Fri, 16 May 2025 14:44:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; 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=1747421096; x=1747507496; bh=TzDJdsKcK97e7JeCzRCAsBU5qeBiPw8OrrWRtenLDMI=; b= SEP/luYe1USQUd66M88kDdZwEK9J4wpSnJ6VLd+SOzu61ug8QeBeMST+Qpox7l0s p9a86w0LzpUODbzXSRCT5YCGn/wOqG1356t/VUd43jOnshBi4Dfyrk6il8RrJbGp 1Rz+ghy/4+M8h8a79LpuzuahLObdXgSlwivuddwwUpZH7bSNBxMzykNPECmH+y8p Px5Q5oxYLDNKfBcQvaDpTbn7+xRvB7G1YVp7e4Srzdi5MEAPUJO071ZBctN5B3Cl EE4ASSymUeu0BVRaorVq5CrtsnZFVCIVD7/AyIZsOiYkWVM3rmfz7GCldo6Rudfq 4J8bcA2hKdWD4uHiFAS13w== 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=1747421096; x=1747507496; bh=T zDJdsKcK97e7JeCzRCAsBU5qeBiPw8OrrWRtenLDMI=; b=K+mrYn8RJiIoTxWML z9fJjFV7YnrpLx5BjuRWAW9Jh2vz90AXGub+rygn1YfaLq8msXoTtRCd6J4ZI83M rydy8tKfrN1ZnWhMcuvpWmiwuKtJmu/JP9wmj/hqo/IJ+gCxjtRqv4HVuJcLh/t3 4inT2+9KMemN8iRMcWBZR0MKA5emUUk5NdvqO69sgMBViVYHf5W4jy39BFSjhtdo goK2P3bsln/tmGB2ZfCINm/rqmNdkeJgXXMxrQTn+g+25otl7wO7oR04wZGHSlIX Hynn5xyeYpJcn9fjpwEUrQBmNQY4OHDRGJzdDe3PsR+iqCKZKcECk3TeESbLgxTU m6UJA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdefudefhedtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefkff ggfgfuvfhfhfgjtgfgsehtjeertddtvdejnecuhfhrohhmpedftfhofigrnhcuvfhomhhm ihhnshculgfkoffuohfrngdfuceoihhmshhophdrphhhphesrhifvggtrdgtohdruhhkqe enucggtffrrghtthgvrhhnpeejkefghfeugffgtdeuheeggfdugefhudekjefhteegieej leehveelhfefvdfhudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehimhhsohhprdhphhhpsehrfigvtgdrtghordhukhdpnhgspghrtghpthht ohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlsheslh hishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 16 May 2025 14:44:55 -0400 (EDT) Message-ID: <7ec1997d-a8d4-43fd-870f-9a18872c7c8f@rwec.co.uk> Date: Fri, 16 May 2025 19:44:55 +0100 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [RFC] Clone with v2 Content-Language: en-GB To: internals@lists.php.net References: <266FA35A-15B0-435E-BBFE-1C6926EB0B7E@koalephant.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On 15/05/2025 18:56, Stephen Reay wrote: > I agree that no __clone and an empty __clone should behave the same > way. But as I said, I believe they should behave the same way as they > do *now*, until the developer opts in to support cloning with new values. I think what Andreas is saying is that the behaviour of this: $foo = clone($bar, someProperty: 42); Should be consistent with the existing behaviour of this: $foo = clone $bar; $bar->someProperty = 42; An empty or missing __clone method won't prevent `someProperty` being assigned in the existing case, and for everything other than readonly properties, the new syntax is purely sugar for the existing one. If I understand the RFC, the only change in behaviour is for readonly properties, which are "unlocked" during the "clone with" process. That means that if they were previously validated only in the constructor, this syntax can put the object in an unexpected state. However, readonly properties are "protected(set)" by default, so the situations where this can happen are actually quite limited: - Code inside the class itself (private scope) can reasonably be considered to be "opting in" to the feature it's using. - Code in a sub-class (protected scope) can by default over-ride the constructor anyway. - Code outside the class (public scope) will fail unless the property is explicitly "readonly public(set)", which would be pointless if it was always initialised in the constructor. So the only case I can think of where something surprising could happen is: 1. A public or protected readonly property is initialised in a constructor marked "final" 2. A sub-class adds code that uses "clone with" to set that property to a new value The question then is, how worried are we about that scenario? -- Rowan Tommins [IMSoP]