Skip to content

Commit 5b799a2

Browse files
committed
Fix bug in UnneededElse.
1 parent 13e4f36 commit 5b799a2

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

PSR2R/Sniffs/ControlStructures/UnneededElseSniff.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ public function process(File $phpcsFile, $stackPtr) {
4141
$parenthesisStartIndex = $tokens[$prevParenthesisEndIndex]['parenthesis_opener'];
4242

4343
$prevConditionIndex = $phpcsFile->findPrevious(T_WHITESPACE, $parenthesisStartIndex - 1, null, true);
44-
// We only do trivial fixes right now
45-
if ($tokens[$prevConditionIndex]['code'] !== T_IF) {
44+
if (!in_array($tokens[$prevConditionIndex]['code'], [T_IF, T_ELSEIF], true)) {
4645
return;
4746
}
4847

0 commit comments

Comments
 (0)