-
Notifications
You must be signed in to change notification settings - Fork 70
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
Ignore throws in function mocks #245
Conversation
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.
Thanks for this! I too had noticed this and it was irksome. I appreciate a fix!
Just want to test it out quickly before merging, but it looks good.
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.
Confirmed this fixes the issue!
Summary
I have noticed that in some circumstances the mocks contained in
API/function-mocks.php
could trigger false positives in static analyzers like PhpStan or just the IDE if using WP_Mock within a project. I think by removing the@throws
solves this, although PhpStan will complain about it in this project. I suppose since these are just internal mocks we can safely ignore.I did try using
@noinspection
tags but PhpStorm wasn't happy (whether specific to unhandled exceptions or not).As for the strict type notations, same reason, externally it will reflect WP behavior (the alternative was to leave non-strict and rely only on phpdoc -- like WP does -- but then PhpStan would complain again... could swap that for a phpstan-ignore again, up to you)
Closes #248
Contributor checklist
Testing
Reviewer checklist