Edit report at https://bugs.php.net/bug.php?id=61467&edit=1
ID: 61467 Comment by: david at grudl dot com Reported by: david at grudl dot com Summary: New "callable" typehint does not work (autoloading) Status: Feedback Type: Bug Package: Class/Object related PHP Version: 5.4.0 Block user comment: N Private report: N New Comment: Sorry, in PHP 5.4 there is not "an instance of" in error message. But that's not the point. Previous Comments: ------------------------------------------------------------------------ [2012-03-21 20:49:54] ras...@php.net Are you sure you are running 5.4? Your your test script: % php53 test.php Catchable fatal error: Argument 1 passed to test() must be an instance of callable, array given, called in /home/rasmus/r on line 6 and defined in /home/rasmus/r on line 2 % php54 test.php Catchable fatal error: Argument 1 passed to test() must be callable, array given, called in /home/rasmus/r on line 6 and defined in /home/rasmus/r on line 2 ------------------------------------------------------------------------ [2012-03-21 20:25:04] david at grudl dot com do -> does ------------------------------------------------------------------------ [2012-03-21 20:22:00] david at grudl dot com Description: ------------ Is really new type hint callable implemented? I see no difference between PHP 5.3 and PHP 5.4, both versions only throw catchable fatal errors. (I think this unexpected behaviour is due to the fact that class "A" do not exists. In this case the error message is confusing. But the callable should not trigger autoload, it should behave like is_callable($arg, TRUE) and just check the syntax. Otherwise typehint callable will cause major performance issues.) Test script: --------------- function test(callable $a) { } test(array('A', 'b')); // Catchable fatal error: Argument 1 passed to test() must be an instance of callable, array given test('A::b'); // Catchable fatal error: Argument 1 passed to test() must be an instance of callable, string given ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=61467&edit=1