Edit report at https://bugs.php.net/bug.php?id=54311&edit=1

 ID:                 54311
 Updated by:         ras...@php.net
 Reported by:        dan dot lugg at gmail dot com
 Summary:            Implicit variable scope declaration
-Status:             Open
+Status:             Wont fix
 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:

I really prefer to be explicit about what you bring into a restricted scope. 
That 
has been PHP's approach from day 1 with the explicit nature of the 'global' 
keyword to declare explicitly which global variables a function will muck with.

And in PHP 5.4 with the implicit binding of $this I think most of the 
motivation 
for a request like this is gone anyway.


Previous Comments:
------------------------------------------------------------------------
[2011-03-19 18:14:33] dan dot lugg at gmail dot com

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

------------------------------------------------------------------------
[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 https://bugs.php.net/bug.php?id=54311&edit=1

Reply via email to