Skip to content

Commit dedda1e

Browse files
morozovgsherwood
authored andcommitted
Ignore the previous element's T_COMMA when looking up the beginning of the previous expression
1 parent 494494a commit dedda1e

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ $foo =
7070
],
7171
];
7272

73+
$foo = [
74+
'foo'
75+
. 'bar',
76+
[
77+
'baz',
78+
'qux',
79+
],
80+
];
81+
7382
// phpcs:set Generic.Arrays.ArrayIndent indent 2
7483

7584
$var = [

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ $foo =
7171
],
7272
];
7373

74+
$foo = [
75+
'foo'
76+
. 'bar',
77+
[
78+
'baz',
79+
'qux',
80+
],
81+
];
82+
7483
// phpcs:set Generic.Arrays.ArrayIndent indent 2
7584

7685
$var = [

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,13 @@ public function getErrorList()
3636
62 => 1,
3737
63 => 1,
3838
69 => 1,
39-
76 => 1,
4039
77 => 1,
4140
78 => 1,
4241
79 => 1,
42+
85 => 1,
43+
86 => 1,
44+
87 => 1,
45+
88 => 1,
4346
];
4447

4548
}//end getErrorList()

0 commit comments

Comments
 (0)