php-src/Zend/tests/closure_019.phpt

34 lines
695 B
Plaintext
Raw Normal View History

2008-07-14 13:39:32 +00:00
--TEST--
Closure 019: Calling lambda using $GLOBALS and global $var
--FILE--
<?php
$lambda = function &(&$x) {
2020-02-03 21:52:20 +00:00
return $x = $x * $x;
2008-07-14 13:39:32 +00:00
};
function test() {
2020-02-03 21:52:20 +00:00
global $lambda;
2018-09-16 17:16:42 +00:00
2020-02-03 21:52:20 +00:00
$y = 3;
var_dump($GLOBALS['lambda']($y));
var_dump($lambda($y));
var_dump($GLOBALS['lambda'](1));
2008-07-14 13:39:32 +00:00
}
test();
?>
--EXPECTF--
2013-11-27 16:30:35 +00:00
Notice: Only variable references should be returned by reference in %sclosure_019.php on line 4
2008-07-14 13:39:32 +00:00
int(9)
2013-11-27 16:30:35 +00:00
Notice: Only variable references should be returned by reference in %sclosure_019.php on line 4
2008-07-14 13:39:32 +00:00
int(81)
Fatal error: Uncaught Error: {closure}(): Argument #1 ($x) cannot be passed by reference in %s:%d
Stack trace:
#0 %s(%d): test()
#1 {main}
thrown in %s on line %d