Bug Description
AlwaysReturnSniff doesn't actually trigger if the filter function doesn't include the return statement anywhere.
We have a bunch of tests to ensure AlwaysReturnSniff flags various problematic ways of returning from inside WP filters, but there is no test that ensures it raises a flag when return is omitted entirely.
Minimal Code Snippet
add_filter( 'bad_example_closure_with_no_returns', function( $input ) {
$input = $input . ' hello!';
// But we never return _anywhere_
}, 10, 2 );
Error Code
WordPressVIPMinimum.Filters.AlwaysReturn.missingReturnStatement
Environment
Use php -v and composer show to get versions.
| Question |
Answer |
| PHP version |
7.1.19 |
| PHP_CodeSniffer version |
3.3.2 |
| VIPCS version |
master |
Tested Against master branch?
Bug Description
AlwaysReturnSniffdoesn't actually trigger if the filter function doesn't include thereturnstatement anywhere.We have a bunch of tests to ensure
AlwaysReturnSniffflags various problematic ways of returning from inside WP filters, but there is no test that ensures it raises a flag whenreturnis omitted entirely.Minimal Code Snippet
Error Code
WordPressVIPMinimum.Filters.AlwaysReturn.missingReturnStatementEnvironment
Use
php -vandcomposer showto get versions.Tested Against
masterbranch?masterbranch of VIPCS.