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
#[Override] attribute in trait does not check for parent class implementations #12189
Comments
Seems to be because of the flag removal code: if (!check_only && child->common.scope == ce) {
child->common.fn_flags &= ~ZEND_ACC_OVERRIDE;
} The second condition doesn't trigger because the method doesn't belong to the class, it belongs to the trait. However, getting rid of the condition is a bad idea because it may load to modification inside shm as the trait is shared. |
Without looking yet into this again (I fear it's above my pay-grade based on your description), I wonder why it works fine for interfaces then 🤔 Looking at the tests, it appears this issue found the only case that is not covered by the tests 😔 |
…ng interface Fixes phpGH-12189 Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
@TimWolla thanks for fixing! |
@jnoordsij Thank you for testing the release candidates and also for finding the bug 😃 |
Description
When adding the
#[Override]
attribute to a trait method, then use-ing it in a class, a runtime error is triggered even if a parent class defines a matching method. This does not happen when an interface with matching signature is encountered.The following excerpt from the rfc made me expect this would work:
The following code:
Resulted in this output:
But I expected no output instead.
PHP Version
8.3.0RC1
Operating System
Windows 11 / Ubuntu 23.10 with WSL
The text was updated successfully, but these errors were encountered: