|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #80531 call_user_func_array() interprets string keys as named args
Submitted: 2020-12-18 09:43 UTC Modified: 2020-12-18 09:46 UTC
Avg. Score:4.3 ± 0.9
Reproduced:6 of 6 (100.0%)
Same Version:4 (66.7%)
Same OS:3 (50.0%)
From: rh at tfli dot co dot uk Assigned:
Status: Open Package: Scripting Engine problem
PHP Version: 8.0.0 OS: Windows 10 (64Bit)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
41 - 1 = ?
Subscribe to this entry?

 [2020-12-18 09:43 UTC] rh at tfli dot co dot uk
This might be expected behaviour, but if so, should be made clear in the migration guide and/or the function page.

Since upgrading to PHP8, then an unchanged call to call_user_func_array in an existing project was returning the error 'Uncaught Error: Cannot use positional argument after named argument'. Investigating it further, one of the arguments is de-serialised from a JSON object (and so the array has string keys).

While I can see the behaviour of `call_user_func_array` using string keys as named arguments being useful, I can also see it being a massive 'gotta' for people when upgrading, especially as it is not currently documented anywhere that this will be the case (a lot of the times this can happen the array internal structure won't be apparent from the code or the error message).

Test script:
var_dump(call_user_func_array("strlen", ["hello"]));
var_dump(call_user_func_array("strlen", ["a" => "hello"]));

// Version Comparison:

Expected result:

Actual result:

Fatal error: Uncaught Error: Unknown named parameter $a in /in/c1R03:3
Stack trace:
#0 {main}
  thrown in /in/c1R03 on line 3

Process exited with code 255.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-18 09:46 UTC]
-Summary: Crash in mysqlnd_fetch_stmt_row_cursor when calling an SP with a cursor +Summary: call_user_func_array() interprets string keys as named args -Type: Bug +Type: Documentation Problem
 [2020-12-18 09:46 UTC]
This is documented in the migration guide (

> call_user_func_array() array keys will now be interpreted as parameter names, instead of being silently ignored.

However, it is not yet mentioned in the call_user_func_array() documentation itself.
 [2020-12-18 09:50 UTC] rh at tfli dot co dot uk
Ah, right you are! I did do a search for `named` (in relation to named arguments) before reporting the bug; and I did read through the full guide when upgrading.
 [2022-12-02 06:29 UTC] barryuyuamo at gmail dot com
I'm especially stayed aware of the article and I will get many benefits from it. Subsequently, thank you for sharing it.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 26 00:01:30 2024 UTC