Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130557 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 16CDB1A00BC for ; Sat, 4 Apr 2026 00:52:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1775263975; bh=09HGfyaN7p1CacgiiB3m8lfQ/VCvIghwWm2tLj1Ufe4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=UWMALvVoU5LJT5FXn4Z7XB/K/wcGbZtSO2hvMXFv8LdCkaRiCEDOK78fTAjhB7EQb ca9wOqTZB7Wzutgmn6lDPniiw8z3RVKjoC6EgbblgktKsCNCy1fv8Pv8eMjI8YcT64 2kgNnFYhibg/Lv4PCwsnehOU5X5UGi2QnMGy0+xFX19/CNNPgHvvRms7qLTJVOCf4G 1Jk6XoUG6JrTPTeHvILw4qvtbcGZJC3iqjqHqex0V5GSu7+lf28gYNFHIFCf/cKiUm CdFg7lWhP6J7e0uoKj2YSWyZZUmW9NggDDA+STtT3bXtKVFNv0mULyrCFTz3va71dm gTQ1642riH3iQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DED7B18006E for ; Sat, 4 Apr 2026 00:52:54 +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=ARC_SIGNED,ARC_VALID,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-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) (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 ; Sat, 4 Apr 2026 00:52:51 +0000 (UTC) Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-8a56ca653ceso24136276d6.2 for ; Fri, 03 Apr 2026 17:52:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775263965; cv=none; d=google.com; s=arc-20240605; b=bRvUCzksopCgde8/qQVnHuBCa7ewMN7k/AUghk1Qs7guiYwyP1SNd31dvAEcJ4BST7 bTqhdDeTj45UdjL4X1FGI2Os2EIN64Z7IBWPkMlVbX4E8ufwpTwYG4LpJqaZFkobGFOZ IFhntPjY25YMFMZYBcrFdRCr9oQ0fT2EuL+nhWZX4rYv5xh4dSruSvzWe9hi5IuiQ09Z BXniGPv5x9i5AUzBdFWxGaiW9z1EPivpA/0MFZiMkz/EnHU89Aw59iGgi5y601G/hsFQ DQZX67t9OvdpScccPZmstk83cSWs0Cxlz1iR3d2MGOYNeMegWofKvgDOw3GBz7qks+pe QVyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=dqPfGMg3vCFERD4dIi+oFA45ZA6z+Yqj4yDtNYMGExw=; fh=E9j2+tjlTIty3FcToH6Xjp3plaG49hRIf5uYPlZVs2I=; b=fRFCwnf3YbDOq7B+vMz9SzYo2pPnncsLF7wn8WIP0W/tzE1b5u9Gfm/R+S9T3ocwj1 I0JvK8XZRtB5IrdP7kajCJJTWmIBDuWOAlX2J9ksFhfuMsKonZIL9GBR/VN2bb+Qx4TT DMJePx2rNNuZnWSwW5C2RnbJs8FhZfn56xwatKSsNzK+RUPG2KucOM8lDTq0GHXGyDby vG7QVb8VQwacwyipZ29VFUDXYrW/RS60vKCuiFFEakJ24VIkMKsUPtM5hv7R6QmY1l/d k6nkZk5QdziWygdyUu3Crba58ROuuDtrtBzQjeD0Y681H4dTmT2ogm5aBFr+LnW2jg/Y wbDw==; darn=lists.php.net ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775263965; x=1775868765; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=dqPfGMg3vCFERD4dIi+oFA45ZA6z+Yqj4yDtNYMGExw=; b=Mo2j+4obfd8gznpey+BZ2bh7croV6iKcOSi+Y94sbFQxoVW3fu9YXgk7VEqs5iLivS 4pkqxt6kpHJsps+7QLexVdz0gX80vl3Ct97gdaCtBUQPkDdDxuOB7mby0h5Z4yIa+nKR oK7jqdo653mEBGE+rUjM0jWFqlLjM+FZUbfdqDSU3ED2y2nJCjeUQebQleOWAy2KTYVk KLb1wPqB03xygNvoa4NJa31KVw1vui/bX7svrO6QlD5AblzdtE7/JDPRhZ8Jbtd8Nfja OT7zSdWmWsc0W7Y7qUPdPPv8+JlcqkrPSu6tQIF3PkOBEDY+tAdQFxRGmgbrax2rKZLg 2Ddg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775263965; x=1775868765; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=dqPfGMg3vCFERD4dIi+oFA45ZA6z+Yqj4yDtNYMGExw=; b=UANgVjzc7PvJWw/yQN50a8r9FoETuNf+/AD4FIUMPhFeC+gHkHMqjxPqDae5onvi/u 4nnH4U2C/2sVrP+/eRU5fsEjpI5iZTN3wV6jdL3aTixmSvrSlKN+XeS/jNOn0jWeXmI4 ZU+Mk59s6CIRTOGY6T5bg2O4B7uxbfq3aiWLUZn3lB7jXikLMMX0tsZrF7B+GW3kUlUH hydJw3iUi6REaCbhfoRDXLllhL74GRB6E1FUDXV7BwZ0tY+d8EyQ1z/38nc/SM5O7wBN fbJ+hoz7skGLgDNb17JafwiawYG8+enJVTlmb/oCirtA7tjeqFLQl5Hv5fjWLzcPezpv sQNg== X-Forwarded-Encrypted: i=1; AJvYcCVO/wx0Zo77fZgKpuIzBCvYM2UKIZoltHkuDjeKJoImL0wY7wqTgHuI/vnXvPylIyZ/3WLNF0mRHn4=@lists.php.net X-Gm-Message-State: AOJu0YzRtAiQqnOW1oAgE+QSWc3/lbTrXnPVbMSGIS7CFObqk43b1Zkw vj5C2l0tW3d84zrcaCP51GFGUBx/gcM7G45AEf7zkZJLu6Q7U48Yi/YQXct35qqHFIC4w0pWLOM Knc29OxyqbXl9Lw7A7MVJBejFqTH0Zgw= X-Gm-Gg: AeBDietZr91CpL4IjMZxfC3B/K74pm+Wei6QbUUzjJ2yoCktUNfw6cl38UiCtVm4X1w kKTO5suFwJ9bWp1Ly5J0Sup82gP7aW2/MYwr8A/MjrMObPoWth2Q66orpUC/fswjW6sxta48pui i6E48h+gedcKdzY1FofgHifzADwZK+dyNnxOHOTg5fhzRSowYcE00J/2OaQaKXSdz1WcZlUlgnP yPGw2j0AD/hCZgVvL66tgr1wqeBmLPlO+cHMR2W2Sl1HfmWGljsWw3ckJF6SupD5RM5QTyeYbRY GiMx3lmH4Ybjadp8PtViPmoCO4fxJ9nBH3YAiS4Mqy+AvjH99A== X-Received: by 2002:a05:6214:4114:b0:89f:2ae0:3a02 with SMTP id 6a1803df08f44-8a7028a9743mr83950226d6.19.1775263965417; Fri, 03 Apr 2026 17:52:45 -0700 (PDT) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: <433cf40fdc4a5459b9b87e966f02a96f@bastelstu.be> In-Reply-To: <433cf40fdc4a5459b9b87e966f02a96f@bastelstu.be> Date: Sat, 4 Apr 2026 02:52:34 +0200 X-Gm-Features: AQROBzDIRgv71uiUGEXrjvoC-EztQk_N-0LHMoNJBsKOoaPUOQCmobZ9oju882c Message-ID: Subject: Re: [PHP-DEV] [php-src] PR #20903: GH-10497 (const obj->prop write) - language change notes To: =?UTF-8?Q?Tim_D=C3=BCsterhus?= Cc: Ilija Tovilo , PHP internals Content-Type: multipart/alternative; boundary="0000000000000a93a5064e97dadc" From: khaledalam.net@gmail.com (Khaled Alam) --0000000000000a93a5064e97dadc Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi internals, I'd like to bring attention back to this RFC, which has been updated to v0.2 based on prior feedback: https://wiki.php.net/rfc/const_object_property_write Summary: This RFC proposes allowing property write operations (->) on objects referenced by constants. Currently, CONST_OBJ->prop =3D value produces "Cannot use temporary expression in writ= e context", even though the operation mutates the object, not the constant binding. What changed since the initial discussion (Jan 2026): - Addressed Tim D=C3=BCsterhus's and Ilija Tovilo's feedback regarding arra= y constant dim writes. The RFC now explicitly scopes out dim/array writes and documents the "silent no-op" concern in a dedicated section. A future RFC can address whether ASSIGN_DIM on non-pointer OP1 should warn/throw =E2=80=94 = this is acknowledged as a valid but distinct issue. - Added by-reference passing support (BP_VAR_FUNC_ARG path), with tests. - Added guardrail tests confirming that dim writes on constants, dim writes on constant objects, and constant rebinding all remain unchanged. - Updated the gh12102_3.phpt test: passing an array constant element by-ref now correctly throws an Error instead of silently operating on a temporary copy. PR: https://github.com/php/php-src/pull/20903 I'd appreciate any feedback before moving this to a formal vote. Best regards, __ *Khaled Alam* On Thu, Jan 22, 2026 at 10:33=E2=80=AFAM Tim D=C3=BCsterhus wrote: > Hi > > Am 2026-01-22 00:33, schrieb Ilija Tovilo: > > No strong opinions on my part, but I'd like to point out that similar > > situations already exist. > > > > https://3v4l.org/ARMMS#v8.4.14 > > > > const C =3D [1, 2, 3]; > > function foo(): array { > > return C; > > } > > foo()[] =3D 4; > > var_dump(C); > > > > PHP will happily duplicate the array returned from foo() to append 4, > > without warning. The original array in C remains unmodified. It might > > I'm aware. However to me this situation is a little different, > intuition-wise: A return value already looks and feels like a temporary > value to me (unless a by-ref return is used, of course, but those are > rare). An access on a const does not. > > > make sense for ASSIGN_DIM to warn/throw if OP1 is not a "pointer" > > (indirect, reference or object), as then the operation will never have > > an effect. But it seems to me this is a distinct issue. > > That makes sense to me and IMO is a necessary precursor for this. > > Best regards > Tim D=C3=BCsterhus > --0000000000000a93a5064e97dadc Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi internals,

I'd like t= o bring attention back to this RFC, which has been updated to v0.2 based on= prior feedback:

https://wiki.php.net/rfc/const_object_property_write
<= br>Summary: This RFC proposes allowing property write operations (->) on= objects referenced by constants. Currently,
CONST_OBJ->prop =3D valu= e produces "Cannot use temporary expression in write context", ev= en though the operation
mutates the object, not the constant binding.
What changed since the initial discussion (Jan 2026):

- Address= ed Tim D=C3=BCsterhus's and Ilija Tovilo's feedback regarding array= constant dim writes. The RFC now explicitly
=C2=A0scopes out dim/array = writes and documents the "silent no-op" concern in a dedicated se= ction. A future RFC can
=C2=A0address whether ASSIGN_DIM on non-pointer = OP1 should warn/throw =E2=80=94 this is acknowledged as a valid but distinc= t
=C2=A0issue.
- Added by-reference passing support (BP_VAR_FUNC_ARG = path), with tests.
- Added guardrail tests confirming that dim writes on= constants, dim writes on constant objects, and constant
=C2=A0rebinding= all remain unchanged.
- Updated the gh12102_3.phpt test: passing an arr= ay constant element by-ref now correctly throws an Error instead of
=C2= =A0silently operating on a temporary copy.

PR: https://github.com/php/php-src/pull/20903<= /a>

I'd appreciate any feedback before moving this to a formal v= ote.

Best regards,

Hi

Am 2026-01-22 00:33, schrieb Ilija Tovilo:
> No strong opinions on my part, but I'd like to point out that simi= lar
> situations already exist.
>
> https://3v4l.org/ARMMS#v8.4.14
>
>=C2=A0 =C2=A0 =C2=A0const C =3D [1, 2, 3];
>=C2=A0 =C2=A0 =C2=A0function foo(): array {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return C;
>=C2=A0 =C2=A0 =C2=A0}
>=C2=A0 =C2=A0 =C2=A0foo()[] =3D 4;
>=C2=A0 =C2=A0 =C2=A0var_dump(C);
>
> PHP will happily duplicate the array returned from foo() to append 4,<= br> > without warning. The original array in C remains unmodified. It might<= br>
I'm aware. However to me this situation is a little different,
intuition-wise: A return value already looks and feels like a temporary value to me (unless a by-ref return is used, of course, but those are
rare). An access on a const does not.

> make sense for ASSIGN_DIM to warn/throw if OP1 is not a "pointer&= quot;
> (indirect, reference or object), as then the operation will never have=
> an effect. But it seems to me this is a distinct issue.

That makes sense to me and IMO is a necessary precursor for this.

Best regards
Tim D=C3=BCsterhus
--0000000000000a93a5064e97dadc--