Skip to content

Commit

Permalink
Generic/UnusedFunctionParameter: remove unreacheable if condition
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rodrigoprimo authored and jrfnl committed Jan 17, 2024
1 parent f8dd4aa commit e881193
Showing 1 changed file with 0 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,6 @@ public function process(File $phpcsFile, $stackPtr)
// A return statement as the first content indicates an interface method.
if ($code === T_RETURN) {
$firstNonEmptyTokenAfterReturn = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), null, true);
if ($firstNonEmptyTokenAfterReturn === false && $implements !== false) {
return;
}

// There is a return.
if ($tokens[$firstNonEmptyTokenAfterReturn]['code'] === T_SEMICOLON && $implements !== false) {
return;
}
Expand Down

0 comments on commit e881193

Please sign in to comment.