Bug #72240 [Opn->Dup]: self in anonymous function indicates inherited class

From: Date: Thu, 19 May 2016 03:07:15 +0000
Subject: Bug #72240 [Opn->Dup]: self in anonymous function indicates inherited class
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201189@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72240&edit=1

 ID:                 72240
 Updated by:         requinix@php.net
 Reported by:        dqneoo at gmail dot com
 Summary:            self in anonymous function indicates inherited class
-Status:             Open
+Status:             Duplicate
 Type:               Bug
 Package:            *General Issues
 PHP Version:        5.6.21
 Block user comment: N
 Private report:     N

 New Comment:

Duplicate of bug #69568 which apparently says this could only be fixed for PHP 7.


Previous Comments:
------------------------------------------------------------------------
[2016-05-19 02:52:38] 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


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=72240&edit=1


Thread (2 messages)

« previous php.bugs (#201189) next »