[RFC] Array unpacking with string keys

php.internals

Nikita Popov

5 years ago
Hi internals, I'd like to propose that string keys be allowed when unpacking into arrays: https://wiki.php.net/rfc/array_unpacking_string_keys Especially as unpacking in calls supports string keys now, I believe it is time to drop this limitation for arrays as well. Regards, Nikita

Larry Garfield

5 years ago
On Thu, Jan 7, 2021, at 5:30 AM, Nikita Popov wrote:
> Hi internals, > > I'd like to propose that string keys be allowed when unpacking into arrays: > https://wiki.php.net/rfc/array_unpacking_string_keys > > Especially as unpacking in calls supports string keys now, I believe it is > time to drop this limitation for arrays as well. > > Regards, > Nikita
Hard yes. I ran into a case just yesterday (while doing some sample code for immutability) when I wanted to merge associative arrays this way and the alternate was much yuckier. --Larry Garfield

Kalle Sommer Nielsen

5 years ago
Den tor. 7. jan. 2021 kl. 21.19 skrev Larry Garfield <larry@garfieldtech.com>:
> Hard yes. I ran into a case just yesterday (while doing some sample code for immutability) when I wanted to merge associative arrays this way and the alternate was much yuckier.
Seconded, I ran into a similar thing yesterday and it took me a bit to figure out what was going on. This RFC would fix that behavior so big +1
-- regards, Kalle Sommer Nielsen kalle@php.net

tyson andre

5 years ago
Hi Nikita, > I'd like to propose that string keys be allowed when unpacking into arrays: > https://wiki.php.net/rfc/array_unpacking_string_keys > > Especially as unpacking in calls supports string keys now, I believe it is > time to drop this limitation for arrays as well. +1, was considering proposing the same array_merge semantics as this RFC but didn't get around to looking into why this wasn't in the original php 7.4 array unpacking RFC. Regards, Tyson

Nikita Popov

5 years ago
On Thu, Jan 7, 2021 at 12:30 PM Nikita Popov <nikita.ppv@gmail.com> wrote:
> Hi internals, > > I'd like to propose that string keys be allowed when unpacking into > arrays: https://wiki.php.net/rfc/array_unpacking_string_keys > > Especially as unpacking in calls supports string keys now, I believe it is > time to drop this limitation for arrays as well. > > Regards, > Nikita >
This RFC seems to have been well-received, so I plan to start voting soon. Nikita