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
Rule visits nullsafe method call twice (once with MethodCall, once with NullsafeMethodCall) #9830
Comments
This is expected behaviour. If you hook your rule on NullsafeMethodCall, it's gonna get called. If you hook your rule on MethodCall, it's also gonna get called (I did this so that existing rules also check NullsafeMethodCall nodes which PHPStan greatly benefits from). This means that if you hook your rule on a common ancestor like CallLike or Node, it should also get called. You also get multiple virtual nodes for every method declaration etc. You can fix your problem if you filter out all NullsafeMethodCall invocations because you're not interested in them. Alternatively, we could provide some attribute like |
I like that. Because currently, I was unable to distinguish (while ignoring NullsafeMethodCall to avoid this issue) if it was nullsafe or not. Here is the case (currently, I'm unable to show |
I think we can close this as this has a solution now, WDYT? |
Yes :) |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug report
When a rule is hooked on parent of those nodes, e.g. like this:
and analyses this simple code
The rule is called twice:
Code snippet that reproduces the problem
https://phpstan.org/r/2aa36241-7795-4561-bf14-5c8d641f89fb
Expected output
Visit node only once.
Did PHPStan help you today? Did it make you happy in any way?
No response
The text was updated successfully, but these errors were encountered: