1--TEST-- 2Closure 059: Closure type declaration 3--FILE-- 4<?php 5class A { 6} 7 8class B { 9} 10 11$a = new A; 12$b = new B; 13 14$f = function (A $a){}; 15 16$f($a); 17$f->__invoke($a); 18call_user_func(array($f,"__invoke"), $a); 19 20try { 21 $f($b); 22} catch (Error $e) { 23 echo "Exception: " . $e->getMessage() . "\n"; 24} 25try { 26 $f->__invoke($b); 27} catch (Error $e) { 28 echo "Exception: " . $e->getMessage() . "\n"; 29} 30try { 31 call_user_func(array($f,"__invoke"), $b); 32} catch (Error $e) { 33 echo "Exception: " . $e->getMessage() . "\n"; 34} 35?> 36--EXPECTF-- 37Exception: {closure:%s:%d}(): Argument #1 ($a) must be of type A, B given, called in %s on line %d 38Exception: {closure:%s:%d}(): Argument #1 ($a) must be of type A, B given 39Exception: {closure:%s:%d}(): Argument #1 ($a) must be of type A, B given 40