Re: [RFC] [DISCUSSION] Type casting in array destructuring expressions
| From: | Nicolas Grekas | Date: | Tue, 07 Apr 2020 11:14:33 +0000 |
| Subject: | Re: [RFC] [DISCUSSION] Type casting in array destructuring expressions | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-109548@lists.php.net to get a copy of this message | ||
Le mar. 7 avr. 2020 à 12:07, Enno Woortmann <enno.woortmann@web.de> a
écrit :
> Am 25.03.2020 um 18:53 schrieb Enno Woortmann:
>
> > Hi,
> >
> > I've written the RFC and implemented a first patch concerning the idea
> > to allow type casting in array destructuring expressions.
> >
> >
> > The RFC is located at
> > https://wiki.php.net/rfc/typecast_array_desctructuring
> >
> > The patch can be found in MR 5296 located at
> > https://github.com/php/php-src/pull/5296
> >
> >
> > Thanks for further feedback!
> >
> > Cheers, Enno
> >
>
> Hi together,
>
> As there has been no recent discussion concerning this RFC (tbh no
> discussion at all, I don't know if it's like "ok, cool idea, just let's
> do it" or more like "oh no, let's forget this asap") I'd like to start
> the voting tomorrow if there are no further comments on this proposal.
>
On my side, I like the idea but the proposed syntax looks weird.
I would vastly prefer (and upvote) Levi's proposal:
[int $a] = [123]; // note: no brackets, this is a type declaration, not a
casting operation
[string $a] = [123]; // TypeError or implicit cast depending on
declare(strict_types=1/0) in the file
Nicolas