1--TEST--
2Testing call_user_func() with closures
3--FILE--
4<?php
5
6$foo = function() {
7    static $instance;
8
9    if (is_null($instance)) {
10        $instance = function () {
11            return 'OK!';
12        };
13    }
14
15    return $instance;
16};
17
18var_dump(call_user_func(array($foo, '__invoke'))->__invoke());
19var_dump(call_user_func(function() use (&$foo) { return $foo; }, '__invoke'));
20
21?>
22--EXPECTF--
23string(3) "OK!"
24object(Closure)#%d (4) {
25  ["name"]=>
26  string(%d) "{closure:%s:%d}"
27  ["file"]=>
28  string(%d) "%s"
29  ["line"]=>
30  int(%d)
31  ["static"]=>
32  array(1) {
33    ["instance"]=>
34    object(Closure)#%d (3) {
35      ["name"]=>
36      string(%d) "{closure:%s:%d}"
37      ["file"]=>
38      string(%d) "%s"
39      ["line"]=>
40      int(%d)
41    }
42  }
43}
44