Bug #79419 [Opn->Dup]: self:: does not refer to the same class name

From: Date: Fri, 27 Mar 2020 09:16:44 +0000
Subject: Bug #79419 [Opn->Dup]: self:: does not refer to the same class name
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226280@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79419&edit=1

 ID:                 79419
 Updated by:         nikic@php.net
 Reported by:        michael dot vorisek at email dot cz
 Summary:            self:: does not refer to the same class name
-Status:             Open
+Status:             Duplicate
 Type:               Bug
 Package:            Scripting Engine problem
 PHP Version:        7.4.4
 Block user comment: N
 Private report:     N

 New Comment:

Duplicate of bug #77985, see also https://wiki.php.net/rfc/lsb_parentself_forwarding.


Previous Comments:
------------------------------------------------------------------------
[2020-03-27 08:42:21] michael dot vorisek at email dot cz

Description:
------------
Please verify or provide an the intuition behind this behaviour.

This issue is critical as CS fixers are very common these days and one of the standard rule is
replace current class name with self if the name is used inside the current class definition.

Test script:
---------------
class TestParent
{
    public static function  className() {
        return static::class;
    }
    
    public static function  classNameSelf() {
        return self::className();
    }
    
    public static function  classNameExplicit() {
        return TestParent::className();
    }
}

class TestChild extends TestParent {}

print(TestChild::classNameSelf());
print("\n");
print(TestChild::classNameExplicit());

Expected result:
----------------
TestParent
TestParent

Actual result:
--------------
TestChild
TestParent


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



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


Thread (3 messages)

« previous php.bugs (#226280) next »