-
Notifications
You must be signed in to change notification settings - Fork 8k
Allow readonly properties to be reinitialized once during cloning #10389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
01f03db to
d88f16b
Compare
d88f16b to
d6bbf1a
Compare
iluuu1994
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm only halfway through the review, the rest will follow 🙂
d6bbf1a to
1aa6fe5
Compare
|
I rebased to current master + pushed a new commit fixing some of the review comments |
c10c4cd to
75d4d9d
Compare
iluuu1994
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
| variable_ptr = &EG(error_zval); | ||
| goto exit; | ||
| } | ||
| if (UNEXPECTED(prop_info->flags & ZEND_ACC_READONLY)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized that this is actually wrong. if (UNEXPECTED(prop_info->flags & ZEND_ACC_READONLY)) { should be done before zend_verify_property_type, because otherwise side-effects like __toString() will run even if the property cannot be assigned. Z_PROP_FLAG_P(variable_ptr) &= ~IS_PROP_REINITABLE; however should be run after. @kocsismate Can you adjust that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iluuu1994 Yes, sure. I actually had the very same implementation initially for a few minutes, just to switch it to the current implementation. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a test should be simple enough. Create a class with __toString and assign to a readonly property that's already initialized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I have already created a similar test case locally :)
RFC: https://wiki.php.net/rfc/readonly_amendments
Split from #9497