Allow use AS in the closure declaration, like:
<?php $foo = "bar"; $func = function () use ($foo as $dup, &$foo as $ref) { //alias name };
I have made a patch, after patch, the following script:
<?php $a = "2"; $b = function() use (&$a as $b, $a as $c, $a as $e) { echo $b; echo $c; echo $e; $b = 4; }; $b(); echo $a; class Foo { public function closure() { return function () use ($this as $obj) { var_dump($obj); }; } } $foo = new Foo(); $a = $foo->closure(); $a();
will output:
2224object(Foo)#2 (0) { }
I will be keeping improve this patch.