Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128003 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 7170B1A00BC for ; Fri, 11 Jul 2025 04:44:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1752208975; bh=agbaMCb3TZgc26F4iMiwMk592qE4BTsNcgBlkw+Xvhk=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=S67d0IYFCrU8OQtVLCrrfBUEmyPHVcqP0OEQSNm+sxosP/jyqPoKotMPa2xy7C7Qw icrkq6WBbpcVb8dAubokyo40vRozp9O0XLs3362mipSRytoN9EajPDMAY82UdnOpc7 ANKKbo2K5Pv2xQKDthZDLrhiyqhMzSHzlFMhcES1YPBKu2XPMidG3JX1o7vQGZdxCe FOvexW26NbgZUXnOO6FQakHJ48BD94liX+83Zpk9VfT8bNsjggQiWJIF7myBkTydN5 ZPHipHou//L3BbFKtBVwoVuR/46IP7YQ6dZH2xDBLzWtiYrJaxMfHhS2gKfUpaN+Fm j0UHLB70+mhmQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 451151807C4 for ; Fri, 11 Jul 2025 04:42:54 +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=-0.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,HTML_MESSAGE, 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 avril.gn2.hosting (avril.gn2.hosting [84.19.162.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 11 Jul 2025 04:42:53 +0000 (UTC) Received: from avril.gn2.hosting (localhost [127.0.0.1]) by avril.gn2.hosting (Postfix) with ESMTP id 9AD2B1C4082C; Fri, 11 Jul 2025 06:44:41 +0200 (CEST) Received: from smtpclient.apple (unknown [111.68.29.103]) by avril.gn2.hosting (Postfix) with ESMTPSA id BCC061C40816; Fri, 11 Jul 2025 06:44:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nicksdot.dev; s=default; t=1752209077; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=AP1TScMKQR1mqlVuilQQYcdRF9WLjnaOTmrXlUnEd10=; b=URdyhipJmTsANdCgf4OJ1e6sZ95V55GEFKaCZ15rkpwEPV910zKVKmJDgtKClT+YKTA41P tSBkTNVgQ2FvedsKJR2TPbkgHQLIBt9H+JjFDUq2a4iYjWZRvZWvd+iPbVlQ0qFDtQHWCZ 0gY8OiM4uPoU9LiSgHJOvDSvru9KEO5SnWhtURUc6q7lpjkHL144xdrqdHzGSpyk0h1YQ2 Rl+HaOtW0R8gjAkZz5UfFPlWRMinxISJdPB8BtQiJgB+SlxBItzbF+MGsijuinX9r3GKZ4 b+McYVSimJ4Wz0bYNoT6MHIJyzYAinMbp2iwkWeQLYzx2hNZEvFYBodjTbO7ow== Message-ID: <1363C627-2ACA-4567-83CF-CCB4ACD393AF@nicksdot.dev> Content-Type: multipart/alternative; boundary="Apple-Mail=_8D02A911-4FEF-4CE4-BDED-98EF4DE6490E" Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.600.51.1.1\)) Subject: Re: [PHP-DEV] [RFC] Readonly property hooks Date: Fri, 11 Jul 2025 11:44:15 +0700 In-Reply-To: Cc: Larry Garfield , php internals To: erictnorris@gmail.com References: <1e8634d7-ac1a-4025-b4e2-1948aabf5251@app.fastmail.com> <46857A6D-5EAF-44AF-A2DE-9B40AF8DE8C8@gmail.com> <41241c3d-a601-4fb8-9f32-976bea3b660e@app.fastmail.com> <922a21f4-c28c-4824-b1d6-0c53ae080ffb@app.fastmail.com> X-Mailer: Apple Mail (2.3826.600.51.1.1) From: php@nicksdot.dev (Nick) --Apple-Mail=_8D02A911-4FEF-4CE4-BDED-98EF4DE6490E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hey Eric, > On 11. Jul 2025, at 10:08, Eric Norris = wrote: >=20 > Regarding the caching option suggested elsewhere, the semantics > mentioned seem confusing to me. The body is called on subsequent gets, > but only the value from the first get is returned? I would expect that > would be very confusing to developers. If the body wasn't executed on > subsequent invocations that might make more sense to me, but then the > get hook essentially is an init hook, and why not call it as such. I just before pushed a third implementation idea which addresses this. It also no longer requires a separate cache. It uses the store itself. A link to the branch is in the description of the original PR. > Also, just to throw the idea out there - maybe start with init hooks > *only* for readonly properties? Is there something to this, especially > if you consider "readonly" actually "writeonce"? Maybe this plus > disallowing set hooks? Personally, I don=E2=80=99t see added value in adding yet another hook = `init`. I also don=E2=80=99t see how this would solve the `get` hook issue? As a user I want to be able to have a `get` hook in readonly classes. = For instance, for formatting. In my last answer to Tim I showed an example of what I would expect from = `readonly` properties. Cheers, Nick= --Apple-Mail=_8D02A911-4FEF-4CE4-BDED-98EF4DE6490E Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Hey Eric,

On 11. Jul 2025, at 10:08, Eric Norris = <eric.t.norris@gmail.com> wrote:

Regarding the = caching option suggested elsewhere, the semantics
mentioned seem = confusing to me. The body is called on subsequent gets,
but only the = value from the first get is returned? I would expect that
would be = very confusing to developers. If the body wasn't executed = on
subsequent invocations that might make more sense to me, but then = the
get hook essentially is an init hook, and why not call it as = such.

I just before pushed a third = implementation idea which addresses this.
It also no longer = requires a separate cache. It uses the store itself.
A link to = the branch is in the description of the original = PR.

Also, just to throw the idea out = there - maybe start with init hooks
*only* for readonly properties? = Is there something to this, especially
if you consider "readonly" = actually "writeonce"? Maybe this plus
disallowing set = hooks?

Personally, I don=E2=80=99t see added value in adding yet another hook = `init`.
I also don=E2=80=99t see how this would solve the = `get` hook issue?
As a user I want to be able to have a `get` = hook in readonly classes. For instance, for formatting.
In my = last answer to Tim I showed an example of what I would expect from = `readonly` = properties.

Cheers,
Nick
= --Apple-Mail=_8D02A911-4FEF-4CE4-BDED-98EF4DE6490E--