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

From: Date: Tue, 24 Feb 2026 19:52:23 +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  Groups: php.internals 
Request: Send a blank email to internals+get-130160@lists.php.net to get a copy of this message
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. --Larry Garfield

« previous php.internals (#130160) next »