Re: [RFC] Allow Reassignment of Promoted Readonly Properties in Constructor
| From: | Nicolas Grekas | Date: | Mon, 23 Feb 2026 07:49:34 +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 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-130131@lists.php.net to get a copy of this message | ||
Le dim. 22 févr. 2026 à 19:14, Tim Düsterhus <tim@bastelstu.be> a écrit :
> Hi
>
> On 2/19/26 10:49, Nicolas Grekas wrote:
> > Thanks, I've added new test cases to cover this.
> > I've also improved tests as suggested on the PR.
> > And finally I updated the implementation to reuse IS_PROP_REINITABLE
> > instead of adding new flags + use an approach that doesn't require
> walking
> > the call stack.
> > PR and RFC updated accordingly, all green.
>
> Thank you. The implementation looks much simpler now and the tests all
> make sense to me and I can't think of any other relevant “edge case”.
>
> I have one more comment regarding the RFC text, which should result in
> “minor” changes as per the policy of making clarifying changes:
>
> 1. “Set in child before parent::__construct()” also fails, since the
> property slot is not yet initialized:
>
> That explanation and example does not seem to be quite correct: It's not
> the
$this->x = 'C'; assignment that fails,
> it's the implicit CPP
> assignment when calling parent::__construct(). The explanation should be
> fixed and the // Error: Cannot modify readonly property P::$x
> comment
> should be moved to the parent::__construct() call.
>
> The test in the implementation was already correct.
>
>
Hi Tim,
Good catch thanks, wording updated!
The RFC is ready then. Any other comments from anyone else?
Nicolas