Skip to content

Commit e881193

Browse files
rodrigoprimojrfnl
authored andcommitted
Generic/UnusedFunctionParameter: remove unreacheable if condition
At this point in the code, there should always be a non-empty token after the return statement, even if only the scope closer, and thus the if condition will never be true. If there is a syntax error and there is nothing after the return, the code will never reach this point as in the beginning of the method the code checks if `$token['scope_opener']` is set and this only happens when there is also a scope_closer.
1 parent f8dd4aa commit e881193

File tree

1 file changed

+0
-5
lines changed

1 file changed

+0
-5
lines changed

src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,6 @@ public function process(File $phpcsFile, $stackPtr)
174174
// A return statement as the first content indicates an interface method.
175175
if ($code === T_RETURN) {
176176
$firstNonEmptyTokenAfterReturn = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), null, true);
177-
if ($firstNonEmptyTokenAfterReturn === false && $implements !== false) {
178-
return;
179-
}
180-
181-
// There is a return.
182177
if ($tokens[$firstNonEmptyTokenAfterReturn]['code'] === T_SEMICOLON && $implements !== false) {
183178
return;
184179
}

0 commit comments

Comments
 (0)