Hello,

I would like to submit an RFC proposal about array destructuring assignment. An 
RFC has already been implemented in php 7.1 about this 
(https://wiki.php.net/rfc/short_list_syntax), but I feel like something is 
missing for this one. Indeed, another RFC about "Spread Operator in Array 
Expression" has been implemented in php 7.4 
(https://wiki.php.net/rfc/spread_operator_for_array). The first RFC allows to 
destructure an array and assign several variable from it, the other one allows 
to build an array by "spreading another array inside of it". It would be so 
nice if we could combine both feature to provide a spread operator for array 
destructuring assignment.

Here is a short example to demonstrate it:

$foobar = [1, 2, 3, 4, 5];
[$foo, ...$bar] = $foobar;

So here $foo = 1 and $bar = [2, 3, 4, 5];

During my developer journey, I've encountered several cases where this could be 
very useful and make my code shorter.


Best regards,


Paul Laffitte

paul.laffi...@epitech.eu<mailto:paul.laffi...@epitech.eu>

Student Promotion 2021

{EPITECH.} Montpellier

+336.01.04.24.96

Reply via email to