Hi Weilin,
Adding an usable new feature to array is always challenging.
But even if you were able to back up that this function would be
useful, how expressions such as assignment expressions (e.g. [$x =
$y]) would work well in that context ?
Regards.

On Wed, 30 Sept 2026 at 07:05, Sebastian Bergmann <[email protected]> wrote:
>
> Am 29.09.2026 um 19:44 schrieb Weilin Du:
> > 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.
> > ```
>
> I am not convinced by the premise of this RFC: it opens with the claim
> that associative arrays often repeat a key and a variable with the same
> name, but it offers no evidence for this, and it does not match my experience.
>
> A syntax change should be backed by data, for instance an analysis of a
> representative body of real-world code.
>
> Even if the pattern were common, I do not see any benefit in the proposed
> syntax. It saves a few characters but adds another form that every reader
> and every tool has to understand.
>
> I am sorry, but I will vote against this RFC.
>
> --
> Sebastian Bergmann                                 https://phpunit.expert
>
> Stay up to date with PHPUnit: https://phpunit.expert/newsletter

Reply via email to