php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #17207 call_user_func_array does not bind array keys to params
Submitted: 2002-05-14 08:50 UTC Modified: 2014-12-30 10:41 UTC
From: rcarmo at accao dot net Assigned:
Status: No Feedback Package: Arrays related
PHP Version: 4.1.2 OS: Irrelevant
Private report: No CVE-ID: None
 [2002-05-14 08:50 UTC] rcarmo at accao dot net
When calling a function with call_user_func_array, if one of the parameters is not set, the trailing hash values are assigned to the wrong parameters.

function test( $a, $b, $c ) {
  echo "|$a:$b:$c|";
}

$aParams = array( "a" => 1, "c" => 3 );

call_user_func_array( "test", $aParams );

The output I get is
|1:3:|

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-14 08:53 UTC] derick@php.net
This is not supposed to work at all, I'm making this a feature request.

Derick
 [2002-05-14 09:29 UTC] rcarmo at accao dot net
Thanks. This would be extremely useful for XML-RPC/SOAP stuff with optional parameters (that have to be validated down at the actual function call level). 

Since there is no way to actually get a valid argument list on the function BEFORE doing call_user_func_array, I'm getting around it with stuff like this hideous kludge INSIDE the actual function:

if( func_num_args() < 7 )
    return new CFault( "400", "Client", "Incorrect number of method arguments", $php_errormsg );
 [2014-04-16 16:38 UTC] levim@php.net
This is similar to the RFC for named parameters: https://wiki.php.net/rfc/named_params
 [2014-04-28 14:16 UTC] levim@php.net
-Status: Open +Status: Feedback -Package: Feature/Change Request +Package: Arrays related -Operating System: Any +Operating System: Irrelevant
 [2014-04-28 14:16 UTC] levim@php.net
Is this something you are still interested in seeing?
 [2014-12-30 10:41 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC