Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129933 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 4D1E51A00BC for ; Mon, 26 Jan 2026 17:50:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1769449814; bh=3vsuf6n34dU1WkyJl55Kq0Xl05UZmVOo7NkguvHzn2o=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=X9sxlI134Vu7kuv08UeTv+yzXFFK6/GDiR3rf2neX+7yjtJtljNJgtk+GyfvQHdcU f4Hhj3awSVp9LaaYfutJbr39vA2uC127kdHXPVIP/oWXJD8a9tlmLiUOiYbcEVqg+N 7h8uzPXtl9tfH9YrxDp9XAuZdunkurIx53kbTj2uu0EN8NNt/nInTYHyn+RUTKW8ZB N9anY36yVior1/PpC6NdXGJGycAB4y5xzRfCcbsauXJ+DfUCkMXKu6FzVNpRduRa7j pQuyVYwd3MPfV8nSTRZ816s3W7HluIjM3WOkcI7VDJVD9oturRelXIfY6+mHIsvnEh 8FlFwxhx0c2Vw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EA3F9180087 for ; Mon, 26 Jan 2026 17:50:10 +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,T_SPF_TEMPERROR autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (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 ; Mon, 26 Jan 2026 17:50:10 +0000 (UTC) Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-89461ccc46eso86845376d6.2 for ; Mon, 26 Jan 2026 09:50:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1769449805; cv=none; d=google.com; s=arc-20240605; b=O7s103ePD5MkJaoqTIYH5VOIu8doLzSpE37poTZ8YeWN9QFY2s4Um1VuKHPqWjsQK5 fOaSIuVrV0c5fQ59OKmlA+SbFv42ZCybHjjQKHYe1qAcNAIeNezKQ68J856Pkvcnyyko KzMC6SnIyOsQfX3fZS+phbuuvsxrQYLWdQa7ZuIBcnEa+SAwdaaTyTYRip9jTt5wHip/ wsRxpxF5ubitXFOkvRZaBO21bV1oWmZmN1MWKAnnR5RAVvIw+42cC+DDRGPsRCdEVNZV SYhx2F789hcT+xJH5noAJushFpOb/FGqC64NqpnzBFKGyhwP2kY6tAHDkf/XNy8+6pFt hqJg== 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=JqGv35sB1Ptkm78S1J0lsHi8Ywrs8wMObot6789DZRQ=; fh=Ofn+XpSLefQyxrNYeqFK5V6BgIEzMTvoqvpJ6/SQfuk=; b=LxfdOHUYZbcHyqob8qX3pu8vU9dWByEngyRXTuDqvEJ16r7GdwJlK0J8AkL5TJSku4 vgr7aUGm1+6nsCpyNOnBfeNEU5IIWW7QVNhIr6+A9sog0WcsNFeZKikOznjECCdTQBZi IerwuzUauQPHJwE83GJZQgzbTTyfa9akDyVdXDB4Nwh6+wmtT7ilr1ycN58grGZYtEW9 YWygRCBXEraI1f1uvIeYTnpO2sDtjQ2GJppHTn8qx9QHh9Ifudbl3Mr+TjGEeGD7o2Hi JIe+ByHVCzRtuBTN5k9Vr2C0wDk8l1q+WwgmH8hQ4Iht4XTyztDtmMCO6PASPA3uxsRs d1Rw==; 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=20230601; t=1769449805; x=1770054605; 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=JqGv35sB1Ptkm78S1J0lsHi8Ywrs8wMObot6789DZRQ=; b=Jlf6hyKbMlmo9de12iiebAWdl5AT87nts0R5tuZ9mzk2iHuTKdRVpYgS1KxdhoAbE6 xKGBQkriT8++50a4YNoY908dQQtbBM6OCW8strnG83nxyl/R+b219znWVZX6IuCW+M1/ CsaL0xTQANsPqbJXqF7BBwtCve/Ygo6q56NSbOYnoFZvAIPSakdgOQn3WYhfa9l9lZcA Udf8pl4roge7UC9z1kafvc8s8IlPj43wX0KYlJqbbguMbx2S5fd4BgmB6sPVZXtO2x0q eO7Ybc0pclTA5CzbPkwz/O91XBVD0UZwb/W+s6NFhr1CIqTRhwqvbvlW6Q7HlntaaVYi Cl4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769449805; x=1770054605; 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=JqGv35sB1Ptkm78S1J0lsHi8Ywrs8wMObot6789DZRQ=; b=rOE4o0yrO3aEp9ERje8vp0f2hdPoQnVR5bDfNaZ2BpRYG7GovJw7BfEI1REMB5qT0N Ag3+zEvimNeNo14mNo7Vh+Emw/uFA8uzGj0Nnjn45qCSkwhuVmgpf37zbdwhqzsflpUU GvsygLK/w/h70OpLvyi53KmSt5a/txVFqDZEO3UpizZP1BSgrHrNaZSFSWXCxNa2DVpB NtiGPcWwIttbBlP2wPYkmmj1Cz2jUNfhdlMckXnDtTxAAle2wLsFcdx65xTVtp7xwiIj FLbxW+4rw2CXLGbMWZ4UcQDkTcjqrG5MxzUCo08NRzi8fnLeertNb+l+Y4o4AsMwwflL xh0Q== X-Gm-Message-State: AOJu0YxHJ3vKyDGB65BIi/fBL+FXL/rK9H25YOqPQeVyImVOoX9ab64i Uo3A+1WJiw+IZ/rEhp+bXU2yeF2bm6Em+SshGxyNuDlfv3Yy5020O/XPd7H6duuRjXMxDoAQUOJ kvs2+SO6UstuTDsYVHNnbVWlDU8DPZjsPBEbn X-Gm-Gg: AZuq6aKtldBUM43G6+na2fyrFmhWzUoOP3lYH48nU0qbp0/XRJKSPSQzbFEkTCr3CRI bTdSpHHg5aeDfrkxu1xgOrmnGgka8vJrZ1DMyDHY/xeqHJ6ZIQ6fN0UCCsZ5d3KPbTrBAQYZGF9 a7NiWm9e7gpytC+0uTp6BJA/SAY+2FUmhBuRZeuLqnw0RmonX4bDUGBloX8dEErul6tyPMMsrbP xsA6BRFeF47siFoVUbj/1SiuEMg8CmCTp1mbbxAWyFwRi4Q4B8ifg/ztC+aN5Bg+J3kNvNLb6Au TnXu++LJ1OKShWf4DfMTEFVfc+Xi1VxdDfveraVfCwfwj9koM5nSVyki X-Received: by 2002:a05:620a:4625:b0:8c6:a585:aa83 with SMTP id af79cd13be357-8c6f95729e8mr672050985a.18.1769449804780; Mon, 26 Jan 2026 09:50:04 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: <077e27345a1f5b7969c114684aede7e8@bastelstu.be> <85e10caa-f577-4f8f-a93d-955348b67013@app.fastmail.com> <1776f008-f444-4952-8f98-3a2693801145@app.fastmail.com> In-Reply-To: <1776f008-f444-4952-8f98-3a2693801145@app.fastmail.com> Date: Mon, 26 Jan 2026 18:49:52 +0100 X-Gm-Features: AZwV_QhZ3Xf321vxPm-LnsETW3C0NcGzxMvqYkMvfvEs9jjE7-_VdF4SOO9P5h0 Message-ID: Subject: Re: [PHP-DEV] [RFC] Allow Reassignment of Promoted Readonly Properties in Constructor To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="0000000000000fd71606494e23ce" From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --0000000000000fd71606494e23ce Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Larry, Le dim. 25 janv. 2026 =C3=A0 19:53, Larry Garfield = a =C3=A9crit : > On Sat, Jan 24, 2026, at 12:09 PM, Nicolas Grekas wrote: > > >> Boring is good in this case. :-) I like the updates. I only have two > remaining quibbles. > >> > >> > All other readonly semantics remain unchanged (no modification > outside constructor, no unsetting, etc.) > >> > >> As previously stated, "no modification outside constructor" is not, an= d > has never been, part of the language semantics of readonly. In fact, the > RFC has been updated now such that updates outside of the constructor are > allowed, provide the constructor is in the call stack. Please remove tha= t > clause, as it is incorrect. > > > > How would you phrase this? > > To me, point 3 above makes this clear: "The reassignment must occur > > while a constructor of the object is on the call stack (methods and > > closures called from the constructor are allowed)" > > Then, point 7: "All other readonly semantics remain unchanged (no > > modification outside constructor, no unsetting, etc.)" has enough > > context to me to be clear. > > > > No? > > There's a very subtle caveat here. Readonly properties that are not yet > initialized can be set from anywhere, not just the constructor. That is > the language semantic, regardless of what the PHPStan/Psalm authors think= . > :-) > > In this particular case, because the property is being set in the > constructor preamble, essentially, it cannot then be re-assigned... EXCEP= T > in the constructor due to this RFC. But that's a subtle, easy to miss > caveat. Hence why I'd prefer wording that doesn't imply (to those that > don't catch that subtlety) that the language doesn't allow readonly to be > assigned outside of the constructor. > > This is a particular pet peeve of mine because I have very good use cases > for assigning to a readonly property outside of the constructor, but alwa= ys > therefore have to disable that check in PHPStan as a result. Hence why I > harp on it so much. :-) I updated the text to make this more clear, thanks for the suggestion! --0000000000000fd71606494e23ce Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Larry,

