Re: Re: 8.1 / Exception / Property Type / Backwards compatbility
| From: | Nikita Popov | Date: | Fri, 27 Aug 2021 15:40:41 +0000 |
| Subject: | Re: Re: 8.1 / Exception / Property Type / Backwards compatbility | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-115880@lists.php.net to get a copy of this message | ||
On Fri, Aug 27, 2021 at 5:35 PM Ben Ramsey <ramsey@php.net> wrote:
> Nikita Popov wrote on 8/26/21 14:57:
> > On Thu, Aug 26, 2021 at 8:34 PM Ben Ramsey <ramsey@php.net> wrote:
> >
> >> Nikita Popov wrote on 8/26/21 09:57:
> >>> Right. I at least do not plan to address this issue. If you take a
> >>> protected property and publicly re-export it, then any compatibility
> >> issues
> >>> are on you.
> >>
> >> This does not appear to affect only cases where one is re-exporting a
> >> protected property as public.
> >>
> >> Exception protected properties without type hints:
> >>
> >> * PHP <= 8.0 - https://3v4l.org/GWmrk
> >> * PHP 8.1 - https://3v4l.org/GWmrk/rfc
> >>
> >>
> >> Exception protected properties with type hints:
> >>
> >> * PHP <= 8.0 - https://3v4l.org/UX1Pa
> >> * PHP 8.1 - https://3v4l.org/UX1Pa/rfc
> >>
> >
> > These are not really meaningful examples, because you could simply not
> > redeclare the property at all and assign it in the constructor instead
> (or
> > preferably, let the parent constructor assign it). That's the normal way
> to
> > extend exceptions. What made the original case interesting is that the
> > property redeclaration isn't immediately redundant there, because it
> > changes visibility.
>
> If we don't want downstream users to redeclare the properties, why are
> they protected?
>
To allow downstreams users to write $this->line = 123.
Regards,
Nikita