On Wed, Jul 12, 2017 at 2:09 PM, Bartłomiej Krukowski < krukowski.bartlom...@gmail.com> wrote:
> Hello, > > Yes, this is exactly what I would like to achieve. > > Best regards > > 2017-07-12 14:06 GMT+02:00 Marco Pivetta <ocram...@gmail.com>: > >> On Wed, Jul 12, 2017 at 11:22 AM, Bartłomiej Krukowski < >> krukowski.bartlom...@gmail.com> wrote: >> >>> Hello, >>> From PHP 5.6 we have possibility to add variadic functions and unpacking >>> arrays via *...* >>> Would be nice to extend responsibility of *...*. Sometimes in code I can >>> find lines similar to the following: >>> >>> $result = array_merge(['some value'], ['some other value'], $array); >>> >>> >>> I would like to shorten this line to the following: >>> >>> $result = ['some value', ['some other value'], ...$array]; >>> >>> >>> And even allow to unpack more than one array: >>> >>> $result = ['some value', ['some other value'], ...$array, >>> ...$secondArray]; >>> >>> >>> Using new operator we can produce shorter and more clearable code. I >>> would >>> like to create RFC for my proposal. If you think idea can be useful, >>> please >>> give me an access for creating RFC. >>> >>> Best regards >>> >> >> Would this allow operations such as the following one? >> >> $a = [0]; >> $b = [1]; >> $otherArrays = [[2,3], [4,5]]; >> $mergeAll = [...$a, ...$b, ...[...$otherArrays]]; // [0, 1, 2, 3, 4, 5] >> >> Marco Pivetta >> >> http://twitter.com/Ocramius >> >> http://ocramius.github.com/ >> >> >> > TBH, I'd like to have a functional approach to this, so that I can use functional composition instead of operators (`array_map('...', $values))`). Still, the addition is very nice and complimentary with the existing splat/variadic argument stuff :D Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/