Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128682 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 017E51A00BC for ; Fri, 12 Sep 2025 14:21:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1757686787; bh=2gVtc+IvTwxpcswNBKgEfTqRaT1PZH5lXj4cVHeqFzc=; h=References:In-Reply-To:From:Date:Subject:To:From; b=FZCiz80oclSPDfn9ifUuP7OEOZirL54LtlxX/UzrJtq1ujg+q+bZ223AGgx3Bbf0A X3XC/SLfD3azuaXcPsbXLXfxShU+XeHDtzqZT1+cBCa/w1rz66swCCdyhHKfVzUKV5 uVGKJwNRHCkdDe1d9vCAX5obTWTgkMKCmlypFh9V4R0pft3oFNoG+0SqyKnxOwxVUw XfaLXFeo413Og2MRRNGeSnBG41Vcx0EAtBJKkCDxu3hh2BebsZo6op6PIU3+1Yxei4 knO1ZWh1hMl7vI/Am/CCaThEP2xPLXD8lUHaTkHgsmk9EcKIXpZ/2QhkLqe5CdAQlz MoEuWUV8dfGyQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 50ADE180078 for ; Fri, 12 Sep 2025 14:19:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 12 Sep 2025 14:19:41 +0000 (UTC) Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-4b494e774bfso6466861cf.3 for ; Fri, 12 Sep 2025 07:21:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757686867; x=1758291667; darn=lists.php.net; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=urXbSVmrdrP2OLf94yHnFr2xPfrFQxutVoj27yim24I=; b=HClmECQspQBQOU1MY8OTevd3POhGLZ254mE+4rp5+vonKIR85yh1pKdZxx/Mn2pMrJ tLzVYPQDNZAObcg7zkglRHM8tdJE1l7qkitT9RAkS5QtNhjeCt1lAy+60f3qXzn02ELC AcRCU3UeCJ6yaXas05Ccj+jr+OoQAWrgeumkKlK2ec3gKQNMzckKjQBYRg+9Bs8YPNwy Tki/YjAfo5ceSrEbedo+y48G2rEbLSfUtO3Ghb6saPKL+tbxieykiWVKl1bL7uGFnXYg NKTZz0kivn+qyuKet8+DOy2k0xWbgOAvG9yJbO938wrBPGNWbPs7CDV/ftWbtsXfaiJS KlPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757686867; x=1758291667; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=urXbSVmrdrP2OLf94yHnFr2xPfrFQxutVoj27yim24I=; b=X82PEnYQYXOYMFCgdr80Yj7sVa+K4HAj5gs+r8z8kbjM21ygJuDvUsfwqr2eoUuFj+ Ag13lZMh4Z9l2xMG+HYajmldevc3+MPY4BJjpc2hAW+G7THPBaQ+HK6DpKf1hHJ0wE2o rt5dmr8mJGp2ejG9EM/XPzIOz8lf6g3OVLoL26rD5LOpgWPDFR8rISkG5k7Vi33uoQkZ eSb+C6PagOTX8r5bX/xEa6x35Q9V1bKXBf4ddx95ie7GvukYFgPF7DguMDlgVXdTs2e5 Rw6N5VQjykWO9EjdcGWbhUHARzuqqpRwyZFrWciYMuZIZwsIP7Ha0z5mVs5AhXsqqq70 TxOA== X-Gm-Message-State: AOJu0Yw11NmXCVVp6uuepn21RhXK4wi8blcfs0XfqYMvUZAPsMejuKn8 rwR0aPE/SQOa7NsozydMV4pmBjeOSLrxrIPc0y3+D40SyqsWGvKDVXvJD6i43OBj5+sSUtP5W6p LUnzmyZe/NUajRTgdXE80AAD5bKbI4T/x1Ilg X-Gm-Gg: ASbGncvNQKgrgmmGhwtDfLrutR1gBsI9t8aI6XZUkXxUpOebO0+hp8exnfLVO4yX7q/ kd1SnqB6V1YF853s92alO+l/XHC9fo7aN9RtpPSwl3m0cH/by/l3Xhl+JEybbq8eioqOW4W9QTM ekn3FzWWabzgPZBqysTlUyWBrvhZMz/DBtEKH7JqZN8caFNm6sIBMvhzI7yj/IbBtXJXl0DwmJi Y08JB2V7uZfPSTKhbOZAfqCM1w7eQgrB2f5pdm1Nm85zYHu X-Google-Smtp-Source: AGHT+IHfAaok/E8Tr4dQIHGUwM2zQhJTDZ7ZpF2aD0WGBT0w3cacltirGZenJxGjlDvRR3xxxOb2Z7H43mGBsCGWrgA= X-Received: by 2002:a05:622a:1455:b0:4b5:e9b6:c9f with SMTP id d75a77b69052e-4b77cfb686dmr28156291cf.2.1757686866872; Fri, 12 Sep 2025 07:21:06 -0700 (PDT) Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 12 Sep 2025 16:20:54 +0200 X-Gm-Features: Ac12FXwtZMhAnYA2uVE73oYtuVf--yZMo1BE-0qnbq7KOWsNiqDud6Qr0Rww2ME Message-ID: Subject: [PHP-DEV] Re: [RFC proposal] Syntactic sugar for array push() To: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000538c77063e9b5db5" From: dusankrehel@gmail.com (=?UTF-8?B?RHXFoWFuIEtyZWhlxL4=?=) --000000000000538c77063e9b5db5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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: nap= =C3=ADsal(a): > A proposal to add syntactic sugar for array_push() in PHP. > > Syntax: > // now > array_push($array, 1); > > // new syntax > $array[+]=3D1; > > Du=C5=A1an Krehe=C4=BE > > --000000000000538c77063e9b5db5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
arr= ay_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=3D[3];
$a[+]=3D2;

// PHP Parse error: =C2=A0syntax error, unexpected token "]&qu= ot; in=C2=A0=E2=80=A6 o= n line 3


pi 12. 9. 2025 o=C2=A012:19 Du=C5=A1an Krehe=C4=BE <= dusankrehel@gmail.com> nap= =C3=ADsal(a):
A pro= posal to add syntactic sugar for array_push() in PHP.

Syntax:
// now
array_push($array, 1);

// new syntax
$array[+]=3D1;

Du=C5=A1an Krehe=C4=BE

--000000000000538c77063e9b5db5--