Am 29.09.2026 um 19:44 schrieb Weilin Du <[email protected]>:
> Today, I want to announce my second RFC to php 8.7
> https://wiki.php.net/rfc/array_shorthand
>
> This RFC brings a IMO useful syntactic sugar to array's
> construction and destruction. I hope you'all find this
> interesting! To be short:
>
> ```
> $point = [:$x, :$y, :$z]; // ['x' -> $x, 'y' -> $y, 'z' -> $z]
> [:$x, :$y, :$z] = $point; // reverse.
> ```
We have been using a local patch for this short-hand syntax for many years and
are very happy as for our coding style this comes up quite often.
I prefer the original :$foo instead of =$foo even though there is a minor clash
with the ternary operator but to be honest I would find
[ $bool ? =$foo : =$bar]
to return either an array with the key 'foo' or 'bar' not useful enough and
would rather use
$bool ? [:$foo] : [:$bar]
So you have a +1 from me but I would strongly prefer : instead of =,
- Chris