Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127979 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 54D651A00BC for ; Wed, 9 Jul 2025 17:11:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1752081002; bh=5khrgN7egQPvMjGbX0nDUzqqtkwEbdIKvY52NZYORUs=; h=Date:From:To:In-Reply-To:References:Subject:From; b=WO+iIxjn2/7JIIu3NXXYkL2Yedqq5sbK6Sc2/PHhWW9l4qJJ5sR2uHngrYZhKKM/P MY1ne48hEqlbTEMUmtndYJDRz5yW1/rn66xT/5tMvf/ff4vfKg8thChqcGM6j4BbFr tz/Q4qxnYr9ypBdfYx4acDash1QzbzzrgbTFJNn+gMjj0ZAxm8nbuQzrW/G0wU+nNB Ji4Xnl6G5jBbLLFj+BP9iidF50VX9tbOyKfD/OqdlimxQd9PB/koumjQ7SwQ+iBrXl 2bfJDkodWerqvoan0MNPci7lQZpRe+cRnSOwlS8Z5u+IWnHMbs6rcMRZxnBOSGYlay pwnI85qtD8oEQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0EE82180068 for ; Wed, 9 Jul 2025 17:10:02 +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 fout-b6-smtp.messagingengine.com (fout-b6-smtp.messagingengine.com [202.12.124.149]) (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, 9 Jul 2025 17:10:01 +0000 (UTC) Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfout.stl.internal (Postfix) with ESMTP id 5154E1D000FE for ; Wed, 9 Jul 2025 13:11:50 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-10.internal (MEProxy); Wed, 09 Jul 2025 13:11:50 -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=1752081110; x=1752167510; bh=gnOp6Ljv53EZ1MgQmEnGd t0PmlMxm9jPZCcyteJ1Fn8=; b=UF/2tjj0VI+zns4nO0a5Q9748e63uxPx8jhE1 XOzwbpJ0oF+BGxDQFNCA8uwbXi7l2eeWjzyNER0s+bYyQmrvKmUB5lV5eNJG+gI0 sX+uLIn7PbKuipE6ajOlcDs1ZZIDZoBpTrIhZ8TRylr8q+mK7MYW3W5QFuqpHAhz 5PSeBxW3DSSYM+xciRX7E5EqSRhoini81B5m0SeEz2ZBhgsaOBNGkx9EVDejmZXG sFUT4fvRGO8CYkWMMKU2yzTZzdQHHCPoh1UtSf7A8PMxwDznOmsb350PBlB0RVGU iLAaLilu+wvK0hzShTV1GIUfsvfRQ1czIh+OZNev3LNWcWY0Q== 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=1752081110; x=1752167510; bh=g nOp6Ljv53EZ1MgQmEnGdt0PmlMxm9jPZCcyteJ1Fn8=; b=RKfiysdw0j5MnzLNQ Yy+7pW9Q2NZzu9MgHjmtMi9RtxOg695ihWoTAycT5Q/spa9yCyosAaDlf/1WxraE shI9EOj9yjpWrxOSyjeRhER7gqTtqETBPOmYgHClLZDOpYxNNkFanGH+68eVo7c/ GucBnM4RoANotsu6PmNjrM6FPURXvc+rBvEcBGtjhJDfLcBiPK2MZzV20LAe/KK0 OC4Yu8JL4aleIKeIuZ0plAFcOrFcmC4qtNqJH/B4rtULxfNix7kYX5WcCiH29KLA jmzPu907XlZuvQHSaG62yT/gMnjzDktq//5ixcCGaLTR79iX56CuvjccluUM8CJl X95qA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdefkedufecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefoggffhffvkfgjfhfutgfgsehtjeertdertddtnecuhfhrohhmpedfnfgrrhhrhicu ifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomheqne cuggftrfgrthhtvghrnhepudegvdelgfeugeehfeejteffudevleethfefgeejffffleeg tddtveekgeekudfgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmpdhnsggprhgtphht thhopedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhsse hlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id C4265700069; Wed, 9 Jul 2025 13:11:49 -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: Taa1a9d92243b6726 Date: Wed, 09 Jul 2025 12:11:29 -0500 To: "php internals" Message-ID: <922a21f4-c28c-4824-b1d6-0c53ae080ffb@app.fastmail.com> In-Reply-To: References: <1e8634d7-ac1a-4025-b4e2-1948aabf5251@app.fastmail.com> <46857A6D-5EAF-44AF-A2DE-9B40AF8DE8C8@gmail.com> <41241c3d-a601-4fb8-9f32-976bea3b660e@app.fastmail.com> Subject: Re: [PHP-DEV] [RFC] Readonly property hooks Content-Type: text/plain Content-Transfer-Encoding: 7bit From: larry@garfieldtech.com ("Larry Garfield") On Wed, Jul 9, 2025, at 10:42 AM, Eric Norris wrote: >> An init hook would be clearer, certainly, though it also has its own edge cases. Can you set something that has an init hook? What happens if there's both a get and init hook? These probably have answers that could be sorted out, but that's a different question from "why the does a readonly class forbid me using even rudimentary hooks???" >> >> I'd be open to a follow up RFC for an init hook, though I likely wouldn't write it myself. But that's a different topic than what we're addressing here. >> >> --Larry Garfield > > I'm not entirely sure I follow - it sounds like your email states that > `readonly` should be interpreted as `writeonce`, which makes sense, > but then why would an `init` hook not be the appropriate answer here? > > The two scenarios you listed (`set` hooks for validation and lazy > computed properties) seem like they could be solved by allowing `set` > hooks (everyone seems +1 to that), an `init` hook, and disallowing > `get` hooks. It would sidestep the controversial nature of a `get` > hook for the property. > > It feels to me like an init hook would be the more conservative > approach, and would (I imagine) still allow for potential `readonly` > engine optimizations like Tim pointed out. Once we allow `get` hooks, > there's no going back. If we still needed to add `get` hooks in the > future, it's not off the table. > > I don't know that I feel strongly here, but there does seem something > intuitively off with allowing a get hook for a readonly (writeonce) > property. Can an init hook reference itself, the way get and set can? If there is both an init and set hook, what happens? Is it different if set reads from itself than if it writes to itself? Should combining init and set be forbidden as confusing? Can you have both an init hook and a get hook? What happens then? Repeat all of the above on readonly properties. I don't know the answer to any of those. We could probably collectively figure out some answers to that in time, but that's a much larger lift than either Nick or I have any interest in engaging in at this point, especially when there is a reasonable solution right in front of us that is trivial to implement. --Larry Garfield