Skip to content

Commit 1697fac

Browse files
committed
Ignore the previous element's T_COMMA when looking up the beginning of the previous expression
1 parent 1371c59 commit 1697fac

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ 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;
6566
$prev = $phpcsFile->findPrevious($ignore, ($stackPtr - 1), null, true);
6667
$start = $phpcsFile->findStartOfStatement($prev);
6768
$first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $start, true);

src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,14 @@ $var = [
7777
2 => 'two',
7878
/* three */ 3 => 'three',
7979
];
80+
81+
// phpcs:set Generic.Arrays.ArrayIndent indent 4
82+
83+
$foo = [
84+
'foo'
85+
. 'bar',
86+
[
87+
'baz',
88+
'qux',
89+
],
90+
];

src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc.fixed

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,14 @@ $var = [
7878
2 => 'two',
7979
/* three */ 3 => 'three',
8080
];
81+
82+
// phpcs:set Generic.Arrays.ArrayIndent indent 4
83+
84+
$foo = [
85+
'foo'
86+
. 'bar',
87+
[
88+
'baz',
89+
'qux',
90+
],
91+
];

src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public function getErrorList()
4040
77 => 1,
4141
78 => 1,
4242
79 => 1,
43+
87 => 1,
44+
88 => 1,
45+
89 => 1,
4346
];
4447

4548
}//end getErrorList()

0 commit comments

Comments
 (0)