Hi,

> If my default assumption (and Larry's) was that such a class would be
immutable, it's fair to think that a non-trivial number of other
programmers may make the same faulty assumption, and making this
distinction obvious in the documentation would probably help.

Yes, it makes sense to mention this in the documentation, but fortunately,
the manual already makes the behavior clear at
https://www.php.net/manual/en/language.oop5.properties.php#language.oop5.properties.readonly-properties
:

"However, readonly properties do not preclude interior mutability. Objects
(or resources) stored in readonly properties may still be modified
internally:"

Following our discussion, Nicolas and I announced our proposal to fix two
of the above mentioned issues: https://externals.io/message/119007 Feedback
is welcome!

Regards:
Máté

Jordan LeDoux <jordan.led...@gmail.com> ezt írta (időpont: 2022. szept.
25., V, 23:01):

>
>
> On Sun, Sep 25, 2022 at 10:57 AM Máté Kocsis <kocsismat...@gmail.com>
> wrote:
>
>> Hi,
>>
>> I agree with Tim, and I also think that both reverting and making any last
>> minute fundamental change is not a good idea, especially
>> because people don't have a clear agreement about how inheritance
>> should work. Readonly classes is an optional feature, so anyone
>> who wants proxies to work can simply not add the readonly flag to their
>> classes. Of course, it's a bit more tricky for library code,
>> but package authors should be aware of this gotcha. Having that said, I'll
>> try my best to fix the current shortcomings for PHP 7.3.
>>
>> Regards,
>> Máté
>>
>
> I tried hard to make it clear that I don't think this makes it "broken",
> it was just a deviation from my expectations and memory, both of which can
> obviously be flawed. I was mostly looking for some kind of information
> about what the reasoning was for this, given that I obviously (since I
> didn't remember it) missed that part of the discussion. The distinction
> between "readonly" and "immutable" is subtle, but fair. This distinction
> should probably be pointed out quite explicitly in the documentation
> though.
>
> If my default assumption (and Larry's) was that such a class would be
> immutable, it's fair to think that a non-trivial number of other
> programmers may make the same faulty assumption, and making this
> distinction obvious in the documentation would probably help.
>
> Jordan
>

Reply via email to