mirror of
https://github.com/php/php-src.git
synced 2024-12-25 01:40:50 +08:00
39 lines
439 B
Plaintext
39 lines
439 B
Plaintext
|
--TEST--
|
||
|
Closure 007: Nested lambdas in classes
|
||
|
--FILE--
|
||
|
<?php
|
||
|
|
||
|
class A {
|
||
|
private $x = 0;
|
||
|
|
||
|
function getClosureGetter () {
|
||
|
return function () {
|
||
|
return function () {
|
||
|
$this->x++;
|
||
|
};
|
||
|
};
|
||
|
}
|
||
|
|
||
|
function printX () {
|
||
|
echo $this->x."\n";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$a = new A;
|
||
|
$a->printX();
|
||
|
$getClosure = $a->getClosureGetter();
|
||
|
$a->printX();
|
||
|
$closure = $getClosure();
|
||
|
$a->printX();
|
||
|
$closure();
|
||
|
$a->printX();
|
||
|
|
||
|
echo "Done\n";
|
||
|
?>
|
||
|
--EXPECT--
|
||
|
0
|
||
|
0
|
||
|
0
|
||
|
1
|
||
|
Done
|