Re: [VOTE] Allow Reassignment of Promoted Readonly Properties in Constructor
| From: | Michał Marcin Brzuchalski | Date: | Tue, 24 Mar 2026 14:06:53 +0000 |
| Subject: | Re: [VOTE] Allow Reassignment of Promoted Readonly Properties in Constructor | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-130431@lists.php.net to get a copy of this message | ||
Hi,
I also voted “no”, for essentially the same reason as Ilija..
To me, this is the wrong use case for readonly. If a property is expected
to change during construction, then initializing it as readonly and later
reassigning it feels like it weakens the semantics instead of clarifying
them.
One of the main values of readonly is that it communicates a very simple
rule: once initialized, the property does not change. Introducing
exceptions around constructor promotion makes that model harder to reason
about, while the language already has alternatives for cases where
controlled local mutability is needed.
So while I understand the motivation behind the RFC, I think this moves
readonly further toward special-case behavior, when it would be better to
keep it strict and predictable.
Kind regards,
--
Michał Marcin Brzuchalski
pon., 23 mar 2026 o 16:40 Nicolas Grekas <nicolas.grekas+php@gmail.com>
napisał(a):
> Dear internals,
>
> It's now time to open the vote for the following RFC:
> https://wiki.php.net/rfc/promoted_readonly_constructor_reassign
>
> The vote will close on 2026-04-07 at 16:00 UTC.
>
> Cheers,
> Nicolas
>