Re: [RFC] Short Array Variable Shorthand

From: Date: Wed, 30 Sep 2026 06:02:06 +0000
Subject: Re: [RFC] Short Array Variable Shorthand
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-132703@lists.php.net to get a copy of this message
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

« previous php.internals (#132703) next »