Re: [RFC] Short Array Variable Shorthand

From: Date: Wed, 30 Sep 2026 05:50:06 +0000
Subject: Re: [RFC] Short Array Variable Shorthand
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-132702@lists.php.net to get a copy of this message
Hi! On Tue, Sep 29, 2026 at 8:45 PM Weilin Du <weilin-du@qq.com> wrote: > > ``` > $point = [:$x, :$y, :$z]; // ['x' -> $x, 'y' -> $y, 'z' > -> $z] > ``` To be honest, I'm not a huge fan of quirky and tricky perl-like syntaxes in languages, but in general I think I personally would like such a feature for exactly one purpose: to cast DTO's to arrays if this feature also supported [=$this->id, =$this->name, ...etc] (or replace $this with any other object). This would allow to constrain key-names in resulting arrays to reflect exact names of properties of the class. But according to your current version of RFC, it is not the case. Is there any strong reason to not support such behaviour? Regards, Alexandr Egorov.

« previous php.internals (#132702) next »