Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129989 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 C8E441A00BC for ; Tue, 3 Feb 2026 09:00:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1770109234; bh=5RNXgdnMghB2ShNSa0PcW2Ry099J8zp42zcO56v0gx0=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=a2Z6nYKo6OwE1i0WR/aX919iMqH8atexmjUj9Aqh4nGxcZGJtp+0OF6HuO2tc3+v8 oopM1FHmkFY2jwu1Z340wN+LbHrw5p8CMDPOzgtHEZXj2lY5zFiIUlylpclymLjXj7 kJmYjF5s81hl5RqdPBwKEZpAu7d2+uZY44qWRO1q9i8D/Xxec7tB6b0p0bwH56R9yL Jx9+1UTn29GPY8Y6Sps9a0OzrIkaDps6YU1KlRTBgKHZDdKzlQHJXGuES6iDiWWvjY PczRsuJTpBzIGEBD2bI5LyVrVkY1R2rIeWEVv69d/rKsIfAKlut+xJOaN1M4IIqvDo DSS7Gn52i2iyw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C9988180883 for ; Tue, 3 Feb 2026 09:00:30 +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,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from fout-b3-smtp.messagingengine.com (fout-b3-smtp.messagingengine.com [202.12.124.146]) (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 ; Tue, 3 Feb 2026 09:00:28 +0000 (UTC) Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfout.stl.internal (Postfix) with ESMTP id B00811D00095; Tue, 3 Feb 2026 04:00:23 -0500 (EST) Received: from phl-imap-05 ([10.202.2.95]) by phl-compute-12.internal (MEProxy); Tue, 03 Feb 2026 04:00:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:cc: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=fm1; t=1770109223; x= 1770195623; bh=5RNXgdnMghB2ShNSa0PcW2Ry099J8zp42zcO56v0gx0=; b=k IqmZP3/74AwF6zD+omLhJ8oGOjq2RHDP/lQKwVJd7HPFP2XIT80nmAXizP31idvg iH+GOwlMxaspNlDYNBLYHCrQtenBiPvcQ19ahfczDSo2crxEzpszto0Aao77PyWR DI/5wApreaF+EMk6YxPvSSEM7LUDt1393W4eyMu5Br5O/fqsdqDhFWLM9/xc0kCE +S6c+LJ67QusgeaGaT1WnSS5xSf7fVGWcdLSx5atCh2iUKehRWHrIfpbTn7Q2E1R FedTjDPllx/BuoP6t8NKPHAbR+rHJuOvIogSXmN3iYkWLOPL4zQTGlxkq/MDN4tf KY2o5ITTzZ2zNos2k5N1Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc: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=fm3; t= 1770109223; x=1770195623; bh=5RNXgdnMghB2ShNSa0PcW2Ry099J8zp42zc O56v0gx0=; b=qOuLXNdvNxW7VzDOJ2zCdlnERp9ENFKZJqxO2cPIbVIlDMAVRyb mQEIHzfYjqHR6KksIJWTg6axsbP9qAZImPV8QKOgDRiJM/+tR7TgjrQxGdWoOx+1 SYiNeaT6zTGIAaht786hqUa9d4gwl0eVOVZV7416/bJlizCCaFBqqnu6xfcBd1aL kTtidIcLUf+LkflPaU66b5m3Itib0L2svuCuILvZ9Qn/t/ojYLqnZvcoEwkCrDD7 f5BrtGs8CotiGB8Sy84IcYfZ/yHPh/tZbrgTHkT9v60ER3RMB8ArWQ0SQ7rSPgjd a3lJptuqjoqXN5sp8FrnkkCLUoOnYeOFW5g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddujeelleeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepofggfffhvfevkfgjfhfutgesrgdtreerredtjeenucfhrhhomhepfdftohgsucfn rghnuggvrhhsfdcuoehrohgssegsohhtthhlvggurdgtohguvghsqeenucggtffrrghtth gvrhhnpeffgeevveegtdffgfffvdfftddvheeuleegveekteffueeliedtgeekjeettdet keenucffohhmrghinhepphhhphdrnhgvthenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehrohgssegsohhtthhlvggurdgtohguvghspdhnsggp rhgtphhtthhopedvpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehnihgtohhlrg hsrdhgrhgvkhgrshdophhhphesghhmrghilhdrtghomhdprhgtphhtthhopehinhhtvghr nhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 5B41E1820082; Tue, 3 Feb 2026 04:00:23 -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: AZ7fesbM8yI- Date: Tue, 03 Feb 2026 10:00:03 +0100 To: "Nicolas Grekas" Cc: "PHP Internals List" Message-ID: <585bfc82-a522-43ec-be42-b8945952fe8b@app.fastmail.com> In-Reply-To: References: <4b74f9a1-96d2-4104-abdd-fe56c5e7016c@app.fastmail.com> Subject: Re: [PHP-DEV] [RFC] Allow Reassignment of Promoted Readonly Properties in Constructor Content-Type: multipart/alternative; boundary=ed867ea2001f407cab0d25d0136cea69 From: rob@bottled.codes ("Rob Landers") --ed867ea2001f407cab0d25d0136cea69 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Tue, Feb 3, 2026, at 09:56, Nicolas Grekas wrote: > Hi Rob, >=20 > Le mar. 3 f=C3=A9vr. 2026 =C3=A0 09:50, Rob Landers a =C3=A9crit : >> __ >> On Mon, Feb 2, 2026, at 22:14, Nicolas Grekas wrote: >>> Hi Marco, >>>=20 >>> Le lun. 2 f=C3=A9vr. 2026 =C3=A0 11:54, Marco Pivetta a =C3=A9crit : >>>> Hey Nicolas, >>>>=20 >>>>=20 >>>> On Thu, 22 Jan 2026 at 16:34, Nicolas Grekas > wrote: >>>>> Dear all, >>>>>=20 >>>>> Here is a new RFC for you to consider: >>>>> https://wiki.php.net/rfc/promoted_readonly_constructor_reassign >>>>=20 >>>>=20 >>>> What happens if one calls `$obj->__construct(1, 2, 3)` (on an alrea= dy instantiated `$obj`) in the context of this patch? >>>=20 >>> Thanks for asking, I didn't think about this. This made me also thin= k about ReflectionClass::newInstanceWithoutConstructor(). >>> I clarified this in the RFC, see "Direct __construct() Calls Cannot = Bypass Readonly" and "Reflection: Objects Created Without Constructor". >>> Patch and PR updated also if anyone wants to run some code where thi= s RFC can be played with. >>>=20 >>> Cheers, >>> Nicolas >>=20 >> Hi Nicolas, >>=20 >> Under "Child Classes Can Reassign Parent Properties": this feels like= a major footgun. Calling parent::__construct() won't allow a reset (per= the rules of calling a constructor directly); which would completely br= eak inheritance... but then in the examples it says that calling a const= ructor directly can reset it -- but you can't? >>=20 >> This feels really inconsistent to me. >>=20 >> =E2=80=94 Rob >=20 > Yes, the text was ambiguous. The implementation allows parent::__const= ruct() during the initial construction (normal inheritance), and only bl= ocks explicit __construct() calls after construction completed. I=E2=80=99= ve clarified this in the RFC. >=20 > Nicolas Will this result in a catchable error? I assume so, so a valid pattern d= uring inheritance might be to put these in a try/catch so children can s= et them first? FWIW, in my Records RFC, properties were fully mutable during constructi= on for exactly this reason.=20 =E2=80=94 Rob --ed867ea2001f407cab0d25d0136cea69 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Tue, Feb = 3, 2026, at 09:56, Nicolas Grekas wrote:
Hi Rob,

Le mar. 3 f=C3=A9vr. 2026 =C3=A0=  09:50, Rob Landers <rob@bottled.codes> a =C3=A9crit :

On Mon, Feb 2, 2026, at 22:14, Nicol= as Grekas wrote:
Hi Marco,

Le lun. 2 f=C3=A9vr. 2026 =C3=A0 11:54= , Marco Pivetta <ocramius@gmail.com> a =C3=A9crit :
He= y Nicolas,


On Thu, 22 Jan 2026 at 16:34, Nicolas Grekas <nicolas.grekas+php@gmail.= com> wrote:
<= div dir=3D"ltr">
Dear all,

Here is a n= ew RFC for you to consider:


What happens if one call= s `$obj->__construct(1, 2, 3)` (on an already instantiated `$obj`) in= the context of this patch?
Thanks for asking, I didn't think about this. This made me a= lso think about ReflectionClass::newInstanceWithoutConstructor().
<= div>I clarified this in the RFC, see "Direct __construct() Calls Cannot = Bypass Readonly" and "Reflection: Objects Created Without Constructor".<= /div>
Patch and PR updated also if anyone wants to run some code whe= re this RFC can be played with.

Cheers,
Nicolas

Hi Nicolas,=

Under "Child Classes Can Reassign Parent Prope= rties": this feels like a major footgun. Calling parent::__construct() w= on't allow a reset (per the rules of calling a constructor directly); wh= ich would completely break inheritance... but then in the examples it sa= ys that calling a constructor directly can reset it -- but you can't?

This feels really inconsistent to me.
<= br>
=E2=80=94 Rob<= /div>

Yes, the text was ambiguous.= The implementation allows parent::__construct() during the initial cons= truction (normal inheritance), and only blocks explicit __construct() ca= lls after construction completed. I=E2=80=99ve clarified this in the RFC= .

Nicolas
Will this result in a catchable error? I assume so, so a va= lid pattern during inheritance might be to put these in a try/catch so c= hildren can set them first?

FWIW, in my Records= RFC, properties were fully mutable during construction for exactly this= reason. 

=E2=80=94 Ro= b
--ed867ea2001f407cab0d25d0136cea69--