php-src/Zend/tests/closure_018.phpt

32 lines
584 B
Plaintext
Raw Normal View History

2008-07-14 13:39:32 +00:00
--TEST--
Closure 018: Assigning lambda to static var and returning by ref
--FILE--
<?php
class foo {
public function test(&$x) {
static $lambda;
2018-10-14 15:45:48 +00:00
$lambda = function &() use (&$x) {
2008-07-14 13:39:32 +00:00
return $x = $x * $x;
};
return $lambda();
}
}
$test = new foo;
$y = 2;
var_dump($test->test($y));
var_dump($x = $test->test($y));
var_dump($y, $x);
?>
2013-11-27 17:04:00 +00:00
--EXPECTF--
2013-11-27 16:30:35 +00:00
Notice: Only variable references should be returned by reference in %sclosure_018.php on line 7
2008-07-14 13:39:32 +00:00
int(4)
2013-11-27 16:30:35 +00:00
Notice: Only variable references should be returned by reference in %sclosure_018.php on line 7
2008-07-14 13:39:32 +00:00
int(16)
int(16)
int(16)