Bug #75689 [Opn]: Wrong function pointer when using functions from trait
| From: | andrey at phpteam dot pro | Date: | Thu, 14 Dec 2017 18:15:49 +0000 |
| Subject: | Bug #75689 [Opn]: Wrong function pointer when using functions from trait | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-213105@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75689&edit=1
ID: 75689
User updated by: andrey at phpteam dot pro
Reported by: andrey at phpteam dot pro
Summary: Wrong function pointer when using functions from
trait
Status: Open
Type: Bug
Package: Class/Object related
Operating System: MacOs
PHP Version: 7.2.0
Block user comment: N
Private report: N
New Comment:
Or I would it expect to complain that 2nd invoke wasn't imported because of name collision. But
that not what you prefer when you giving detail reqirements on under which name function should be
accessible.
Previous Comments:
------------------------------------------------------------------------
[2017-12-14 18:04:48] andrey at phpteam dot pro
Description:
------------
PHP 7.1.11
Using a function from trait ends up with using wrong function.
Test script:
---------------
<?php
trait traitA {
public function __invoke() {
echo "traitA\n";
}
}
trait traitB {
public function __invoke() {
echo "traitB\n";
}
}
class JustAClass
{
use traitA {
__invoke as protected hocus;
}
use traitB {
__invoke as protected pocus;
}
public function __invoke()
{
$this->hocus();
$this->pocus();
}
}
$instance = new JustAClass();
$instance();
Expected result:
----------------
traitA
traitB
Actual result:
--------------
traitA
traitA
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75689&edit=1