Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127989 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 B78741A00BC for ; Thu, 10 Jul 2025 10:43:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1752144117; bh=4Kjg+5bKKfQ5m7kS6UlzGPpJ3TVYzth3JzzT6mEtRNA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=A7QYQlkSiWYsWKmV+vRc2r4WJKrgIR0aD9yeVy1gYCPQIkriEyVfvCoQUYmwdOlpJ /fwnmRx1pAaF5N/ZUewGwPQQ+m1+AkJl7i3LF9LuQR42EbzJaHXyUmkvTKyc037wzQ tNYt+TsoN1i+nCaMBaOgYEryh/ZRp6dmd2ZHcwtniubw5tXFLCUlqcnO+k3XGY6YZk fT3l0EY+4RsU+t5XTRnVn8nJ+lHYxkyN9jGQDoQSeGbL7rYjSkkiXPjRpogUDkE49C ep1b+0/5WC7yZbG9Bos0nrQt2JtHnLT+39hqLiuxCe58I6b+nroT0LdRzUFV6CxM7i HWcr2sxTLnqEg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 32286180053 for ; Thu, 10 Jul 2025 10:41:57 +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 ; Thu, 10 Jul 2025 10:41:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1752144225; bh=zZJWO9euNQibubfle0o++RoPbXsjSglP4+Fuiygv9uw=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=Ntyc8211/yXd+lQb+j8EuRuatY48tV29CsunB3WbhrewV8aYr2XS26ArrmWXCbYpu 0YaPzj1x0CNU/67aL6BE/wO5IXvKdo/x2RPq2zR0bPV5Y8AxYWl0PptWtwjvT5y1zQ CZ1Qa0/dSpHLsa3qFRMwwlSyzc8Jvy4pEs1mfhY2BdndCgK2M2hWwD5na64QBdC9ti qI6Q8nj23uJcQS47Vw2n1l7L3vRL5mRGxU6GXC1lp3bEnIc+EPU2gc9ZZIBWNviMXf ZI9GDWqWE75ggahPbgcpdaC9Yb+DFEmw5xQQWNp8tek79N1VIIXP6+rO4OgQi2NEW4 uPUhiQKWZhlyw== Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Thu, 10 Jul 2025 12:43:45 +0200 To: Nicolas Grekas Cc: Larry Garfield , php internals Subject: Re: [PHP-DEV] [RFC] Readonly property hooks In-Reply-To: References: <1e8634d7-ac1a-4025-b4e2-1948aabf5251@app.fastmail.com> Message-ID: <6acab95a554fe5e188364840ea36d2b7@bastelstu.be> 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 Am 2025-07-08 17:32, schrieb Nicolas Grekas: > I also read Tim's argument that new features could be stricter. If one > wants to be stricter and forbid extra behaviors that could be added by > either the proposed hooks or __get, then the answer is : make the class > final. This is the only real way to enforce readonly-ness in PHP. Making the class final still would not allow to optimize based on the fact that the identity of a value stored in a readonly property will not change after successfully reading from the property once. Whether or not a property hooked must be considered an implementation detail, since a main point of the property hooks RFC was that hooks can be added and removed without breaking compatibility for the user of the API. > engine-assisted strictness in this case. You cannot write such code in > a > non-readonly way by mistake, so it has to be by intent. That is saying "it's impossible to introduce bugs". > PS: as I keep repeating, readonly doesn't immutable at all. I know this > is > written as such in the original RFC, but the concrete definition and > implementation of readonly isn't: you can set mutable objects to > readonly > properties, and that means even readonly classes/properties are > mutable, in > the generic case. `readonly` guarantees the immutability of identity. While you can certainly mutate mutable objects, the identity of the stored object doesn't change. Best regards Tim Düsterhus