|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2021-10-03 13:00 UTC] michael dot vorisek at email dot cz
Description: ------------ demo https://3v4l.org/eT0Aj (same as test case below) Test script: --------------- <?php trait ATrait { public function __isset(string $name): bool { return false; } } trait BTrait { public function __isset(string $name): bool { return false; } } class Model { use ATrait { __isset as private __a_isset; } use BTrait { __isset as private __b_isset; } public function __isset(string $name): bool { return false; } } Expected result: ---------------- no fatal error Actual result: -------------- Fatal error: An alias was defined for method __isset(), which exists in both ATrait and BTrait. Use ATrait::__isset or BTrait::__isset to resolve the ambiguity in /in/eT0Aj on line 17 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 18:00:01 2025 UTC |
Trait use blocks are meaningless. use ATrait { __isset as private __a_isset; } use BTrait { __isset as private __b_isset; } is equivalent to use ATrait, BTrait { __isset as private __a_isset; __isset as private __b_isset; } which is more obviously ambiguous. While your code was accepted prior to PHP 8, it did not actually do what you intended (it would create two aliases to ATrait::__isset instead.)