Bug #75689 [Opn->Dup]: Wrong function pointer when using functions from trait
| From: | requinix@php.net | Date: | Thu, 14 Dec 2017 21:47:33 +0000 |
| Subject: | Bug #75689 [Opn->Dup]: Wrong function pointer when using functions from trait | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-213111@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
Updated by: requinix@php.net
Reported by: andrey at phpteam dot pro
Summary: Wrong function pointer when using functions from
trait
-Status: Open
+Status: Duplicate
Type: Bug
Package: Class/Object related
Operating System: MacOs
PHP Version: 7.1.11
Block user comment: N
Private report: N
New Comment:
Duplicate of bug #74872
Previous Comments:
------------------------------------------------------------------------
[2017-12-14 18:24:50] andrey at phpteam dot pro
Just edit this to put correct version
------------------------------------------------------------------------
[2017-12-14 18:15:46] andrey at phpteam dot pro
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.
------------------------------------------------------------------------
[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