php.net |  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
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:
MUST BE VALID
Solve the problem:
24 + 11 = ?
Subscribe to this entry?

 
 [2016-05-19 02:52 UTC] dqneoo at gmail dot com
Description:
------------
"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:
----------------
A

Actual result:
--------------
B

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-05-19 03:07 UTC] requinix@php.net
-Status: Open +Status: Duplicate
 [2016-05-19 03:07 UTC] requinix@php.net
Duplicate of bug #69568 which apparently says this could only be fixed for PHP 7.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Sep 17 17:01:28 2019 UTC