Bug #69007 [NEW]: scope resolution doesn't work with static anonymous functions
| From: | minecraftshamrock at gmail dot com | Date: | Sat, 07 Feb 2015 21:25:52 +0000 |
| Subject: | Bug #69007 [NEW]: scope resolution doesn't work with static anonymous functions | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-190513@lists.php.net to get a copy of this message | ||
From: minecraftshamrock at gmail dot com
Operating system:
PHP version: Irrelevant
Package: *General Issues
Bug Type: Bug
Bug description:scope resolution doesn't work with static anonymous functions
Description:
------------
Scope resolution using parent:: self:: and static:: does not work
properly and is poorly specified for static anonymous functions.
Test snippet:
http://pastebin.com/7y9Wa4Xj
I have neither found a prediction by the specification about how this
should behave, nor were I able to interpret any rules into the behavior
when testing.
I've tested the linked script using http://3v4l.org/ in various
versions
of PHP and no version of PHP exhibits a logically reasonable behavior
(except HHVM).
So please specify more exactly how this should behave and implement it
in PHP.
Expected result:
----------------
Actually none because the specification predicts nothing about this
code.
Actual result:
--------------
Output for 5.5.14 - 5.6.5, php7@20140701 - 20150201
GuyGuy
ChildChild
FatherFather
Child
GuyChildChild
GuyGuy
Note that for this versions "self::hi();" and "echo self::class;" in the
static anonymous function do not even refer to the same class as
"self".
Output for 5.5.0 - 5.5.13, php7@20140507 - 20140521
GuyGuy
ChildChild
FatherFather
Guy
GuyGuyGuy
FatherFather
--
Edit bug report at https://bugs.php.net/bug.php?id=69007&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69007&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69007&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69007&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69007&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69007&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69007&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69007&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69007&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69007&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69007&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69007&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69007&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69007&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69007&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69007&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69007&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69007&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69007&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69007&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69007&r=mysqlcfg