Re: Protected inheritance hierarchies
| From: | Hans Krentel | Date: | Fri, 08 Aug 2025 12:15:59 +0000 |
| Subject: | Re: Protected inheritance hierarchies | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-128434@lists.php.net to get a copy of this message | ||
On Friday 08 August 2025 09:13:09 (+02:00), Claude Pache wrote:
>
>
> > Le 7 août 2025 à 20:37, Jonathan Vollebregt <jnv@jnvsor.net> a écrit :
> >
> >
> > Back to the original issue: I'm going to open a github issue on this since it's
> > clearly a bug and I don't see fixing it breaking any existing code.
>
>
> Hi,
>
> Sorry to reply without completely reading this long thread.
>
> As many of us understand it, the application of Liskov Substitution Principle indeed shows
> that, if you can access a member declared in a given class from a given context, you ought also be
> able to access the same member when it is redeclared in a subclass.
That could be, and if it is of interest, from what I remember about Liskov when she was talking
about the LSP, she would not declare that property in the (base) type.
Doing as she would, does not only solve what you describe as the issue at hand, it has also helped
me in the past to benefit from the LSP when scripting with the PHP language.
I'd also like to remind that the expressive capabilities of the language are rather limited for
class invariants and the history rule, adding an escape hatch because users need it can be
absolutely legit, but we should be clear about that this will weaken them further for the
foreseeable time.
-- hakre