Skip to content

Commit 901a599

Browse files
rodrigoprimojrfnl
authored andcommitted
Generic/ArrayIndent: remove T_COMMA from list of tokens to ignore
This commit removes T_COMMA from a list of tokens to ignore when searching for the non-empty token before the start of the array. T_COMMA was added to this list in 1697fac to fix a bug. See squizlabs/PHP_CodeSniffer#3100 for more details. Back when this fix was introduced, it was necessary to ignore commas due to a bug in findStartOfStatement() that would cause this method to return the wrong token when passed the last token in a statement. This bug has been fixed afterwards in ef80e53 and ignoring commas is not necessary anymore. Now, the call to findStartOfStatement() in https://github.com/squizlabs/PHP_CodeSniffer/blob/4cf6badaf0c177acaf295e2178f4383e2ea71b20/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php#L67 correctly finds the start of the statement when passed the comma that marks the end of the statement. A test was added 1697fac. It would fail if running an older version of PHPCS without ignoring commas, but now it passes: https://github.com/squizlabs/PHP_CodeSniffer/pull/3101/files#diff-f786a9f6c41b82204dc89de2c02437c0e44401d580b02fcbde6278ea03f25693R83-R90
1 parent 09ff94a commit 901a599

File tree

1 file changed

+0
-1
lines changed

1 file changed

+0
-1
lines changed

src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array
6262
// Determine how far indented the entire array declaration should be.
6363
$ignore = Tokens::$emptyTokens;
6464
$ignore[] = T_DOUBLE_ARROW;
65-
$ignore[] = T_COMMA;
6665
$prev = $phpcsFile->findPrevious($ignore, ($stackPtr - 1), null, true);
6766
$start = $phpcsFile->findStartOfStatement($prev);
6867
$first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $start, true);

0 commit comments

Comments
 (0)