xref: /PHP-8.0/Zend/tests/closure_016.phpt (revision f8d79582)
1--TEST--
2Closure 016: closures and is_callable()
3--FILE--
4<?php
5class Foo {
6    function __invoke() {
7        echo "Hello World!\n";
8    }
9}
10
11function foo() {
12    return function() {
13        echo "Hello World!\n";
14    };
15}
16$test = new Foo;
17var_dump(is_callable($test, true, $name));
18echo $name."\n";
19var_dump(is_callable($test, false, $name));
20echo $name."\n";
21var_dump(is_callable(array($test,"__invoke"), true, $name));
22echo $name."\n";
23var_dump(is_callable(array($test,"__invoke"), false, $name));
24echo $name."\n";
25$test = foo();
26var_dump(is_callable($test, true, $name));
27echo $name."\n";
28var_dump(is_callable($test, false, $name));
29echo $name."\n";
30var_dump(is_callable(array($test,"__invoke"), true, $name));
31echo $name."\n";
32var_dump(is_callable(array($test,"__invoke"), false, $name));
33echo $name."\n";
34?>
35--EXPECT--
36bool(true)
37Foo::__invoke
38bool(true)
39Foo::__invoke
40bool(true)
41Foo::__invoke
42bool(true)
43Foo::__invoke
44bool(true)
45Closure::__invoke
46bool(true)
47Closure::__invoke
48bool(true)
49Closure::__invoke
50bool(true)
51Closure::__invoke
52