From: crashrox at gmail dot com
Operating system: Linux
PHP version: 5.3.1
PHP Bug Type: Class/Object related
Bug description: self in closures has no class scope
Description:
------------
A closure within a static method loses self scope. When you print
__CLASS__ within a closure it claims to belong to the class. But yet you
cant access anything from that class.
Reproduce code:
---------------
class Test {
public function do_something() {
$func = function() {
echo 'I belong to: ' . __CLASS__;
return self::do_something_else();
};
return $func();
}
public static function do_something_else() {
return 'I did something else';
}
}
echo Test::do_something();
Expected result:
----------------
i belong to: Test
i did something else
Actual result:
--------------
Test
Fatal error: Cannot access self:: when no class scope is active in
/home/jument/adam/jument/web/index.php on line 7
--
Edit bug report at http://bugs.php.net/?id=50418&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=50418&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=50418&r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=50418&r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=50418&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=50418&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=50418&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=50418&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=50418&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=50418&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=50418&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=50418&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=50418&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=50418&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=50418&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50418&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=50418&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=50418&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=50418&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=50418&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=50418&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=50418&r=mysqlcfg