Bug #79419 [NEW]: self:: does not refer to the same class name

From: Date: Fri, 27 Mar 2020 08:42:21 +0000
Subject: Bug #79419 [NEW]: self:: does not refer to the same class name
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226279@lists.php.net to get a copy of this message
From:             michael dot vorisek at email dot cz
Operating system: 
PHP version:      7.4.4
Package:          Scripting Engine problem
Bug Type:         Bug
Bug description:self:: does not refer to the same class name

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 bug report at https://bugs.php.net/bug.php?id=79419&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=79419&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=79419&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=79419&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=79419&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=79419&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=79419&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=79419&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=79419&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=79419&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=79419&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79419&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=79419&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=79419&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=79419&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=79419&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=79419&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=79419&r=mysqlcfg


Thread (3 messages)

« previous php.bugs (#226279) next »