Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126511 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 qa.php.net (Postfix) with ESMTPS id 31BB71A00BC for ; Wed, 26 Feb 2025 08:17:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1740557712; bh=NfIIfCUe42/NaRSFL8jxlGdhVAzhLpbyzWTssYWTeq8=; h=Date:From:To:Subject:In-Reply-To:References:From; b=VPQfd4FtmnWDAe+ISq0Gbk+xWc4wp5xgvjfNeoZbINgKHhPE1VaTziz9drg4F88rB f4LTQrnOadZs14thmx67EMpdXTS/m1A4hLtBx/191BWRdA4n0PVANlg5XZUA0ARALL hmRvpb6GmjEue1TRUjhl+wvVHREA2MllO6xFXudZoDrOow9RfOhpqT5rYj3sNuASYh eQXbtzo+K1+WlB05jPIrRooxRnlb/LobtKqe/dkChBz1SSZoaCJHLT9J/AynvxSD7o ZawoQC+BuVWsa1UsQKm7CZ+pSVolTH18JqvCXp2r7ncNSWNAUmEqt4uxm59SsaeF8E 4d4PsssFni7xA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C8E6B180072 for ; Wed, 26 Feb 2025 08:15:11 +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: No X-Envelope-From: Received: from fhigh-a1-smtp.messagingengine.com (fhigh-a1-smtp.messagingengine.com [103.168.172.152]) (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 ; Wed, 26 Feb 2025 08:15:11 +0000 (UTC) Received: from phl-compute-09.internal (phl-compute-09.phl.internal [10.202.2.49]) by mailfhigh.phl.internal (Postfix) with ESMTP id 5F50011400FE for ; Wed, 26 Feb 2025 03:17:49 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Wed, 26 Feb 2025 03:17:49 -0500 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=fm1; t=1740557869; x=1740644269; bh=NfIIfCUe42/NaRSFL8jxlGdhVAzhLpbyzWTssYWTeq8=; b= E652MEwPPuhJ6r0CIr61pib6rqdaDRu+lgSekNORtTLG1ozrZFshD2kKsC73e/W7 N3C0jbW2l6oyuU4LuHqt2I0NsK9U1xM3JFMAfbt9x2WjmbIdbexy4Ql1NYx+l0TF CgS7QKyUZ8KQRw+Xd+MHNKT8LDrghOKeaoVOFBoDT7rtceuXq+Y5fSZEnklv+1xr 7bGYa/eVX/D6oehWtys2qbMgi5e3p1rrqlZCLIekXfKVCZQHLIiUhcGkJqBpvJwX a1y8SEA8ggzjQgEM8oZh94+Wqo4evRBtZZ0Ood0RWJwN2DZButC7O2eWWjPptmd/ zzd21gLWI8o3GNZEv9ejNg== 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=fm1; t=1740557869; x=1740644269; bh=N fIIfCUe42/NaRSFL8jxlGdhVAzhLpbyzWTssYWTeq8=; b=oRFL/JLdoaPrZyOk7 D6LtslQVm3HCcI4jHcpLQqJn9c8iWPO5uMVumwvOOwi2pBryHTmxZ7sJMQsttR5h nMp9gSSKx9viTGke97DYbOKoRcn2lChWb6gQ3v9iafVyiaeKz5XglvlhX/gefDxy ZBlABkLNJn0ySdAULJUzxjIszKbAKh8zrz11g7HBOM+i2+vQrIO7wYAb/82v39aD Gqz39Z3mLwj0iWJgn7jdhTAPseyk7PEYbFzzLTfdCsPjC1HZLg+1vBpwtG4+3mUq S/5OWNvJ6V8kiUkO6Q8Ww9SKq6BLlR6B3SkdnT6xc7xWIV9drJtse70Fa/tm8CQ3 n3TUg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdekgedtkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepfffhvf fufggjfhfkgggtgfesthhqmhdttderjeenucfhrhhomhepfdftohifrghnucfvohhmmhhi nhhsucglkffoufhorfgnfdcuoehimhhsohhprdhphhhpsehrfigvtgdrtghordhukheqne cuggftrfgrthhtvghrnhepheelffetiefgveduteefudegtdduveeludegueegleehiefh hefgtdekveevgfelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepihhmshhophdrphhhphesrhifvggtrdgtohdruhhkpdhnsggprhgtphhtthho pedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhssehlih hsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 26 Feb 2025 03:17:48 -0500 (EST) Date: Wed, 26 Feb 2025 08:17:46 +0000 To: internals@lists.php.net Subject: =?US-ASCII?Q?Re=3A_=5BPHP-DEV=5D_Consensus_gathering=3A_allo?= =?US-ASCII?Q?wing_unsetting_of_backed_property_hooks?= User-Agent: K-9 Mail for Android In-Reply-To: References: <0b408765-04c4-49ed-bd5a-bceb34a2a3f1@app.fastmail.com> Message-ID: <1EBBCAA7-AC32-4C2F-8EB3-B1A69E1D1783@rwec.co.uk> Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On 25 February 2025 23:31:25 GMT, tight=2Efork3192@fastmail=2Ecom wrote: >On 2/25/25 4:51 PM, Rowan Tommins [IMSoP] wrote: >> I actually started writing an RFC to rationalise some of this behaviour > >I'm glad I'm not the only one who considers this an issue worth pursuing! Sorry, I wasn't clear: I was looking at the existing typed vs untyped, unr= efined vs uninitialised mess, before property hooks even existed=2E > >> Here are some of the things that might happen as a result of unset($foo= ->bar): > >I don't disagree that there's a lot of weirdness=2E But for better or wor= se that's where PHP is now - it's a fundamentally weird language=2E I think= it's better to be consistently weird than to be inconsistently weird=2E My point is that it's *already* inconsistently weird=2E > It would be inconsistent to allow unsetting some types of properties but= not others, and which ones can and can't be unset are indistinguishable to= a 3rd-party consumer=2E unset() can already have a bunch of different effects depending on the imp= lementation of the class=2E As well as __unset being able to do *absolutely= anything*, I missed from my list "readonly" properties, which reasonably e= nough *always throw an error for unset*, just like hooked properties=2E >I can't comment from an implementation perspective, but as a user of PHP = I would expect unsetting a backed property to return the property the "unin= itialized" state, and subsequent access would proceed as if it were the fir= st access of the uninitialized property=2E An untyped property is currently never in the "uninitialised" state, only = a different "undefined" state=2E Presumably this inconsistency would need t= o be preserved (for consistency) >Unsetting a virtual property could simply do nothing, but not result in a= fatal error=2E I don't think a warning is even necessary because no action= is taken=2E I don't see how that would be useful=2E The user presumably expected it to= do *something*, so informing them that it didn't seems preferable to silen= tly ignoring their request=2E It would also be inconsistent: a virtual prop= erty with no "set" hook throws an error when you try to set it, it doesn't = silently discard the value=2E > I certainly don't want to be required to define an unset hook for every = single backed property; rather `unset()` should have a default behavior=2E I think you're focusing too closely on one use case, rather than all the w= ays people will want to use hooked properties=2E Imagine you have two prope= rties which you want to keep in sync: setting either of them recalculates t= he other, using set hooks=2E * It would be really surprising to the class author if a user of the class= could "reach in" and invalidate the state by calling unset() on one of the= properties=2E * It would be really surprising to the user if doing so worked on one of t= he properties, but silently did nothing on the other because it was impleme= nted as virtual=2E * It might be appropriate for the class author to add "unset" hooks to bot= h properties, and for the user to see that unsetting one unset the other, j= ust as setting one sets the other=2E That's just one scenario, I'm sure there are others where you could pictur= e different expectations, particularly accounting for some of the other beh= aviour of unset()=2E That's what I mean by it being hard to specify the beh= aviour; nothing to do with the implementation=2E Regards, Rowan Tommins [IMSoP]