-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
PHP 8.4: dynamic dispatch problem with traits and inheritance #18174
Comments
I'm unable to reproduce the issue on https://3v4l.org/ejRtn. Is the issue reliably appearing for you with the example script or is it happening randomly? |
Thanks for the fast reply. The code is just a very condensed example, that abstracts the structure/problem. As soon as as I introduce the method in the class C it works. Removing it results in the erroneous call. |
Do you have a reproducer or can you share the code where it happens in?
|
PHP 8.4.5
I only noticed this in the code I'm currently working on. It's not public, so sharing is not possible. But I could offer a screen sharing. |
It's going to be very challenging to help you if we don't have a reliable reproducer. There's also a patch for master that should be merged soon which changes the order in which traits are bound, to hopefully make some trait edge cases less surprising. #15878 Possibly, this will help. |
Description
I have the following bug. I think it might by a corner case. It is very hard to narrow down. Please find this reduces example. In my real code many more traits are involved, as are promoted properties, property hooks, etc. I cannot pinpoint the error to a specific version, but Im sure, it worked correctly in PHP 8.3.
So the call to C->test() skips the inherited B->test() and dispatches to A/X->test().
I ruled out, that
Most interesting is, that the pure existence of the called method in C with an explicit call to the parent clears the issue. As this should be redundant, I assume a bug.
Please let me know, if I should provide more details. As it is very difficult to reduce the code to a non-working example, thought, maybe something changed in PHP 8.4 regarding dynamic dispatch which could lead to this behavior.
PHP Version
PHP 8.4
Operating System
macOS 15
The text was updated successfully, but these errors were encountered: