Bug #79419 [Opn->Dup]: self:: does not refer to the same class name
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)