Re: Proposal: Shorthand initialization and destructuring of associative arrays
| From: | Konrad Baumgart | Date: | Mon, 04 Oct 2021 19:15:13 +0000 |
| Subject: | Re: Proposal: Shorthand initialization and destructuring of associative arrays | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-116219@lists.php.net to get a copy of this message | ||
> I have spare time this October, so I would happily get into php interpreter by developing this.
Unfortunately my plans to have spare time FAILED and I'm not able to
contribute in the near future.
> If something like this were to be introduced, I'd happily see it happen with anonymous
> objects and interfaces accepting properties:
Using classes/interfaces rather than associative arrays is superior in
'enterprise' projects, but sometimes I just want to quickly return
tuple or construct json response.
> This way php could verify the return value with the return type, and static analyzers can
> determine the structure of what's to be returned. Imo this functionality is not worth the
> headache with arrays.
We recently got #[ArrayShape]. Maybe associative arrays will get more
love from static analyzers and will be suitable for 'tuple returns'.