Le=C2=A0di= m. 25 janv. 2026 =C3=A0=C2=A019:53, Larry Garfield <larry@garfieldtech.com> a =C3=A9crit=C2=A0:
On Sat, Jan 24, 20= 26, at 12:09 PM, Nicolas Grekas wrote:

>> Boring is good in this case. :-)=C2=A0 I like the updates.=C2=A0 I= only have two remaining quibbles.
>>
>> > All other readonly semantics remain unchanged (no modificatio= n outside constructor, no unsetting, etc.)
>>
>> As previously stated, "no modification outside constructor&qu= ot; is not, and has never been, part of the language semantics of readonly.= =C2=A0 In fact, the RFC has been updated now such that updates outside of t= he constructor are allowed, provide the constructor is in the call stack.= =C2=A0 Please remove that clause, as it is incorrect.
>
> How would you phrase this?
> To me, point 3 above makes this clear: "The reassignment must occ= ur
> while a constructor of the object is on the call stack (methods and > closures called from the constructor are allowed)"
> Then, point 7: "All other readonly semantics remain unchanged (no=
> modification outside constructor, no unsetting, etc.)" has enough=
> context to me to be clear.
>
> No?

There's a very subtle caveat here.=C2=A0 Readonly properties that are n= ot yet initialized can be set from anywhere, not just the constructor.=C2= =A0 That is the language semantic, regardless of what the PHPStan/Psalm aut= hors think. :-)

In this particular case, because the property is being set in the construct= or preamble, essentially, it cannot then be re-assigned... EXCEPT in the co= nstructor due to this RFC.=C2=A0 But that's a subtle, easy to miss cave= at.=C2=A0 Hence why I'd prefer wording that doesn't imply (to those= that don't catch that subtlety) that the language doesn't allow re= adonly to be assigned outside of the constructor.

This is a particular pet peeve of mine because I have very good use cases f= or assigning to a readonly property outside of the constructor, but always = therefore have to disable that check in PHPStan as a result.=C2=A0 Hence wh= y I harp on it so much. :-)

=C2=A0I updated= the text to make this more clear, thanks for the suggestion!=C2=A0
--0000000000000fd71606494e23ce--