2015-04-23 14:52:05 +00:00
|
|
|
--TEST--
|
2015-10-20 16:50:13 +00:00
|
|
|
Closure 059: Closure type declaration
|
2015-04-23 14:52:05 +00:00
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
class A {
|
|
|
|
}
|
|
|
|
|
|
|
|
class B {
|
|
|
|
}
|
|
|
|
|
|
|
|
$a = new A;
|
|
|
|
$b = new B;
|
|
|
|
|
|
|
|
$f = function (A $a){};
|
|
|
|
|
|
|
|
$f($a);
|
|
|
|
$f->__invoke($a);
|
|
|
|
call_user_func(array($f,"__invoke"), $a);
|
|
|
|
|
|
|
|
try {
|
|
|
|
$f($b);
|
2015-05-16 21:49:14 +00:00
|
|
|
} catch (Error $e) {
|
2015-04-23 14:52:05 +00:00
|
|
|
echo "Exception: " . $e->getMessage() . "\n";
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
$f->__invoke($b);
|
2015-05-16 21:49:14 +00:00
|
|
|
} catch (Error $e) {
|
2015-04-23 14:52:05 +00:00
|
|
|
echo "Exception: " . $e->getMessage() . "\n";
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
call_user_func(array($f,"__invoke"), $b);
|
2015-05-16 21:49:14 +00:00
|
|
|
} catch (Error $e) {
|
2015-04-23 14:52:05 +00:00
|
|
|
echo "Exception: " . $e->getMessage() . "\n";
|
|
|
|
}
|
|
|
|
--EXPECTF--
|
|
|
|
Exception: Argument 1 passed to {closure}() must be an instance of A, instance of B %s
|
|
|
|
Exception: Argument 1 passed to {closure}() must be an instance of A, instance of B %s
|
|
|
|
Exception: Argument 1 passed to {closure}() must be an instance of A, instance of B %s
|