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
Le mardi 3 mars 2020, 15:11:27 CET Nikita Popov a écrit :
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.
Is that valid in PHP-7 as well?
--
Côme Chilliet
FusionDirectory - https://www.fusiondirectory.org
On Tue, Mar 3, 2020 at 4:06 PM Côme Chilliet <
come.chilliet@fusiondirectory.org> wrote:
Le mardi 3 mars 2020, 15:11:27 CET Nikita Popov a écrit :
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.
Is that valid in PHP-7 as well?
Yes, this is valid in PHP 7.
Nikita
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 %sAs 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?
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!