php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #46229 call_user_func_array throws misleading warning
Submitted: 2008-10-04 20:58 UTC Modified: 2012-04-09 22:14 UTC
Votes:8
Avg. Score:3.6 ± 0.5
Reproduced:8 of 8 (100.0%)
Same Version:4 (50.0%)
Same OS:1 (12.5%)
From: brian at nerdlife dot net Assigned: nikic (profile)
Status: Closed Package: *General Issues
PHP Version: 5.2.6 OS: N/A
Private report: No CVE-ID: None
 [2008-10-04 20:58 UTC] brian at nerdlife dot net
Description:
------------
If you pass an invalid array as a callback (for example if your object is actually just NULL), call_user_func_array warns with a message that implies that arrays are not valid callbacks:

Warning: call_user_func_array(): First argument is expected to be a valid callback, 'Array' was given in ...

This is misleading.  Perhaps the wording should be changed to match call_user_func's warning:

Warning: call_user_func(Array): First argument is expected to be a valid callback in ...

Alternatively the error message can be made more specific when passed an array as to where in the trail of objects the call failed (and possibly what the value/type was).

Reproduce code:
---------------
<?php
$foo = NULL;
call_user_func_array(array($foo, 'foofunc'), array($var1));
call_user_func(array($foo, 'foofunc'), $var1);
?>



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-04-09 22:14 UTC] nikic@php.net
Closing as it looks like this has been fixed by now. Your examples gives the following error:

call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object
 [2012-04-09 22:14 UTC] nikic@php.net
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: nikic
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 03:01:29 2024 UTC