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

From: Date: Wed, 21 Mar 2012 20:25:04 +0000
Subject: Bug #61467 [Opn]: New "callable" typehint does not work (autoloading)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-168699@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
 User updated by:    david at grudl dot com
 Reported by:        david at grudl dot com
-Summary:            New "callable" typehint do not work (autoloading)
+Summary:            New "callable" typehint does not work (autoloading)
 Status:             Open
 Type:               Bug
 Package:            Class/Object related
 PHP Version:        5.4.0
 Block user comment: N
 Private report:     N

 New Comment:

do -> does


Previous Comments:
------------------------------------------------------------------------
[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 (#168699) next »