Re: [PHP-DEV] Protected inheritance hierarchies

2025-08-03 Thread Rob Landers
I originally wrote a long af reply ... but now I agree that this is a bug as well after writing it out ... I’ll be referring to the following code: class A { protected int $v = 1; } class B extends A {} class C extends A { protected int $v = 2; } class D extends A { protected int $v = 3

Re: [PHP-DEV] Protected inheritance hierarchies

2025-08-03 Thread Jonathan Vollebregt
On 8/3/25 11:30 AM, Rob Landers wrote: I'm not sure that this is a bug. You can redeclare the same type and add hooks (or change them), which breaks all assumptions about substitutability. No it doesn't, read the "Property type variance" section on the property hooks RFC: Normal properties

Re: [PHP-DEV] Protected inheritance hierarchies

2025-08-03 Thread Rowan Tommins [IMSoP]
On 3 August 2025 10:30:13 BST, Rob Landers wrote: >I'm not sure that this is a bug. You can redeclare the same type and add hooks >(or change them), which breaks all assumptions about substitutability. If substitutability was the problem, access to the re-declared property should be forbidden t

Re: [PHP-DEV] Protected inheritance hierarchies

2025-08-03 Thread Rob Landers
On Sun, Aug 3, 2025, at 11:10, Rowan Tommins [IMSoP] wrote: > On 2 August 2025 21:59:20 BST, Rob Landers wrote: > >If this were the case, then creating a base class with default values > >wouldn’t be possible. The memory exists and is set aside for that. > > Sure it would: the default value is j

Re: [PHP-DEV] Protected inheritance hierarchies

2025-08-03 Thread Rowan Tommins [IMSoP]
On 2 August 2025 21:59:20 BST, Rob Landers wrote: >If this were the case, then creating a base class with default values wouldn’t >be possible. The memory exists and is set aside for that. Sure it would: the default value is just an assignment that happens at a particular point of the object's