closure_018.phpt 623 B

12345678910111213141516171819202122232425262728293031
  1. --TEST--
  2. Closure 018: Assigning lambda to static var and returning by ref
  3. --FILE--
  4. <?php
  5. class foo {
  6. public function test(&$x) {
  7. static $lambda;
  8. $lambda = function &() use (&$x) {
  9. return $x = $x * $x;
  10. };
  11. return $lambda();
  12. }
  13. }
  14. $test = new foo;
  15. $y = 2;
  16. var_dump($test->test($y));
  17. var_dump($x = $test->test($y));
  18. var_dump($y, $x);
  19. ?>
  20. --EXPECTF--
  21. Notice: Only variable references should be returned by reference in %sclosure_018.php on line 7
  22. int(4)
  23. Notice: Only variable references should be returned by reference in %sclosure_018.php on line 7
  24. int(16)
  25. int(16)
  26. int(16)