Annotation of embedaddon/php/Zend/tests/closure_018.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Closure 018: Assigning lambda to static var and returning by ref
! 3: --FILE--
! 4: <?php
! 5:
! 6: class foo {
! 7: public function test(&$x) {
! 8: static $lambda;
! 9: $lambda = function &() use (&$x) {
! 10: return $x = $x * $x;
! 11: };
! 12: return $lambda();
! 13: }
! 14: }
! 15:
! 16: $test = new foo;
! 17:
! 18: $y = 2;
! 19: var_dump($test->test($y));
! 20: var_dump($x = $test->test($y));
! 21: var_dump($y, $x);
! 22:
! 23: ?>
! 24: --EXPECT--
! 25: int(4)
! 26: int(16)
! 27: int(16)
! 28: int(16)
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>