Re: Require non-absolute trait method references to be unambiguous
| From: | Bishop Bettini | Date: | Tue, 03 Mar 2020 15:57:27 +0000 |
| Subject: | Re: Require non-absolute trait method references to be unambiguous | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-108831@lists.php.net to get a copy of this message | ||
On Tue, Mar 3, 2020 at 9:11 AM Nikita Popov <nikita.ppv@gmail.com> wrote:
> Currently, when writing something like
>
> use T1, T2 {
> func as renamedFunc;
> }
>
> where both T1::func() and T2::func() exist, we silently allow this and just
> assume that it is referring to T1::func(). See
> https://3v4l.org/6h3PM for
> a
> more complete example.
>
> I would like to make this an error in PHP 8:
>
> > Fatal error: An alias was defined for method func(), which exists in both
> T1 and T2. Use T1::func or T2::func to resolve the ambiguity in %s
>
> As the error message indicates, the ambiguity is resolved by writing
>
> use T1, T2 {
> T1::func as renamedFunc;
> // or
> T2::func as renamedFunc;
> }
>
> depending on which of those you actually meant.
>
> This is implemented in BN
> LSk†—»gÉ@Ôç�https://github.com/php/php-src/pull/5232.
>
> Does anyone see an issue with making this change?
>
None.
The break here doesn't seem to be wide spread, the error is clear to me,
and it has an easy remedy that may be made in PHP 7 installs today.
Thanks for fixing this!