xref: /PHP-7.2/Zend/tests/closure_019.phpt (revision 17ccbeec)
1--TEST--
2Closure 019: Calling lambda using $GLOBALS and global $var
3--FILE--
4<?php
5
6$lambda = function &(&$x) {
7	return $x = $x * $x;
8};
9
10function test() {
11	global $lambda;
12
13	$y = 3;
14	var_dump($GLOBALS['lambda']($y));
15	var_dump($lambda($y));
16	var_dump($GLOBALS['lambda'](1));
17}
18
19test();
20
21?>
22--EXPECTF--
23Notice: Only variable references should be returned by reference in %sclosure_019.php on line 4
24int(9)
25
26Notice: Only variable references should be returned by reference in %sclosure_019.php on line 4
27int(81)
28
29Fatal error: Uncaught Error: Cannot pass parameter 1 by reference in %s:%d
30Stack trace:
31#0 %s(%d): test()
32#1 {main}
33  thrown in %s on line %d
34