Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129860 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 C66381A00BC for ; Thu, 22 Jan 2026 16:11:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1769098315; bh=AO7p+dRnDDsFWy7EyEtd8aN+OIpEkPOmykErJjiMMzA=; h=Date:From:To:In-Reply-To:References:Subject:From; b=bYj7MApfEHdlMkUbRZyiunoYr5C36TWvtbx7JLFXfbUnsZxEUnzKeNAzM5opI9EGV NGvSWTAUx6eMXEkCiPvqBy6y4H/+XAnA4C2t7zEAzwtb7eWoFCYaCHwXIIspVwB4Sp t7RnTuIV99j4mCFgtohIr47eIa4nr1SjCbjc3a3OfNTyGSLtBPragCuOsnxzXM8W5e B9tJOXcx3DInDwKeI1eY3BlbTQOFSbED0fe+9tR/49DM4l6FZL4gNNY/poDV0HhkqP yy2/BkBtSxDvhtUqrxNcdK32l8fFq+PNnFjHurlz0YLiGP1efa/6lAylseSgsXbIGN +eKmSVT5bQCPg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 00B12180786 for ; Thu, 22 Jan 2026 16:11:53 +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.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from fhigh-b2-smtp.messagingengine.com (fhigh-b2-smtp.messagingengine.com [202.12.124.153]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 22 Jan 2026 16:11:50 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.stl.internal (Postfix) with ESMTP id 61ACF7A00D0 for ; Thu, 22 Jan 2026 11:11:45 -0500 (EST) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-04.internal (MEProxy); Thu, 22 Jan 2026 11:11:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to; s=fm2; t=1769098305; x=1769184705; bh=tv5hCdbQOJnGWOLI3+N7D +EWFDn9iRBV2wfnX1PNPPg=; b=IQd4cnQTUp4Rc6/Zpw47eYHXR8n1SXojaVqwW xm9n3RZFljWvDn5MIVjagQbkP8pCmda2ifWEk4DslDICbuQTQQ4v6FSochK20XY+ 7nOR6Ussv67TOAmTGUCADHuNLuVjJ0gV4TbMK/KRFPc7ts3dpOkYX3jzm9wXm+Yw 9X+lzWqPeQ58UQ/ecDoSgj4oWZGpd9CSmTSIvY2LFCAOtjv8wzesOWhlSC7Yd9xv xbgZEOH0cPi+sQAEz/Q90nB+PRbh1XL4w/t6cUZp8CFAz5SYqQJdNvHp1RzD0jZA KqOpes+ztCuhlyH5iCZuNllynJdwQ6Ca5b9OkiflpNqO+5jKw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1769098305; x=1769184705; bh=t v5hCdbQOJnGWOLI3+N7D+EWFDn9iRBV2wfnX1PNPPg=; b=KbKqIosbIvOVw+typ DGtM+kgvidd9DzAgWQbhZ/AN6uVv5xVx4yqQcfj/JeLtKU7zJizVzH36mv+/teex U5lGo90bo4s08ii3SaKUUjEC8MpjYHtM8knpxU1oi02BWBeU9NXex8t3Y/mNlGDP CSOKzqiT3zYAJ1ioqKMbQUHHfa+vhZRLzH2/5gS2akWOtAY71w1yEwLF9le7jEru E9PjE5TkqWYPAKADvCw2T+3g4nTWwZlIpFpczFNcUPT+M5V1A//Em9ShYZgqxR2z plWm4vArk6O5v1yxGBHfM/q7uiD7WSV9InSapamj6GTL2Fgz2CHC79ysYvQUlojv T8t6w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddugeeiieduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepofggfffhvffkjghfufgtgfesthejredtredttdenucfhrhhomhepfdfnrghrrhih ucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmqe enucggtffrrghtthgvrhhnpeeuvedvudfhffffhfelueehvdejvefgleegteegffetudef leehgeefvdehgeelteenucffohhmrghinhepphhhphdrnhgvthenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghl ughtvggthhdrtghomhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpd hrtghpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 0A20E700065; Thu, 22 Jan 2026 11:11:45 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: ApWOO0YdA2Vg Date: Thu, 22 Jan 2026 10:11:24 -0600 To: "php internals" Message-ID: <2ecdd74b-c86c-402d-b7ff-d20acb5cbe56@app.fastmail.com> In-Reply-To: References: Subject: Re: [PHP-DEV] [RFC] Allow Reassignment of Promoted Readonly Properties in Constructor Content-Type: text/plain Content-Transfer-Encoding: 7bit From: larry@garfieldtech.com ("Larry Garfield") On Thu, Jan 22, 2026, at 9:33 AM, Nicolas Grekas wrote: > Dear all, > > Here is a new RFC for you to consider: > https://wiki.php.net/rfc/promoted_readonly_constructor_reassign > > As a quick intro, my motivation for that RFC is that I find it quite > annoying that readonly properties play badly with CPP (constructor > property promotion). > > Doing simple processing of any argument before assigning it to a > readonly property forces opting out of CPP. > > This RFC would allow setting once a readonly property in the body of a > constructor after the property was previously (and implicitly) set > using CPP. > > This allows keeping property declarations in their compact form while > still enabling validation, normalization, or conditional initialization. > > Cheers, > Nicolas I can see the benefit of this, though I do have some concerns. > The reassignment must occur directly in the constructor body of the declaring class (not via method calls, closures, or other indirect means) This could be an issue. I understand the argument for it, but for objects designed to be both constructed directly and deserialized the constructor may not always be called. A common solution is to move the shared logic out to a private method, say validate(), and then call validate() from both __construct() and __unserialize() (or the equivalent for a particular serializer). That would no longer be possible with this limitation, thus requiring duplication of code. > Child classes cannot reassign parent's promoted readonly properties Why? > All other readonly semantics remain unchanged (no modification outside constructor, no unsetting, etc.) The "no modification outside constructor" *is not part of the language semantics*. It is a recommended practice invented by SA tools. I also share Derick's disdain for code produced by Grand Theft Autocomplete, and the legal risks therein. --Larry Garfield