Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126507 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 A401F1A00BC for ; Tue, 25 Feb 2025 23:31:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1740526149; bh=VmGo7M4ABwj+HzC2/WfVwbG0ndTLDlA8AXlbjP3PelQ=; h=Date:From:To:In-Reply-To:References:Subject:From; b=VLPzi8PcZgqb7D9L1vOp0QypH2BVDUqLgMrZQaDIwg0+BEEknRzXMlTLhLPJjP8X1 BAVlNsF2ZD/YtGXKC4izy1MkElwuXO00+oSJWRzATtXGXEQMBjBMQTnrWbqd2phpGW oaB2DpNpMqHKtkpSAJ73XKsEanFDj8jqJNjtH5gCc1vwA6plcK8CaM9MFOk+3dHoHJ CI8IBmCkxNYEgTlL/XLJftdxFZ5mR4uKhXN9XqgWws+39RiTn+N3egK7OM3+YMOZWO g+2WvPpoKOYxtQCPxrTJB9Q5gpcyQgVqUmP0WesLEIvfKQtOT/FD4hfKvXQRbV5Awg w5QP04QMmY3NA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8B177180084 for ; Tue, 25 Feb 2025 23:29:08 +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.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,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-a4-smtp.messagingengine.com (fhigh-a4-smtp.messagingengine.com [103.168.172.155]) (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 ; Tue, 25 Feb 2025 23:29:08 +0000 (UTC) Received: from phl-compute-07.internal (phl-compute-07.phl.internal [10.202.2.47]) by mailfhigh.phl.internal (Postfix) with ESMTP id 29C8D11400DF for ; Tue, 25 Feb 2025 18:31:46 -0500 (EST) Received: from phl-imap-07 ([10.202.2.97]) by phl-compute-07.internal (MEProxy); Tue, 25 Feb 2025 18:31:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.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=fm1; t=1740526306; x=1740612706; bh=3nQsuqaKxdJq8Clmph1zAcIuCBvXBDHBH/chaP66fqM=; b= wkpynrnnM7cfr/NtVFRWKkQCIyyLWYfRtyC4lYjerbhJdbvxe5+9XtUQ0s/1rB7h Zzaf4kSzK1Z2u3HWsaUzK2JzBk6/mlPT19SxRunEHMF6jUXq9QXTYmRNqDyyYZIv c28Fz0HwuOqNZSEkYIXnH1RtDF/+9s3QL3Envh/ojALEFFPVcL+aawTtT3FdxImt XxLpgBxv85LrDYH8wYPswedh3GcEhIwxPGSbI7dKsK3VuXVTQC/lPYVYRT5ftlYa EzOwEVUEC+KbG0fIjQmOurtawfyTWC8SmQqAdtvbiJdy1u4nf6hCPsUY0/wLVtE5 X2nvTeFt6P+6Dnk0Ve/1UA== 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=1740526306; x=1740612706; bh=3 nQsuqaKxdJq8Clmph1zAcIuCBvXBDHBH/chaP66fqM=; b=yoJswuBsg0tyGBjH0 ZZ9yQyAYI08ra5aZ/7Y7WpM1ki9mxFagKEkfwP722v/uC3eLbimgth5OPs+FnozD bOaCoba5X7CBiheswxFQHyP92mZ5FDyOyeO3cQIJa/HAu/TOw9CWmh+fU/zRhpV9 fpJnM+5ZQzdim07QLv+q57lSNv+zO8jE8tbem0fQ7CGXXi6iYXmJNH4vREX+Hndn +nuxQzDxtcHUKE5ssm98WLjhz15q9d/jJXL4fnmDqY5RBgNGBFQO3db9dJwPl47Q owva4ZXMaoyUVfmtY2Ss+jyMkUtHzhCpFE0NCelrq9II+0uknjqeYf5YF7unifX0 eHc2w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdekfedtvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepofggff fhvffkjghfufgtgfesthejredtredttdenucfhrhhomhepthhighhhthdrfhhorhhkfedu ledvsehfrghsthhmrghilhdrtghomhenucggtffrrghtthgvrhhnpeeftdeukeffgefhtd euleetffdtgefhleefgefgjedtvdekleekgfdugfevvefhfeenucevlhhushhtvghrufhi iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehtihhghhhtrdhfohhrkhefudelvd esfhgrshhtmhgrihhlrdgtohhmpdhnsggprhgtphhtthhopedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: i35d941ae:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id E114BBA006F; Tue, 25 Feb 2025 18:31:45 -0500 (EST) 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 Date: Tue, 25 Feb 2025 17:31:25 -0600 To: internals@lists.php.net Message-ID: In-Reply-To: References: <0b408765-04c4-49ed-bd5a-bceb34a2a3f1@app.fastmail.com> Subject: Re: [PHP-DEV] Consensus gathering: allowing unsetting of backed property hooks Content-Type: text/plain Content-Transfer-Encoding: 7bit From: tight.fork3192@fastmail.com 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! > 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. But for better or worse that's where PHP is now - it's a fundamentally weird language. I think it's better to be consistently weird than to be inconsistently weird. 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. That's a footgun - the fact that it's caused by an evolution of weirdness is neither here nor there. > If we allow a hooked property to directly "unset" the backing value, what *exactly* will it do? 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 "uninitialized" state, and subsequent access would proceed as if it were the first access of the uninitialized property. Unsetting a virtual property could simply do nothing, but not result in a fatal error. I don't think a warning is even necessary because no action is taken. > If we add an "unset" hook, what's the default behaviour if one isn't defined? Adding an unset hook could be out of scope of this proposal, but if there's sentiment that one should be added, not defining one would result in the behavior described above. 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. > I think it's one of those features that sounds simple when you look at a single use case, but actually specify the behaviour in all cases is going to be a lot of work. Definitely. I do think that hard things are worth pursuing in the interest of consistency and functionality. But then again I'm not the one implementing it!