Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-22 Thread Rob Landers
On Tue, Jul 22, 2025, at 12:17, Claude Pache wrote: > > >> Le 22 juil. 2025 à 11:25, Rob Landers a écrit : >> >> >>> Should I be able to mark this class as readonly? I would think so. >>> >>> I don’t think so. >>> >>> If you want to *document* the intended invariant, you can put a @r

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-22 Thread Claude Pache
> Le 22 juil. 2025 à 11:25, Rob Landers a écrit : > > >> >>> Should I be able to mark this class as readonly? I would think so. >> >> >> I don’t think so. >> >> If you want to *document* the intended invariant, you can put a @readonly >> tag in a phpdoc comment. >> >> Adding a `readonly`

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-22 Thread Rob Landers
On Tue, Jul 22, 2025, at 11:18, Claude Pache wrote: > > >> Le 22 juil. 2025 à 09:43, Rob Landers a écrit : >> >> You can also implement this today, without using readonly: >> >> class Foo { >> public int $bar { >> get => $this->bar; >> set => empty($this->bar) ? $this->bar = $value :

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-22 Thread Claude Pache
> Le 22 juil. 2025 à 09:43, Rob Landers a écrit : > > You can also implement this today, without using readonly: > > class Foo { > public int $bar { > get => $this->bar; > set => empty($this->bar) ? $this->bar = $value : throw new > LogicException("nope"); > } > } > > https://3v4

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-22 Thread Rob Landers
On Tue, Jul 22, 2025, at 02:10, Eric Norris wrote: > On Sun, Jul 20, 2025 at 4:19 PM Rob Landers wrote: > > > > > > > > On Sun, Jul 20, 2025, at 19:18, Eric Norris wrote: > > > > Hi Rob, > > > > I'm going to respond to a few points from earlier emails here instead > > of each one. > > > > On Sat

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-21 Thread Eric Norris
On Sun, Jul 20, 2025 at 4:19 PM Rob Landers wrote: > > > > On Sun, Jul 20, 2025, at 19:18, Eric Norris wrote: > > Hi Rob, > > I'm going to respond to a few points from earlier emails here instead > of each one. > > On Sat, Jul 19, 2025 at 6:13 AM Rob Landers wrote: > > > > > > > > On Sat, Jul 19,

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-21 Thread Tim Düsterhus
Hi Am 2025-07-21 10:29, schrieb Nick: I saw you voted “no” for `get` (expected, and understandable), and decided to be abstinent to `set`. I double checked the full RFC discussion. You asked four times explicitly, and one time indirectly, to allow `set` but not `get`. Would you mind to elabora

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-21 Thread Niels Dossche
On 21/07/2025 11:11, Nick wrote: > Thanks for the detailed answer--I get it. > I honestly would have appreciated  to see you hop in with that in the earlier > state of the RFC. > It would have been more productive from my point of view. Maybe next time! Hi Nick. Honestly, it would've been extrem

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-21 Thread Nick
Hey Niels, > On 21. Jul 2025, at 15:56, Niels Dossche wrote: > > On 21/07/2025 10:29, Nick wrote: >> @Niels >> I saw you voted “no” for `set`. >> I double checked the full RFC discussion. You didn’t participate at all >> until the very end. >> Both mails were on a meta-level. None one your ma

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-21 Thread Niels Dossche
On 21/07/2025 10:29, Nick wrote: > @Niels > I saw you voted “no” for `set`. > I double checked the full RFC discussion. You didn’t  participate at all > until the very end.  > Both mails were on a meta-level. None one your mails had any arguments which > would justify your vote. > I don’t underst

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-21 Thread Nick
Hey all, >> It's important to plan for the future and come up with a holistic solution. >> I don't want to end up in a situation where in hindsight we shouldn't have >> allowed a "set hook" for example and should've just left readonly alone. > > I honestly cannot come up with a reason for why th

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-20 Thread Rob Landers
On Sun, Jul 20, 2025, at 19:18, Eric Norris wrote: > Hi Rob, > > I'm going to respond to a few points from earlier emails here instead > of each one. > > On Sat, Jul 19, 2025 at 6:13 AM Rob Landers wrote: > > > > > > > > On Sat, Jul 19, 2025, at 12:09, Claude Pache wrote: > > > > > > > > Le 19

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-20 Thread Larry Garfield
On Sun, Jul 20, 2025, at 3:54 AM, Niels Dossche wrote: >> When is a discussion allowed to be considered wound down?  > This has never been defined and always has a subjective part. > In general, no one will block you from bringing it to a vote if no > substantial changes have been made to the RF

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-20 Thread Eric Norris
Hi Rob, I'm going to respond to a few points from earlier emails here instead of each one. On Sat, Jul 19, 2025 at 6:13 AM Rob Landers wrote: > > > > On Sat, Jul 19, 2025, at 12:09, Claude Pache wrote: > > > > Le 19 juil. 2025 à 09:46, Rob Landers a écrit : > > > > On Sat, Jul 19, 2025, at 03:0

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-20 Thread Nick
> On 20. Jul 2025, at 15:54, Niels Dossche wrote: > > On 20/07/2025 02:58, Nick wrote: >> >> Hey Niels, >> > > Hey Nick Hey Nils, >> The whole controversy is about `get`. >> > > That's true. > Note though that the fact that the RFC still includes this does show a > non-consensus from t

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-20 Thread Niels Dossche
On 20/07/2025 02:58, Nick wrote: > > Hey Niels, > Hey Nick > > In before: I personally didn’t have a problem with Tim joining in late.  > > > I, however, want to express that I don’t feel anything productive happens at > this point. > > > My personal impression is, there wasn’t anything n

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-19 Thread Nick
> On 19. Jul 2025, at 22:46, Niels Dossche wrote: > > Op zaterdag 19 juli 2025 schreef Rob Landers : > > On Fri, Jul 18, 2025, at 14:10, Tim Düsterhus wrote: > > > > Hi > > Apologies for the belated reply. I was busy with getting my own > > implementation wrapped up and the thread was so active

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-19 Thread Niels Dossche
Op zaterdag 19 juli 2025 schreef Rob Landers : > On Fri, Jul 18, 2025, at 14:10, Tim Düsterhus wrote: > > Hi > Apologies for the belated reply. I was busy with getting my own > implementation wrapped up and the thread was so active that I had > troubles keeping up. > > Hi Tim, > Thanks for taking t

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-19 Thread Rob Landers
On Sat, Jul 19, 2025, at 12:09, Claude Pache wrote: > > >> Le 19 juil. 2025 à 09:46, Rob Landers a écrit : >> >> >> >> On Sat, Jul 19, 2025, at 03:04, Claude Pache wrote: >>> >>> >>> Le 19 juil. 2025 à 00:41, Rob Landers a écrit : The original author (Nikita) suggested t

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-19 Thread Claude Pache
> Le 19 juil. 2025 à 09:46, Rob Landers a écrit : > > > > On Sat, Jul 19, 2025, at 03:04, Claude Pache wrote: >> >> >> >>> Le 19 juil. 2025 à 00:41, Rob Landers a écrit : >>> >>> The original author (Nikita) suggested that there's nothing in the original >>> design that precludes access

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-18 Thread Tim Düsterhus
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

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-18 Thread Tim Düsterhus
Hi [dropping most of the folks from the Cc list to reduce noise a little] On 7/18/25 19:08, Nick wrote: As mentioned earlier, this is my very first RFC. I am at a point where I am a bit overwhelmed. With an RFC touching core language semantics, you've certainly opted to touch a hot topic. E

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-18 Thread mjec
On Fri, 2025-07-18 at 11:49 -04:00, Rob Landers wrote: > On Fri, Jul 18, 2025, at 17:25, Tim Düsterhus wrote: >> A readonly class is not just a convenience shortcut to mark each >> individual property as readonly. It has important semantics of its own, >> because it forces child classes to also

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-18 Thread Nick
> On 18. Jul 2025, at 23:48, Eric Norris wrote: > > On Fri, Jul 18, 2025 at 12:01 PM Rob Landers > wrote: >> >> >> >> On Fri, Jul 18, 2025, at 17:25, Tim Düsterhus wrote: >> >> Hi >> >> On 7/14/25 15:38, Larry Garfield wrote: >>> Thanks, Ilija. You expressed my c

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-18 Thread Rob Landers
On Fri, Jul 18, 2025, at 18:48, Eric Norris wrote: > On Fri, Jul 18, 2025 at 12:01 PM Rob Landers wrote: > > > > > > > > On Fri, Jul 18, 2025, at 17:25, Tim Düsterhus wrote: > > > > Hi > > > > On 7/14/25 15:38, Larry Garfield wrote: > > > Thanks, Ilija. You expressed my concerns as well. And y

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-18 Thread Eric Norris
On Fri, Jul 18, 2025 at 12:01 PM Rob Landers wrote: > > > > On Fri, Jul 18, 2025, at 17:25, Tim Düsterhus wrote: > > Hi > > On 7/14/25 15:38, Larry Garfield wrote: > > Thanks, Ilija. You expressed my concerns as well. And yes, in practice, > > readonly classes over-reaching is the main use case

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-18 Thread Larry Garfield
On Fri, Jul 18, 2025, at 9:50 AM, Marco Pivetta wrote: > On Fri, 18 Jul 2025 at 16:43, Tim Düsterhus wrote: >> On 7/18/25 16:25, Faizan Akram Dar wrote: >> > The problem with allowing only set hooks is that readonly class won't be >> > compatible with hooks, I think that is one of the main motivat

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-18 Thread Rob Landers
On Fri, Jul 18, 2025, at 17:25, Tim Düsterhus wrote: > Hi > > On 7/14/25 15:38, Larry Garfield wrote: > > Thanks, Ilija. You expressed my concerns as well. And yes, in practice, > > readonly classes over-reaching is the main use case; if you're marking > > individual properties readonly, the

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-18 Thread Tim Düsterhus
Hi On 7/14/25 15:38, Larry Garfield wrote: Thanks, Ilija. You expressed my concerns as well. And yes, in practice, readonly classes over-reaching is the main use case; if you're marking individual properties readonly, then just don't mark the one that has a hook on it (use aviz if needed) a

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-18 Thread Marco Pivetta
On Fri, 18 Jul 2025 at 16:43, Tim Düsterhus wrote: > On 7/18/25 16:25, Faizan Akram Dar wrote: > > The problem with allowing only set hooks is that readonly class won't be > > compatible with hooks, I think that is one of the main motivations behind > > this RFC. > > Yes. The point is that the se

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-18 Thread Tim Düsterhus
Hi On 7/18/25 16:25, Faizan Akram Dar wrote: The problem with allowing only set hooks is that readonly class won't be compatible with hooks, I think that is one of the main motivations behind this RFC. Yes. The point is that the semantics users expect from `readonly` are fundamentally incompa

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-18 Thread Faizan Akram Dar
On Fri, 18 Jul 2025, 15:16 Tim Düsterhus, wrote: > Hi > > On 7/9/25 16:05, Larry Garfield wrote: > > 1. `readonly` bills itself as immutability, but it fundamentally is > not. There are at least two loopholes: __get and a mutable object saved to > a property. So while it offering immutability g

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-18 Thread Tim Düsterhus
Hi On 7/10/25 17:34, Larry Garfield wrote: Nick previously suggested having the get-hook's first return value cached; it would still be subsequently called, so any side effects would still happen (though I don't know why you'd want side effects), but only the first returned value would ever g

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-18 Thread Tim Düsterhus
Hi see also my previous reply to your email where you initially mentioned init hooks. On 7/9/25 19:11, Larry Garfield wrote: Can an init hook reference itself, the way get and set can? If the init hook references its own property you will get endless recursion. If there is both an init an

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-18 Thread Tim Düsterhus
Hi On 7/9/25 16:05, Larry Garfield wrote: 1. `readonly` bills itself as immutability, but it fundamentally is not. There are at least two loopholes: __get and a mutable object saved to a property. So while it offering immutability guarantees is nice in theory, it's simply not true in practi

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-18 Thread Tim Düsterhus
Hi On 7/9/25 19:58, Claude Pache wrote: I hear you, but I still struggle to fully grasp the issue. It’s genuinely hard for me to come up with a real-world example that actually makes sense. Everything I’ve seen so far, including the RFC example and what I tried myself (I gave it an honest shot

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-18 Thread Tim Düsterhus
Hi Apologies for the belated reply. I was busy with getting my own implementation wrapped up and the thread was so active that I had troubles keeping up. On 7/11/25 06:20, Nick wrote: Personally, I would really like to have `get` hooks on readonly properties. Please consider something like

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-17 Thread Rob Landers
On Thu, Jul 17, 2025, at 15:10, Eric Norris wrote: > On Thu, Jul 17, 2025 at 3:31 AM Rob Landers wrote: > > > > On Tue, Jul 15, 2025, at 19:27, Nicolas Grekas wrote: > > > > > > > > Le lun. 14 juil. 2025 à 15:41, Larry Garfield a > > écrit : > > > > On Sun, Jul 13, 2025, at 6:28 PM, Ilija Tovi

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-17 Thread Eric Norris
On Thu, Jul 17, 2025 at 3:31 AM Rob Landers wrote: > > On Tue, Jul 15, 2025, at 19:27, Nicolas Grekas wrote: > > > > Le lun. 14 juil. 2025 à 15:41, Larry Garfield a > écrit : > > On Sun, Jul 13, 2025, at 6:28 PM, Ilija Tovilo wrote: > > Hi Nick > > > > On Fri, Jul 11, 2025 at 6:31 AM Nick wrote

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-17 Thread Rob Landers
On Tue, Jul 15, 2025, at 19:27, Nicolas Grekas wrote: > > > Le lun. 14 juil. 2025 à 15:41, Larry Garfield a > écrit : >> On Sun, Jul 13, 2025, at 6:28 PM, Ilija Tovilo wrote: >> > Hi Nick >> > >> > On Fri, Jul 11, 2025 at 6:31 AM Nick wrote: >> >> >> >>> On 8. Jun 2025, at 11:16, Larry Garfiel

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-15 Thread Nicolas Grekas
Le lun. 14 juil. 2025 à 15:41, Larry Garfield a écrit : > On Sun, Jul 13, 2025, at 6:28 PM, Ilija Tovilo wrote: > > Hi Nick > > > > On Fri, Jul 11, 2025 at 6:31 AM Nick wrote: > >> > >>> On 8. Jun 2025, at 11:16, Larry Garfield > wrote: > >>> > >>> https://wiki.php.net/rfc/readonly_hooks > >>>

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-14 Thread Larry Garfield
On Sun, Jul 13, 2025, at 6:28 PM, Ilija Tovilo wrote: > Hi Nick > > On Fri, Jul 11, 2025 at 6:31 AM Nick wrote: >> >>> On 8. Jun 2025, at 11:16, Larry Garfield wrote: >>> >>> https://wiki.php.net/rfc/readonly_hooks >>> >>> To not get this buried in individual answers to others: >> >> I came up wi

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-13 Thread Ilija Tovilo
Hi Nick On Fri, Jul 11, 2025 at 6:31 AM Nick wrote: > >> On 8. Jun 2025, at 11:16, Larry Garfield wrote: >> >> https://wiki.php.net/rfc/readonly_hooks >> >> To not get this buried in individual answers to others: > > I came up with two alternative implementations which cache the computed `get`

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-13 Thread Eric Norris
> Well, I don’t know. Everyone seems to think of init hooks (and their playing > together with other hooks) differently. > Some say this, some say that. That’s the exact issue. Want an example? > > Eric just agreed with your code example which has a get hook AND init hook. > > ``` > class Test { >

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-13 Thread Nick
> On 14. Jul 2025, at 01:15, Eric Norris wrote: > > On Sun, Jul 13, 2025 at 2:00 PM Marc Bennewitz wrote: >> >> >> On 13.07.25 18:17, Nick wrote: >> >> >> On 13. Jul 2025, at 20:38, Marc Bennewitz wrote: >> >> Hi Nick, Claude, >> >> Hey Marc, >> >> I think it's important to explicitly m

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-13 Thread Eric Norris
On Sun, Jul 13, 2025 at 2:00 PM Marc Bennewitz wrote: > > > On 13.07.25 18:17, Nick wrote: > > > On 13. Jul 2025, at 20:38, Marc Bennewitz wrote: > > Hi Nick, Claude, > > Hey Marc, > > I think it's important to explicitly mark it as "this value will be stored in > memory", I mean just silently c

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-13 Thread Marc Bennewitz
On 13.07.25 18:17, Nick wrote: On 13. Jul 2025, at 20:38, Marc Bennewitz wrote: Hi Nick, Claude, Hey Marc, I think it's important to explicitly mark it as "this value will be stored in memory", I mean just silently caching the get hook could quickly lead to unexpected behavior. Like on

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-13 Thread Nick
> On 13. Jul 2025, at 20:38, Marc Bennewitz wrote: > Hi Nick, Claude, Hey Marc, > I think it's important to explicitly mark it as "this value will be stored in > memory", I mean just silently caching the get hook could quickly lead to > unexpected behavior. Like one would expect the value to be

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-13 Thread Marc Bennewitz
On 11.07.25 11:38, Nick wrote: On 11. Jul 2025, at 14:25, Claude Pache wrote: Le 11 juil. 2025 à 06:30, Nick a écrit : To not get this buried in individual answers to others: I came up with two alternative implementations which cache the computed `get` hook value. One leverages separate

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-11 Thread Claude Pache
> Le 11 juil. 2025 à 11:38, Nick a écrit : > > > I am afraid here I do have a strong opinion. Please remember my very first > mail before discussion [1]. > While for Larry the main reason for `readonly` hooks is lazy-initialisation, > for me it is to write less code, to have less noisy class

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-11 Thread Rob Landers
On Fri, Jul 11, 2025, at 13:40, Nick wrote: > >> On 11. Jul 2025, at 01:43, Rob Landers wrote: >> >> On Thu, Jul 10, 2025, at 17:34, Larry Garfield wrote: >>> On Thu, Jul 10, 2025, at 5:43 AM, Tim Düsterhus wrote: >>> > Hi >>> > >>> > Am 2025-07-08 17:32, schrieb Nicolas Grekas: >>> >> I also

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-11 Thread Nick
> On 11. Jul 2025, at 01:43, Rob Landers wrote: > > On Thu, Jul 10, 2025, at 17:34, Larry Garfield wrote: >> On Thu, Jul 10, 2025, at 5:43 AM, Tim Düsterhus wrote: >> > Hi >> > >> > Am 2025-07-08 17:32, schrieb Nicolas Grekas: >> >> I also read Tim's argument that new features could be stricter.

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-11 Thread Nick
> On 11. Jul 2025, at 13:02, Rob Landers wrote: >> >> Please remember that the RFC will allow `readonly` on backed properties >> only, not on virtual hooked properties. >> Nothing from your example would work, and it would result in: >> Fatal error: Hooked virtual properties cannot be declared

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-11 Thread Nick
> On 11. Jul 2025, at 14:25, Claude Pache wrote: > >> Le 11 juil. 2025 à 06:30, Nick a écrit : >> >> To not get this buried in individual answers to others: >> >> I came up with two alternative implementations which cache the computed >> `get` hook value. >> One leverages separate cache prop

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-11 Thread Claude Pache
> Le 11 juil. 2025 à 06:30, Nick a écrit : > > Hey all, > >> On 8. Jun 2025, at 11:16, Larry Garfield wrote: >> >> As Nick has graciously provided an implementation, we would like to open >> discussion on this very small RFC to allow `readonly` on backed properties >> even if they have a h

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-10 Thread Rob Landers
On Fri, Jul 11, 2025, at 02:40, Nick wrote: > Hey Rob, > >> On 11. Jul 2025, at 01:43, Rob Landers wrote: >>> >>> Nick previously suggested having the get-hook's first return value cached; >>> it would still be subsequently called, so any side effects would still >>> happen (though I don't kno

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-10 Thread Nick
Hey Eric, > On 11. Jul 2025, at 10:08, Eric Norris 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 confusin

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-10 Thread Nick
Hey all, > On 8. Jun 2025, at 11:16, Larry Garfield wrote: > > As Nick has graciously provided an implementation, we would like to open > discussion on this very small RFC to allow `readonly` on backed properties > even if they have a hook defined. > > https://wiki.php.net/rfc/readonly_hooks

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-10 Thread Nick
Hey Tim, > On 10. Jul 2025, at 17:37, Tim Düsterhus wrote: > > Hi > > Am 2025-07-08 17:10, schrieb Larry Garfield: >> The only way to make the readonliness fully guaranteed would be to force a >> readonly property to be cached > > Or by not allowing a `get` hook on readonly properties, of cou

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-10 Thread Eric Norris
On Wed, Jul 9, 2025 at 1:50 PM Larry Garfield wrote: > > 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

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-10 Thread Nick
Hey Rob, > On 11. Jul 2025, at 01:43, Rob Landers wrote: >> >> Nick previously suggested having the get-hook's first return value cached; >> it would still be subsequently called, so any side effects would still >> happen (though I don't know why you'd want side effects), but only the first >

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-10 Thread Rob Landers
On Thu, Jul 10, 2025, at 17:34, Larry Garfield wrote: > On Thu, Jul 10, 2025, at 5:43 AM, Tim Düsterhus wrote: > > 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 behavio

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-10 Thread Larry Garfield
On Thu, Jul 10, 2025, at 5:43 AM, Tim Düsterhus wrote: > 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, the

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-10 Thread Tim Düsterhus
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 t

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-10 Thread Tim Düsterhus
Hi Am 2025-07-08 17:10, schrieb Larry Garfield: The only way to make the readonliness fully guaranteed would be to force a readonly property to be cached Or by not allowing a `get` hook on readonly properties, of course. Best regards Tim Düsterhus

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-09 Thread Claude Pache
> Le 9 juil. 2025 à 15:17, Nick a écrit : > > Hey Claude, > > > I hear you, but I still struggle to fully grasp the issue. It’s genuinely > hard for me to come up with a real-world example that actually makes sense. > Everything I’ve seen so far, including the RFC example and what I tried >

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-09 Thread 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

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-09 Thread Rob Landers
On Wed, Jul 9, 2025, at 13:39, Nicolas Grekas wrote: > Thanks for your detailed thoughts, Claude. I'd like to offer my perspective > on some of the points you raised. > > Le mer. 9 juil. 2025 à 12:53, Claude Pache a écrit : >> >> >>> Le 8 juil. 2025 à 17:32, Nicolas Grekas >>

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-09 Thread Eric Norris
> 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 r

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-09 Thread Larry Garfield
On Wed, Jul 9, 2025, at 5:52 AM, Claude Pache wrote: >> Le 8 juil. 2025 à 17:32, Nicolas Grekas a >> écrit : >> >> I read Claude's concern, and I agree with Larry's response: the engine >> already allows readonly to be bypassed using __get. The added hook doesn't >> make anything more lenient.

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-09 Thread Nick
Hey Claude, >> Le 8 juil. 2025 à 17:32, Nicolas Grekas a >> écrit : >> >> I read Claude's concern, and I agree with Larry's response: the engine >> already allows readonly to be bypassed using __get. The added hook doesn't >> make anything more lenient. >> > > It is true that readonly could

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-09 Thread Nicolas Grekas
Thanks for your detailed thoughts, Claude. I'd like to offer my perspective on some of the points you raised. Le mer. 9 juil. 2025 à 12:53, Claude Pache a écrit : > > > Le 8 juil. 2025 à 17:32, Nicolas Grekas a > écrit : > > I read Claude's concern, and I agree with Larry's response: the engine

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-09 Thread Claude Pache
> Le 8 juil. 2025 à 17:32, Nicolas Grekas a > écrit : > > I read Claude's concern, and I agree with Larry's response: the engine > already allows readonly to be bypassed using __get. The added hook doesn't > make anything more lenient. > It is true that readonly could be bypassed by __get(

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-08 Thread Nicolas Grekas
Hi Tim, Le mar. 1 juil. 2025 à 16:29, Tim Düsterhus a écrit : > Hi > > Am 2025-06-09 17:11, schrieb Larry Garfield: > > I also fleshed out the __get mention with an example that shows what > > you can already do today, and in fact could since 8.1 when readonly was > > introduced. The hard guara

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-08 Thread Nicolas Grekas
Hi Larry et al. Le mar. 8 juil. 2025 à 17:12, Larry Garfield a écrit : > On Tue, Jul 1, 2025, at 9:27 AM, Tim Düsterhus wrote: > > Hi > > > > Am 2025-06-09 17:11, schrieb Larry Garfield: > >> I also fleshed out the __get mention with an example that shows what > >> you can already do today, and

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-08 Thread Larry Garfield
On Tue, Jul 1, 2025, at 9:27 AM, Tim Düsterhus wrote: > Hi > > Am 2025-06-09 17:11, schrieb Larry Garfield: >> I also fleshed out the __get mention with an example that shows what >> you can already do today, and in fact could since 8.1 when readonly was >> introduced. The hard guarantee of idem

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-07-01 Thread Tim Düsterhus
Hi Am 2025-06-09 17:11, schrieb Larry Garfield: I also fleshed out the __get mention with an example that shows what you can already do today, and in fact could since 8.1 when readonly was introduced. The hard guarantee of idempotency has never actually been there. (This also speaks to Claud

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-06-30 Thread Larry Garfield
On Sat, Jun 7, 2025, at 11:16 PM, Larry Garfield wrote: > As Nick has graciously provided an implementation, we would like to > open discussion on this very small RFC to allow `readonly` on backed > properties even if they have a hook defined. > > https://wiki.php.net/rfc/readonly_hooks After so

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-06-09 Thread Larry Garfield
On Sun, Jun 8, 2025, at 7:17 AM, Volker Dusch wrote: > Hey Larry, > > Couple points from a first read and from trying to run the examples. > > a) From the "ProductFromDB" i get: > >> Fatal error: Uncaught TypeError: LazyProduct::$category::get(): Return value >> must be of type Category, none retu

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-06-09 Thread Claude Pache
> Le 8 juin 2025 à 06:16, Larry Garfield a écrit : > > As Nick has graciously provided an implementation, we would like to open > discussion on this very small RFC to allow `readonly` on backed properties > even if they have a hook defined. > > https://wiki.php.net/rfc/readonly_hooks > > --

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-06-08 Thread Nick
Hey Volker, > On 8. Jun 2025, at 19:17, Volker Dusch wrote: > > a) From the "ProductFromDB" i get: > > > Fatal error: Uncaught TypeError: LazyProduct::$category::get(): Return > > value must be of type Category, none returned in ... > > I assume you're missing a return statement here? Or is t

Re: [PHP-DEV] [RFC] Readonly property hooks

2025-06-08 Thread Volker Dusch
Hey Larry, Couple points from a first read and from trying to run the examples. a) From the "ProductFromDB" i get: > Fatal error: Uncaught TypeError: LazyProduct::$category::get(): Return value must be of type Category, none returned in ... I assume you're missing a return statement here? Or is

[PHP-DEV] [RFC] Readonly property hooks

2025-06-07 Thread Larry Garfield
As Nick has graciously provided an implementation, we would like to open discussion on this very small RFC to allow `readonly` on backed properties even if they have a hook defined. https://wiki.php.net/rfc/readonly_hooks -- Larry Garfield la...@garfieldtech.com