xref: /PHP-8.2/Zend/tests/closure_018.phpt (revision f8d79582)
1--TEST--
2Closure 018: Assigning lambda to static var and returning by ref
3--FILE--
4<?php
5
6class 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;
19var_dump($test->test($y));
20var_dump($x = $test->test($y));
21var_dump($y, $x);
22
23?>
24--EXPECTF--
25Notice: Only variable references should be returned by reference in %sclosure_018.php on line 7
26int(4)
27
28Notice: Only variable references should be returned by reference in %sclosure_018.php on line 7
29int(16)
30int(16)
31int(16)
32