Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128124 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 A68961A00BC for ; Fri, 18 Jul 2025 17:54:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1752861182; bh=fpXJ8q8sIoWmgUlbL09211uKmwNGKmBIx40sBBHVLQg=; h=Date:Subject:To:References:From:In-Reply-To:From; b=jd0PEKPiil+aPg6fCu9QGn0ivbPAgA3eGS+/5RUU9K+LFF9R92YCX0LRv9mOys+CY rQqY5YKuwlDQU4gU+bVSD+duIWw+TsvqDw6i91AghfJmdg3HZE9jfeD67hMjifnBLz 9TyphCg/JMvOV8zfuTbDPg+rDehCWBz05j0akgm8y0ZEuyXQu/NRe9tR44v7Y3frPm +5Lczfy6pT8k6cqse8gu8WNjaVVkMUFFY6Unw+/DalRFnkJa3PsNckZ0ozmjZ/uRwk t2Ij4go6FJfhkpStQurGOPQKbu+Eo1hUcH6LZ3Tac4H5ot2kgVP4N1S5fNT0jXaY3Q 60PuvbQMlUo+w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 153FF180061 for ; Fri, 18 Jul 2025 17:53: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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS 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 chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (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 17:53:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1752861286; bh=0FntgDU/sJIf8AIxX/l0w+NPAM4YdkMaCzHmYQvNKD0=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type:from:to:cc:subject:message-id; b=RbBaDsiwhUU/+LtYQD7G2LXHpN2KBDlJ6MjRE1AlkdOWHjTkGyKFXcSwc7LFD9b4o BsBriLO311PCtjDGaiZtg48W5phBGnbxx97o5F0/KlDBs4FC7JmAIlkJYaPTgGdt6d ClOITntsGJyHjetFWrNhxY1f9rmDTuGbsyYpv2+vh/HfWkRNOIWh3zfz/koDmxVkUX KSLlRkzlDyuKLGWyra9Z505Sl9G5KJodH5EHlMTiRgqL+TWzxOt3E3YNCnt/Ziy+NA PoALWxQYGxLXG1orK2CznOOw8ibOdFSu2wJ0WTqeotnRqbsXrXpDl9wv10+2I/NSCD duNs9jXEnkRqQ== Message-ID: <3c304702-f0a5-4bb6-800e-443029283f58@bastelstu.be> Date: Fri, 18 Jul 2025 19:54:45 +0200 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Subject: Re: [PHP-DEV] [RFC] Readonly property hooks To: Rob Landers , Larry Garfield , php internals References: <1e8634d7-ac1a-4025-b4e2-1948aabf5251@app.fastmail.com> <9D5043B2-1589-4FD5-B289-6E98FB1177BE@nicksdot.dev> <0856c89f-2000-448a-bbbf-c145a8699f6a@app.fastmail.com> <2641b8bc-6337-4b75-a5a3-93dee1b03796@bastelstu.be> <0d9a2968-26dd-43dd-9733-d2eb621ab9ec@app.fastmail.com> Content-Language: en-US In-Reply-To: <0d9a2968-26dd-43dd-9733-d2eb621ab9ec@app.fastmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi On 7/18/25 17:49, Rob Landers wrote: > Wasn’t that the entire point of readonly classes? Because it was painful to write readonly for every property. It was certainly *one point*, but not the *entire* point. Quoting from the RFC (https://wiki.php.net/rfc/readonly_classes): "it's still not easy to declare (quasi-)immutable classes" and then further: "it will prevent the creation of dynamic properties" and "a readonly class can only extend a readonly parent" So the point of the RFC is not "adding readonly for every property is verbose", but "I want to be able to define immutable classes", which, as I outlined before, is something different. > The behavior of the class doesn’t magically change. Or, at least, I hope it doesn’t. The behavior of the class changes, since dynamic properties will now be legal. It also breaks any child classes, since child classes of non-readonly classes may not be readonly (not even if all properties are already readonly). The behavior doesn't change magically, though, it changes due to the intentional removal of the `readonly` keyword on the class. > Unless I missed something. Hooks are fancy methods? There is nothing intrinsic about object properties. There is nothing that says two calls to the same property’s getters are going to result in the same values. There is asynchronous php, declare ticks, etc. especially in the case of globals, there is no guarantee you even have the same object. At the end of the day, it is up to the programmer building that system / program to provide those guarantees— not the language. I agree with both Eric's response to this paragraph. Best regards Tim Düsterhus