Skip to content

Commit

Permalink
Hotfix: array indices with PHP 7.4 fn closure
Browse files Browse the repository at this point in the history
  • Loading branch information
michalbundyra committed Nov 19, 2019
1 parent 119a702 commit 98ae4ef
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Sniffs/AbstractArraySniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public function process(File $phpcsFile, $stackPtr)
if ($tokens[$checkToken]['code'] === T_ARRAY
|| $tokens[$checkToken]['code'] === T_OPEN_SHORT_ARRAY
|| $tokens[$checkToken]['code'] === T_CLOSURE
|| $tokens[$checkToken]['code'] === T_FN
) {
// Let subsequent calls of this test handle nested arrays.
if ($tokens[$lastToken]['code'] !== T_DOUBLE_ARROW) {
Expand Down
2 changes: 2 additions & 0 deletions src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ $array = [
'hey' => $baz ??
['one'] ??
['two'],
'fn' =>
fn ($x) => yield 'k' => $x,
];

// phpcs:set Generic.Arrays.ArrayIndent indent 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ $array = [
'hey' => $baz ??
['one'] ??
['two'],
'fn' =>
fn ($x) => yield 'k' => $x,
];

// phpcs:set Generic.Arrays.ArrayIndent indent 2
Expand Down
4 changes: 2 additions & 2 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,
65 => 1,
66 => 1,
67 => 1,
68 => 1,
69 => 1,
70 => 1,
];

}//end getErrorList()
Expand Down

0 comments on commit 98ae4ef

Please sign in to comment.