|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72240 self in anonymous function indicates inherited class
Submitted: 2016-05-19 02:52 UTC Modified: 2016-05-19 03:07 UTC
From: dqneoo at gmail dot com Assigned:
Status: Duplicate Package: *General Issues
PHP Version: 5.6.21 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: dqneoo at gmail dot com
New email:
PHP Version: OS:


 [2016-05-19 02:52 UTC] dqneoo at gmail dot com
"self" in anonymous function indicates child class, behaving the same way as "static"

Test script:
class A
    public static function func()
        return function ()  {
            return new self();

class B extends A {}

$b = B::func();
echo get_class($b());

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-05-19 03:07 UTC]
-Status: Open +Status: Duplicate
 [2016-05-19 03:07 UTC]
Duplicate of bug #69568 which apparently says this could only be fixed for PHP 7.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Jun 07 03:01:24 2020 UTC