Skip to content

Commit 4a582a0

Browse files
committed
PEAR/MultiLineCondition: bug fix - allow for new PHPCS native whitelist comments
Treat the new `// phpcs:` comments in the same way as "ordinary" `T_COMMENT` tokens.
1 parent 5442b01 commit 4a582a0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ public function process(File $phpcsFile, $stackPtr)
117117
if ($fix === true) {
118118
// Account for a comment at the end of the line.
119119
$next = $phpcsFile->findNext(T_WHITESPACE, ($closeBracket + 1), null, true);
120-
if ($tokens[$next]['code'] !== T_COMMENT) {
120+
if ($tokens[$next]['code'] !== T_COMMENT
121+
&& isset(Tokens::$phpcsCommentTokens[$tokens[$next]['code']]) === false
122+
) {
121123
$phpcsFile->fixer->addNewlineBefore($closeBracket);
122124
} else {
123125
$next = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), null, true);
@@ -144,7 +146,9 @@ public function process(File $phpcsFile, $stackPtr)
144146
$expectedIndent = ($statementIndent + $this->indent);
145147
}//end if
146148

147-
if ($tokens[$i]['code'] === T_COMMENT) {
149+
if ($tokens[$i]['code'] === T_COMMENT
150+
|| isset(Tokens::$phpcsCommentTokens[$tokens[$i]['code']]) === true
151+
) {
148152
$prevLine = $tokens[$i]['line'];
149153
continue;
150154
}

0 commit comments

Comments
 (0)