Bug #81497 [Com]: Multiple traits can not be aliased since PHP 8.0
| From: | michael dot vorisek at email dot cz | Date: | Sun, 03 Oct 2021 14:15:08 +0000 |
| Subject: | Bug #81497 [Com]: Multiple traits can not be aliased since PHP 8.0 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-237001@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81497&edit=1
ID: 81497
Comment by: michael dot vorisek at email dot cz
Reported by: michael dot vorisek at email dot cz
Summary: Multiple traits can not be aliased since PHP 8.0
Status: Not a bug
Type: Bug
Package: Scripting Engine problem
Operating System: any
PHP Version: 8.0.11
Block user comment: N
Private report: N
New Comment:
> The error message literally tells you what you need to do:
> https://3v4l.org/lEgvo
Thanks a lot!, why a trait name needs to be specified for the alias? I mean what is the logic
behind, which ambiguity it solves?
Previous Comments:
------------------------------------------------------------------------
[2021-10-03 14:10:36] michael dot vorisek at email dot cz
another failing test case https://3v4l.org/cUp5N
------------------------------------------------------------------------
[2021-10-03 14:04:57] nikic@php.net
The error message literally tells you what you need to do: https://3v4l.org/lEgvo
------------------------------------------------------------------------
[2021-10-03 13:17:25] michael dot vorisek at email dot cz
even one intermediate trait with alias is not enough https://3v4l.org/8gZrO
the only supported solution for PHP 8.0 is to alias all traits inside a separate traits https://3v4l.org/hmnWC
all 3 test cases should be supported
------------------------------------------------------------------------
[2021-10-03 13:00:10] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81497&edit=1