Bug #69676 [Asn]: Resolution of self::FOO in class constants not correct
| From: | nikic@php.net | Date: | Sun, 08 Jan 2017 11:08:18 +0000 |
| Subject: | Bug #69676 [Asn]: Resolution of self::FOO in class constants not correct | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-206391@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69676&edit=1
ID: 69676
Updated by: nikic@php.net
Reported by: nikic@php.net
Summary: Resolution of self::FOO in class constants not
correct
Status: Assigned
Type: Bug
Package: Scripting Engine problem
PHP Version: master-Git-2015-05-20 (Git)
Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
The particular test script works in PHP 7, but the following still fails:
<?php
class A {
const myDynConst = self::myConst;
const myConst = "const in A";
}
class B extends A {
const myConst = "const in B";
}
var_dump(B::myDynConst);
var_dump(A::myDynConst);
Previous Comments:
------------------------------------------------------------------------
[2015-05-20 21:55:04] nikic@php.net
Description:
------------
* Resolution of self:: at compile-time for constants currently doesn't seem to happen in PHP 7
* The run-time resolution uses the wrong self:: scope in PHP 7
* The scope is also wrong in PHP 5, but in a different way (depending on whether A:: or B:: is
used).
Test script:
---------------
<?php
class A {
const myConst = "const in A";
const myDynConst = self::myConst;
}
class B extends A {
const myConst = "const in B";
}
var_dump(B::myDynConst);
var_dump(A::myDynConst);
Expected result:
----------------
string(10) "const in A"
string(10) "const in A"
Actual result:
--------------
PHP 7:
string(10) "const in B"
string(10) "const in B"
PHP 5:
string(10) "const in A"
string(10) "const in B"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69676&edit=1