Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128125 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 94CAB1A00BC for ; Fri, 18 Jul 2025 18:06:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1752861885; bh=iTiMrf1qqXhD0mgZCHzWI6jOd9xtazeTQ7J4oeHJiRw=; h=Date:From:To:In-Reply-To:References:Subject:From; b=HctaHD/2tSDcUBgy2BiyhUgcyxEPRzuWe0DwHhYCtLvbRDzH3ylGNJNoNwbhcUgYY oAn/4aCZWeh7hLE3Uvf4cc0i3h0JK8dcFumArWrtv6lSWuQyTCP56Gfr21VbYo/6Ns BqTA4qRH0u4eoYHTJzPGJkhAVhnqBTtCsdT2FS2fuheAoaffl9nfo8Chiwd+XIg8kq wUD/cZsnbGNcUwovBbS35Dcg16HI2Tzl/guxmtCCb35SogQGGCZfL6nFz/3lId44TE 3CnzEkgekWaJoNIX6YEpSRjtm/uspXZj1Jrj7yYLAElIYkSqBUOITiUhSKkYzN7SkT 0id9GmV5h68iA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3B850180533 for ; Fri, 18 Jul 2025 18:04:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) 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_NONE autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fhigh-b8-smtp.messagingengine.com (fhigh-b8-smtp.messagingengine.com [202.12.124.159]) (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, 18 Jul 2025 18:04:43 +0000 (UTC) Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfhigh.stl.internal (Postfix) with ESMTP id 21F297A00EC for ; Fri, 18 Jul 2025 14:06:30 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-10.internal (MEProxy); Fri, 18 Jul 2025 14:06:30 -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=fm2; t=1752861989; x=1752948389; bh=vOUTXr6U/FDwBCuvnPJTa 6tWKuJuzLn1I771lHF7CTE=; b=Kr4PsAdVvkhIOIXtsRp3HOUv6jf7MHZoRSJqo KAxUZhH0TlKIiMkELfD9ntGIlbAh1894UOkm3wg6EqZV0Uf1ZQjfwtTWssRKD1kj xSiklRITfXgSP9tG0CYcqmPZK63PQIqDbub6kN/JJGEW/soPdwk3L/yw24ywG89I 0mKSJ6mcVn/aniZHb57Zl+9umIvzaubNnVZpdyBO1anDYnwFqtYuB+oLgv43Z4AW d/xLsCfYddEN7oN3y6+eEhoTFZJp19A/54sgBw7jQOts6XjUM1SjPFp/7UQqN0nZ XW4FRXntqX9Z5EvDduxtK+76AtMLUXAovZtRWtTShA6bCZ4TQ== 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=fm2; t=1752861989; x=1752948389; bh=v OUTXr6U/FDwBCuvnPJTa6tWKuJuzLn1I771lHF7CTE=; b=XBhdkhxgrAL9ZoEXT ewcb/o9ZgCXoInvFtAybw2+kUj20mDEABBTbzQbDPA7JEFdziANR0pVrYoxaoemm hd2gcsTn9PKXuZRa98YUUDX0P877qHNPlpYtUTwVOKP+Bi/LNQEYVhe8AaCvIv23 dOsTYDQBkKRR+ZaW3ng82QoQKXq9B/qHRPn7NDlxSB8dasoTZZGcycftckLmWc8V LJi+YOR30lIaMpMrCRrQ2ETgi19dNIJJd1iXYOD1qdpx6hy5OnTyILrg0+248bTn lq5LrxYf+6G1Ts6z+w5WRV1ctG3Ky2EvH0APhU/oasqag+ctCfAAE07owOS534KV /HZyA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdeigedugecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefoggffhffvkfgjfhfutgfgsehtqhertdertdejnecuhfhrohhmpedfnfgrrhhrhicu ifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomheqne cuggftrfgrthhtvghrnhepffeiiedvhfdvgedutddtgeetieeugeevhfetheeffeeftedu iedthedtgeejueeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmpdhnsggprhgtphht thhopedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhsse hlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 359AB700065; Fri, 18 Jul 2025 14:06:29 -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: Td921449bd694ee01 Date: Fri, 18 Jul 2025 13:06:08 -0500 To: "php internals" Message-ID: <37d0aa7a-aa94-4e70-914a-3a41a6c4b060@app.fastmail.com> In-Reply-To: <0e8eb146-3b1d-4fc2-ad83-77062f2063c9@bastelstu.be> References: <1e8634d7-ac1a-4025-b4e2-1948aabf5251@app.fastmail.com> <09780759-9ddc-45e2-9376-befb8e378775@app.fastmail.com> <0e8eb146-3b1d-4fc2-ad83-77062f2063c9@bastelstu.be> Subject: Re: [PHP-DEV] Re: [RFC] Readonly property hooks Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Fri, Jul 18, 2025, at 11:29 AM, Tim D=C3=BCsterhus wrote: >> // New code in 8.5: >> =20 >> $p =3D new PositivePoint(3, 4); >> $p2 =3D clone($p, ['x' =3D> -10]); > > This is not legal code in PHP 8.5. Clone-with respects visibility and=20 > since your asymmetric visibility RFC included the change, you are=20 > probably aware that `readonly` implies `protected(set)`. > > 5. > >> but are now necessary to ensure that invariants are enforced. > > And therefore with PHP 8.5 hooks are not necessary to enforce=20 > invariants, except in the rare case where a `public(set) readonly`=20 > property is used. This is a valid point, thanks. I have updated the example to use `publi= c(set)`, and note that it means many withX() methods can be eliminated, = as their restrictions can be placed on the property instead. Note to self: public(clone) ...=20 > 6. > >> So no guarantees are softened by this RFC. > > Yes, they are. Unless `__get()` is implemented on a class (which is=20 > explicitly visible as part of the public API), readonly guarantees the=20 > immutability of identity. Which would also be guaranteed with the "refers to the backing value" pr= oposal, which you also rejected. Does readonly refer to the physical value (backing value, object identit= y) or the "value returned"? That wasn't a distinction that mattered in = 8.1 when readonly was introduced, though now it does. If yes, then all = that needs to be protected is the backing value, so get hooks that respe= ct that should be fine. Does readonly refer to the value returned? If so, that's already been b= roken since the beginning because the property can be a mutable object, = so trusting the data returned to be "the same" is already not safe. At a conceptual level, we need to decide what readonly means. There is = clearly no consensus on that right now, and that's going to cause proble= ms any time we touch readonly, not just this RFC. =20 >> While that is an interesting idea that has been floated a few times, = it has enough complexities and edge cases of its own to address that we = feel it is out of scope. > > While it certainly is your right as the RFC authors to consider certai= n=20 > things out of scope for an RFC, I strongly oppose the notion of shippi= ng=20 > something that is strictly inferior and comes with obvious semantic=20 > issues due to perceived complexity of another solution and then=20 > following up with the proper solution that has already been identified= .=20 > As I've outlined in my previous emails, I found defining semantics for=20 > an 'init' hook straight-forward when looking at how PHP works as of to= day. I suppose this is a valid argument, given that readonly was implemented = because Nikita felt the proper solution of full aviz would be too comple= x so went with the simpler solution, which, turns out, is strictly infer= ior and comes with obvious semantic issues. > After reading through the discussion, it seems the only argument again= st=20 > the 'init' hook is perceived complexity. It is not at all clear to me=20 > why this means that we must now rush something with clear issues into=20 > PHP 8.5. At this point, I fully expect the 'get' part of the RFC to not pass. So= meone else is welcome to then work on an init hook. The seemingly less = controversial 'set' hook still has considerable value on its own, and ho= pefully that passes. --Larry Garfield