2008-07-14 20:17:16 +08:00
|
|
|
--TEST--
|
|
|
|
Closure 016: closures and is_callable()
|
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
class Foo {
|
2020-02-04 05:52:20 +08:00
|
|
|
function __invoke() {
|
|
|
|
echo "Hello World!\n";
|
|
|
|
}
|
2008-07-14 20:17:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function foo() {
|
2020-02-04 05:52:20 +08:00
|
|
|
return function() {
|
|
|
|
echo "Hello World!\n";
|
|
|
|
};
|
2008-07-14 20:17:16 +08:00
|
|
|
}
|
|
|
|
$test = new Foo;
|
|
|
|
var_dump(is_callable($test, true, $name));
|
|
|
|
echo $name."\n";
|
|
|
|
var_dump(is_callable($test, false, $name));
|
|
|
|
echo $name."\n";
|
|
|
|
var_dump(is_callable(array($test,"__invoke"), true, $name));
|
|
|
|
echo $name."\n";
|
|
|
|
var_dump(is_callable(array($test,"__invoke"), false, $name));
|
|
|
|
echo $name."\n";
|
|
|
|
$test = foo();
|
|
|
|
var_dump(is_callable($test, true, $name));
|
|
|
|
echo $name."\n";
|
|
|
|
var_dump(is_callable($test, false, $name));
|
|
|
|
echo $name."\n";
|
|
|
|
var_dump(is_callable(array($test,"__invoke"), true, $name));
|
|
|
|
echo $name."\n";
|
|
|
|
var_dump(is_callable(array($test,"__invoke"), false, $name));
|
|
|
|
echo $name."\n";
|
|
|
|
?>
|
|
|
|
--EXPECT--
|
|
|
|
bool(true)
|
|
|
|
Foo::__invoke
|
|
|
|
bool(true)
|
|
|
|
Foo::__invoke
|
|
|
|
bool(true)
|
|
|
|
Foo::__invoke
|
|
|
|
bool(true)
|
|
|
|
Foo::__invoke
|
|
|
|
bool(true)
|
|
|
|
Closure::__invoke
|
|
|
|
bool(true)
|
|
|
|
Closure::__invoke
|
|
|
|
bool(true)
|
|
|
|
Closure::__invoke
|
|
|
|
bool(true)
|
|
|
|
Closure::__invoke
|