Bug #69676 [NEW]: Resolution of self::FOO in class constants not correct

From: Date: Wed, 20 May 2015 21:55:05 +0000
Subject: Bug #69676 [NEW]: Resolution of self::FOO in class constants not correct
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-192792@lists.php.net to get a copy of this message
From: nikic Operating system: PHP version: master-Git-2015-05-20 (Git) Package: Scripting Engine problem Bug Type: Bug Bug description:Resolution of self::FOO in class constants not correct 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 bug report at https://bugs.php.net/bug.php?id=69676&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69676&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69676&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69676&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=69676&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=69676&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=69676&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=69676&r=needscript Try newer version: https://bugs.php.net/fix.php?id=69676&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=69676&r=support Expected behavior: https://bugs.php.net/fix.php?id=69676&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=69676&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=69676&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=69676&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69676&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=69676&r=dst IIS Stability: https://bugs.php.net/fix.php?id=69676&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=69676&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=69676&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=69676&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=69676&r=mysqlcfg

« previous php.bugs (#192792) next »