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

From: Date: Sun, 22 Feb 2026 18:14:50 +0000
Subject: Re: [RFC] Allow Reassignment of Promoted Readonly Properties in Constructor
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.internals 
Request: Send a blank email to internals+get-130128@lists.php.net to get a copy of this message
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. Other than that, I don't have any further comments and I believe everything relevant is mentioned. Personally I'm likely to “Abstain” from the vote for the same reasons that Bob previously mentioned. Best regards Tim Düsterhus

« previous php.internals (#130128) next »