Re: [RFC] Allow Reassignment of Promoted Readonly Properties in Constructor

From: Date: Thu, 26 Feb 2026 20:04:41 +0000
Subject: Re: [RFC] Allow Reassignment of Promoted Readonly Properties in Constructor
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  Groups: php.internals 
Request: Send a blank email to internals+get-130177@lists.php.net to get a copy of this message
On Tue, Feb 24, 2026, at 4:29 PM, Nicolas Grekas wrote: > Le mar. 24 févr. 2026 à 20:57, Larry Garfield <larry@garfieldtech.com> a écrit : >> On Tue, Feb 24, 2026, at 1:34 PM, Nicolas Grekas wrote: >> >> >> Otherwise, I'm happy with where this ended up. Thanks! >> >> >> > >> > Thanks for having a look! >> > Here is the update: >> > >> > https://wiki.php.net/rfc/promoted_readonly_constructor_reassign?do=diff&rev2%5B0%5D=1771797005&rev2%5B1%5D=1771961558&difftype=sidebyside >> > >> > Cheers, >> > Nicolas >> >> > Property hooks cannot be combined with CPP, so properties must be declared separately >> >> This is untrue. The following code is legal: >> >> class Point { >> public function __construct( >> public float $x = 0.0 { set => abs($value); }, >> public float $y = 0.0 { set => abs($value); }, >> ) {} >> } >> >> The point about readonly is valid, and worth keeping, as is the "affects all >> writes" question, but the code above is possible. >> > > My bad, I should get used to them more :) > > > https://wiki.php.net/rfc/promoted_readonly_constructor_reassign?do=diff&rev2%5B0%5D=1771961558&rev2%5B1%5D=1771972141&difftype=sidebyside Looks good now. Thanks. :-) --Larry Garfield

« previous php.internals (#130177) next »