Bug #61467 [Opn->Fbk]: New "callable" typehint does not work (autoloading)

From: Date: Wed, 21 Mar 2012 20:49:54 +0000
Subject: Bug #61467 [Opn->Fbk]: New "callable" typehint does not work (autoloading)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-168702@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=61467&edit=1

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

 New Comment:

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


Previous Comments:
------------------------------------------------------------------------
[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


Thread (18 messages)

« previous php.bugs (#168702) next »