Skip to content

[RFC] Extend #[\Override] to target properties #19061

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

Merged
merged 10 commits into from
Aug 12, 2025

Conversation

jiripudil
Copy link
Contributor

@jiripudil
Copy link
Contributor Author

Thanks for looking over this. I think I've addressed all the comments, please let me know if there's anything else. The RFC has been approved, so if the PR looks ok as is, I'll rebase the branch and regenerate the conflicting arginfo.

@TimWolla
Copy link
Member

@jiripudil Thank you. I've updated the PR to the latest master, fixed the conflict and added 52af261 to make the loop more robust when adding additional checks after the hook checks.

@TimWolla TimWolla requested a review from iluuu1994 August 11, 2025 12:55
Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @jiripudil!

zend_attribute *override_attribute = zend_get_attribute_str(prop->attributes, "override", sizeof("override")-1);
if (override_attribute) {
prop->flags |= ZEND_ACC_OVERRIDE;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side-note: In the long term, I would prefer if zend_internal_attribute.validator would add these flags. I'm not sure this is currently possible, because validator doesn't receive the original target, but just the ce. This would also work automatically for internal classes.

Regardless, that can be done in a second step. Also means a small BC break for validator.

@@ -2316,6 +2318,7 @@ static void zend_do_implement_interfaces(zend_class_entry *ce, zend_class_entry
void zend_inheritance_check_override(const zend_class_entry *ce)
{
zend_function *f;
zend_property_info *prop;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please declare new variables inline.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I stumbled upon this as well, but thought I'd not comment on it for consistency. I'll fix both of them when preparing the PR for the merge.

@TimWolla TimWolla merged commit 38beb44 into php:master Aug 12, 2025
9 checks passed
@TimWolla
Copy link
Member

@jiripudil Now merged, thank you. Don't forget to adjust the RFC status / move it to the correct section.

@jiripudil
Copy link
Contributor Author

Will do, thank you!

@jiripudil jiripudil deleted the override-property branch August 12, 2025 13:25
DanielEScherzer added a commit to DanielEScherzer/php-src that referenced this pull request Aug 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants