|  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: andrey at phpteam dot pro
New email:
PHP Version: OS:


 [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 02 17:03:42 2023 UTC