Re: [RFC proposal] Syntactic sugar for array push()
| From: | Dušan Kreheľ | Date: | Fri, 12 Sep 2025 14:20:54 +0000 |
| Subject: | Re: [RFC proposal] Syntactic sugar for array push() | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-128682@lists.php.net to get a copy of this message | ||
array_push would only be used if there were a [-] in the code, i.e. a
hyphen (or plus for pop()) as pseudo-constant.
Practically, it would change today's behavior that returns an error into a
correct operation:
<?php
$a=[3];
$a[+]=2;
// PHP Parse error: syntax error, unexpected token "]" in … on line 3
pi 12. 9. 2025 o 12:19 Dušan Kreheľ <dusankrehel@gmail.com> napísal(a):
> A proposal to add syntactic sugar for array_push() in PHP.
>
> Syntax:
> // now
> array_push($array, 1);
>
> // new syntax
> $array[+]=1;
>
> Dušan Kreheľ
>
>