|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75689 Wrong function pointer when using functions from trait
Submitted: 2017-12-14 18:04 UTC Modified: 2017-12-14 21:47 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: andrey at phpteam dot pro Assigned:
Status: Duplicate Package: Class/Object related
PHP Version: 7.1.11 OS: MacOs
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
49 - 27 = ?
Subscribe to this entry?

 [2017-12-14 18:04 UTC] andrey at phpteam dot pro
PHP 7.1.11
Using a function from trait ends up with using wrong function. 

Test script:

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()


$instance = new JustAClass();

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-12-14 18:15 UTC] 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:24 UTC] andrey at phpteam dot pro
-PHP Version: 7.2.0 +PHP Version: 7.1.11
 [2017-12-14 18:24 UTC] andrey at phpteam dot pro
Just edit this to put correct version
 [2017-12-14 21:47 UTC]
-Status: Open +Status: Duplicate
 [2017-12-14 21:47 UTC]
Duplicate of bug #74872
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Feb 09 07:05:47 2023 UTC