php.net |  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
Votes:1
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: david at grudl dot com
New email:
PHP Version: OS:

 

 [2020-11-26 01:56 UTC] david at grudl dot com
Description:
------------
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 


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-11-26 02:07 UTC] requinix@php.net
-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] requinix@php.net
Proposed but not in active discussion.
https://wiki.php.net/rfc/additional-splat-usage

8.0 is about to release so the earliest this could happen is 8.1.
 [2020-11-26 02:09 UTC] requinix@php.net
-Status: Suspended +Status: Open
 [2020-11-26 02:09 UTC] requinix@php.net
Actually, going to leave this Open since the RFC is six years old.
 [2021-08-03 13:08 UTC] ramsey@php.net
-PHP Version: 8.1 +PHP Version: 8.2
 [2021-08-03 13:08 UTC] ramsey@php.net
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: Mon Dec 02 20:01:32 2024 UTC