Le 23/10/2023 à 17:16, Larry Garfield a écrit :
Where this becomes a problem is readonly properties, since those are not 
allowed to have default values.  (That would make them constants with worse 
performance.)  A solution would need to be able to detect that the 
parent::__construct() isn't called, and then call it anyway, or at least 
partially call it.  Unfortunately, I can think of many cases where such a call 
would result in unexpected behavior.

It might be possible to resolve, but it's definitely not simple, and it could 
easily lead to weird behavior.

--Larry Garfield

Thanks for the explanation !

I see, there is no easy answer, yet current state is, in my opinion, unintuitive for developers, and eventually unsatisfying when falling in this trap.

That's sad that readonly properties make this not trivial. Maybe some kind of object construct-post-hook could detect those case and affect variables with default values ? I don't know enough PHP internals to give a rational answer to this problem through...

Regards,

--

Pierre

Reply via email to