|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #80971 func_get_args() didnt work when using named args
Submitted: 2021-04-20 16:38 UTC Modified: 2021-05-11 06:42 UTC
From: antoni at friki dot cat Assigned:
Status: Open Package: Documentation problem
PHP Version: 8.0.3 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: antoni at friki dot cat
New email:
PHP Version: OS:


 [2021-04-20 16:38 UTC] antoni at friki dot cat
func_get_args() in combination with named args returns an empty array.

Test script:

function foo(...$args) {

foo(a: 9, b: 99, c: 999);

Expected result:
I expected an array with 3 elements.

array(3) {

array(3) {

Actual result:
array(0) {


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-04-20 17:00 UTC]
-Type: Bug +Type: Documentation Problem -Package: *General Issues +Package: Scripting Engine problem
 [2021-04-20 17:00 UTC]
This is expected, but apparently undocumented.  From the RFC[1]:

| All three functions are oblivious to the collection of unknown
| named arguments by variadics. func_get_args() will not return the
| collected values and func_num_args() will not include them in the
| argument count. Collected unknown named arguments can only be
| accessed through the variadic parameter.

[1] <>
 [2021-05-11 06:42 UTC]
-Package: Scripting Engine problem +Package: Documentation problem
 [2021-06-03 02:28 UTC]
The following pull request has been associated:

Patch Name: Fix 80971: func_get_args() didnt work when using named args
On GitHub:
 [2023-05-06 03:00 UTC] timkeller at aol dot com
 [2023-09-29 06:41 UTC] ta dot nnaowens6 at googlemail dot com
Thanks for sharing this, this is amazing. i like it. (
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 16 19:01:30 2024 UTC