-
Notifications
You must be signed in to change notification settings - Fork 40
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
Sniff WordPressVIPMinimum.Hooks.AlwaysReturnInFilter.MissingReturnStatement fails on abstract methods #580
Comments
@kevinfodness Thanks for reporting this. I agree that that If that direction would be chosen though, some additional code is needed to make the distinction between "scope opener missing because of a parse error/tokenizer error/live coding" and "scope opener missing because it is an abstract method". @rebeccahum @GaryJones What do you think ? |
That makes sense to me, as we do already have some sniffs that flag for "manual inspection" due to static analysis limitations. |
That sounds like a fine solution to me also. |
… error This implements the suggestion made in Automattic#580 (comment) If the method a filter callback points to is an abstract method, a warning will be thrown asking for manual inspection of the child class implementations of the abstract method. In case of parse or tokenizer error, the sniff will bow out and stay silent.
… error This implements the suggestion made in Automattic#580 (comment) If the method a filter callback points to is an abstract method, a warning will be thrown asking for manual inspection of the child class implementations of the abstract method. In case of parse or tokenizer error, the sniff will bow out and stay silent.
I've updated @kevinfodness's PR with the proposed additional change. |
Bug Description
If you define an abstract class that sets up a filter in its constructor and sets the callback to an abstract method in the class which will be defined by implementing classes, the
WordPressVIPMinimum.Hooks.AlwaysReturnInFilter.MissingReturnStatement
sniff causes phpcs to crash, because it's trying to evaluate the return statement in an abstract method.The specific error message being returned is this:
Minimal Code Snippet
Error Code
No error code should be triggered.
Environment
Use
php -v
andcomposer show
to get versions.Additional Context (optional)
Fixed in PR #581
Tested Against
master
branch?master
branch of VIPCS.develop
branch of VIPCS.The text was updated successfully, but these errors were encountered: