Skip to content

Commit fdea0e5

Browse files
committed
PEAR/MultiLineCondition: only examine the current line for the StartWithBoolean error
Fixes the same error may be thrown twice for the same token/line when encountering comments/PHPCS annotations.
1 parent 4a582a0 commit fdea0e5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public function process(File $phpcsFile, $stackPtr)
179179
}
180180

181181
$next = $phpcsFile->findNext(Tokens::$emptyTokens, $i, null, true);
182-
if ($next !== $closeBracket) {
182+
if ($next !== $closeBracket && $tokens[$next]['line'] === $tokens[$i]['line']) {
183183
if (isset(Tokens::$booleanOperators[$tokens[$next]['code']]) === false) {
184184
$error = 'Each line in a multi-line IF statement must begin with a boolean operator';
185185
$fix = $phpcsFile->addFixableError($error, $i, 'StartWithBoolean');

0 commit comments

Comments
 (0)