xref: /PHP-7.3/Zend/tests/closure_007.phpt (revision c93a4f19)
1--TEST--
2Closure 007: Nested lambdas in classes
3--FILE--
4<?php
5
6class A {
7	private $x = 0;
8
9	function getClosureGetter () {
10		return function () {
11			return function () {
12				$this->x++;
13			};
14		};
15	}
16
17	function printX () {
18		echo $this->x."\n";
19	}
20}
21
22$a = new A;
23$a->printX();
24$getClosure = $a->getClosureGetter();
25$a->printX();
26$closure = $getClosure();
27$a->printX();
28$closure();
29$a->printX();
30
31echo "Done\n";
32?>
33--EXPECT--
340
350
360
371
38Done
39