Req #54311 [Opn]: Implicit variable scope declaration
| From: | dan dot lugg at gmail dot com | Date: | Sat, 19 Mar 2011 17:14:35 +0000 |
| Subject: | Req #54311 [Opn]: Implicit variable scope declaration | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-159632@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=54311&edit=1
ID: 54311
User updated by: dan dot lugg at gmail dot com
Reported by: dan dot lugg at gmail dot com
Summary: Implicit variable scope declaration
Status: Open
Type: Feature/Change Request
Package: *Programming Data Structures
Operating System: Windows 7 x64
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Further examples exhibiting scope inheritance:
class Test{
public $func;
public function callFunc(){
$this->func();
}
}
$foo = 'hello';
$test = new Test;
$test->func = function() use implicit{
echo $foo;
}
$test->callFunc(); // hello
Previous Comments:
------------------------------------------------------------------------
[2011-03-19 04:14:28] dan dot lugg at gmail dot com
Description:
------------
Feature request for 'use implicit', or semantically similar syntax.
Anonymous functions with the use implicit directive inherit all
variables from parent scope in which they are declared, not called;
$foo = 'hello';
call_user_func(function() use implicit{
echo $foo; // hello
});
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54311&edit=1