summaryrefslogtreecommitdiff
path: root/Zend/tests/call_user_func_003.phpt
blob: b501d803e776ba0a9d704fe621c880e4dbf0e07c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
--TEST--
Testing call_user_func() with closures
--FILE--
<?php

$foo = function() {
    static $instance;

    if (is_null($instance)) {
        $instance = function () {
            return 'OK!';
        };
    }

    return $instance;
};

var_dump(call_user_func(array($foo, '__invoke'))->__invoke());
var_dump(call_user_func(function() use (&$foo) { return $foo; }, '__invoke'));

?>
--EXPECTF--
string(3) "OK!"
object(Closure)#%d (1) {
  ["static"]=>
  array(1) {
    ["instance"]=>
    object(Closure)#%d (0) {
    }
  }
}