Skip to content

Commit

Permalink
Fixed bug #1881 : Generic.Arrays.ArrayIndent is indenting sub-arrays …
Browse files Browse the repository at this point in the history
…incorrectly when comma not used after the last value
  • Loading branch information
gsherwood committed Mar 19, 2018
1 parent c75c6ae commit 66e6e48
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
- Fixed bug #1863 : File::findEndOfStatement() not working when passed a scope opener
- Fixed bug #1876 : PSR2.Namespaces.UseDeclaration not giving error for use statements before the namespace declaration
-- Adds a new PSR2.Namespaces.UseDeclaration.UseBeforeNamespace error message
- Fixed bug #1881 : Generic.Arrays.ArrayIndent is indenting sub-arrays incorrectly when comma not used after the last value
- Fixed bug #1915 : JS tokenizer fails to tokenize regular expression proceeded by boolean not operator
- Fixed bug #1922 : Equal sign alignment check broken when list syntax used before assignment operator
- Fixed bug #1925 : Generic.Formatting.MultipleStatementAlignment skipping assignments within closures
Expand Down
3 changes: 1 addition & 2 deletions src/Sniffs/AbstractArraySniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,9 @@ public function process(File $phpcsFile, $stackPtr)
}

$checkToken = $phpcsFile->findNext(T_WHITESPACE, ($checkToken + 1), null, true);
$lastToken = $checkToken;
if ($tokens[$checkToken]['code'] !== T_COMMA) {
$checkToken--;
} else {
$lastToken = $checkToken;
}

continue;
Expand Down
6 changes: 6 additions & 0 deletions src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ $var = array(
'two' => 2,
);

return [
[
'foo' => true,
]
];

// phpcs:set Generic.Arrays.ArrayIndent indent 2

$var = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ $var = array(
'two' => 2,
);

return [
[
'foo' => true,
]
];

// phpcs:set Generic.Arrays.ArrayIndent indent 2

$var = [
Expand Down
8 changes: 4 additions & 4 deletions src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public function getErrorList()
31 => 1,
33 => 1,
41 => 1,
49 => 1,
50 => 1,
51 => 1,
52 => 1,
55 => 1,
56 => 1,
57 => 1,
58 => 1,
];

}//end getErrorList()
Expand Down

0 comments on commit 66e6e48

Please sign in to comment.