|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #80421 Splat operator could support associative arrays
Submitted: 2020-11-26 01:56 UTC Modified: 2021-08-03 13:08 UTC
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: david at grudl dot com Assigned:
Status: Open Package: Arrays related
PHP Version: 8.2 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: david at grudl dot com
New email:
PHP Version: OS:


 [2020-11-26 01:56 UTC] david at grudl dot com
Now is possible to use splat operator with associative array when calling functions:

func(...['a' => 1, 'b' => 2])

It would be nice if it worked the same way in arrays:

$a = [  ...['a' => 1, 'b' => 2]  ];

Now it triggers fatal error: Cannot unpack array with string keys 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-11-26 02:07 UTC]
-Status: Open +Status: Suspended -Package: Scripting Engine problem +Package: Arrays related -PHP Version: 8.0.0RC5 +PHP Version: 8.1
 [2020-11-26 02:07 UTC]
Proposed but not in active discussion.

8.0 is about to release so the earliest this could happen is 8.1.
 [2020-11-26 02:09 UTC]
-Status: Suspended +Status: Open
 [2020-11-26 02:09 UTC]
Actually, going to leave this Open since the RFC is six years old.
 [2021-08-03 13:08 UTC]
-PHP Version: 8.1 +PHP Version: 8.2
 [2021-08-03 13:08 UTC]
8.1 is in feature freeze now, so now the earliest this could happen is 8.2.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Feb 21 03:01:33 2024 UTC