Require non-absolute trait method references to be unambiguous
| From: | Nikita Popov | Date: | Tue, 03 Mar 2020 14:11:27 +0000 |
| Subject: | Require non-absolute trait method references to be unambiguous | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-108823@lists.php.net to get a copy of this message | ||
Hi internals,
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 https://github.com/php/php-src/pull/5232.
Does anyone see an issue with making this change?
Regards,
Nikita