Edit report at https://bugs.php.net/bug.php?id=61467&edit=1

 ID:                 61467
 Updated by:         vr...@php.net
 Reported by:        david at grudl dot com
 Summary:            New "callable" typehint does not work (autoloading)
-Status:             Feedback
+Status:             Open
 Type:               Bug
 Package:            Class/Object related
 PHP Version:        5.4.0
 Block user comment: N
 Private report:     N



Previous Comments:
------------------------------------------------------------------------
[2012-03-21 23:57:25] david at grudl dot com

Possible fix is to change in file zend_execute.c on line 645 flag 
IS_CALLABLE_CHECK_SILENT to IS_CALLABLE_CHECK_SYNTAX_ONLY.

------------------------------------------------------------------------
[2012-03-21 21:58:51] david at grudl dot com

Sorry, in PHP 5.4 there is not "an instance of" in error message. But that's 
not the point.

------------------------------------------------------------------------
[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

Reply via email to