Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126509 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 BAEEE1A00BC for ; Wed, 26 Feb 2025 05:45:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1740548598; bh=lqjNnZxvJsbsmxPHiCLotAjSrCHg38h3FN5EVpcCkDo=; h=Date:From:To:In-Reply-To:References:Subject:From; b=Zi9hObHKW/W0S9seRfyQTCTxZueSvmiEIV5lmhra7zuP8qt7Bvx9WJUbYx29nYJhe OoB2fCeMmzWe4x0ktL2CRVs+mmHzs5KUjdXcbZnXEwN/qtD0N63fBatsrSuE9w5wrr 1a2Krcb5MnuXXVy/YcjTxB7QfhNlNixva7eXKO/Oj8fQT6yGJi8gwCEG6la7VUiHQG boH/Rg6TGOeYSknb+DKzDf9qplPi2VaG6BNvx0+eLU39GQ2Fo7/w8JbKAhph9qeXnq 0kIc5NtzBwallIUl1V8wSD68q/2o3xm8z0CStOm0fVZ/jdca8nQuHlNBqqIpkCzAK2 L6mt/hU7GkjWw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 57D5918006C for ; Wed, 26 Feb 2025 05:43:17 +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.9 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout-a5-smtp.messagingengine.com (fout-a5-smtp.messagingengine.com [103.168.172.148]) (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 05:43:16 +0000 (UTC) Received: from phl-compute-07.internal (phl-compute-07.phl.internal [10.202.2.47]) by mailfout.phl.internal (Postfix) with ESMTP id E4C84138098B for ; Wed, 26 Feb 2025 00:45:54 -0500 (EST) Received: from phl-imap-07 ([10.202.2.97]) by phl-compute-07.internal (MEProxy); Wed, 26 Feb 2025 00:45:54 -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=1740548754; x=1740635154; bh=78KtU614RceKYZuGHA2E676GoMlR+FBZ1M4X9e3tH38=; b= Cvm7lV4m3eMdzio3AK1FtZo1L5L4fRz1NOybz1jalTzuRtzZ5LNQfvTlsPHUKq12 xQGwcVWgp81HpRXRbzVmxHFqgF2uTsXze1UJL9KZu4K+olLTBNVj9bhfBqs8IHFn lNsZVOQUwjQnhcN2YDZC38XWzL/sJ7qZ0Ykhag/xXOxBa+xEpvnFeYcYBvQfBZKb 9FGQttH0RgehqkH9NxWRnS3yVawtUOKVKxAxkc5ihZvBD8DzLzpkwBOv/TCDRkQU igiZDQgjBAAMEJTc7B+SA5sBESZJJyhX40uNdE5bHT7YvjLajHn3wu92UAjKM/An qJSSYE4pn7+wPiWoHmyVBQ== 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=1740548754; x=1740635154; bh=7 8KtU614RceKYZuGHA2E676GoMlR+FBZ1M4X9e3tH38=; b=sVlbw0Wk0Br+gbI/S n6sHlsQHv1lRuAkCZ+jdXcSpQZNpLjTOFbT+ylIW5jsPBswlDAUn1K44MBDj9m1l KGUSLjnY0wQQQSuACR6oTH7yRR5T3Sat4jZJsADIblBT0EZl6nPYAhy/3q0+FGuF WaajJxJtLFCbpEmbQHhJslHylZLRSy1JJahaMhvBl/9D0T2gFcBbfr3sKHoyTiW9 DyCu47NED0bl0RbeBrd4xerF4mE2RsU5utf0sJ6BQoYg8zVabJQmSBgAYMUaaETG 9SXFvJ94aQ37xyntxgWtnvsS6U/ztYY7JZVyRr/RYOoHMg1CgEn52Md+Nzp1Omb7 voEPQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdekfeejiecutefuodetggdotefrod 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 9C66ABA006F; Wed, 26 Feb 2025 00:45:54 -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 23:45:32 -0600 To: internals@lists.php.net Message-ID: <5153417c-7feb-4b19-861f-ef94d725e586@app.fastmail.com> In-Reply-To: <62b24fbc-d596-4ade-bf82-4861287ca1ae@app.fastmail.com> References: <0b408765-04c4-49ed-bd5a-bceb34a2a3f1@app.fastmail.com> <62b24fbc-d596-4ade-bf82-4861287ca1ae@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 > Most of the use cases you talk about are easily emulated from within > the class. If you're calling unset($foo->bar) from outside of the > class, I would argue the code is bad and needs to be rethought to begin > with. That may be so - we can judge the code PHP enables all we want, but the fact remains that PHP does allow this kind of thing and it can and will happen in the future. As the language evolves we should not be adding *more* inconsistency - like `unset()` now only working on some things and not others, and which ones work and which ones throw fatal errors being opaque to the consumer. That's leaving a footgun lying around and a violation of encapsulation. > From within the class, the RFC linked to several examples, the first > few of which involved caching of derived properties. > Problem solved. Of course, one can work around almost anything. I'm hoping to envision a solution in which workarounds are not necessary by following established PHP idioms. In the workarounds in the RFC, we either 1) double the number of properties in the class by including separate private cache variables, which is annoying to maintain and extend, and becomes a code convention instead of natural PHP. (Ironically, we `unset()` those private cache variables!!) Or we 2) introduce a more complex situation with private cache arrays and magic constants. If we're talking about bad code, magic constants are certainly up there. IMHO it's much more natural to simply unset the property from inside the class, like PHP has always allowed us to do and is what one of the very workarounds in the RFC does. The fact that the workaround in the RFC does it demonstrates how useful it is!