Skip to content

Commit 98ae4ef

Browse files
committed
Hotfix: array indices with PHP 7.4 fn closure
1 parent 119a702 commit 98ae4ef

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

src/Sniffs/AbstractArraySniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public function process(File $phpcsFile, $stackPtr)
9999
if ($tokens[$checkToken]['code'] === T_ARRAY
100100
|| $tokens[$checkToken]['code'] === T_OPEN_SHORT_ARRAY
101101
|| $tokens[$checkToken]['code'] === T_CLOSURE
102+
|| $tokens[$checkToken]['code'] === T_FN
102103
) {
103104
// Let subsequent calls of this test handle nested arrays.
104105
if ($tokens[$lastToken]['code'] !== T_DOUBLE_ARROW) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ $array = [
5757
'hey' => $baz ??
5858
['one'] ??
5959
['two'],
60+
'fn' =>
61+
fn ($x) => yield 'k' => $x,
6062
];
6163

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

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ $array = [
5858
'hey' => $baz ??
5959
['one'] ??
6060
['two'],
61+
'fn' =>
62+
fn ($x) => yield 'k' => $x,
6163
];
6264

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ public function getErrorList()
3333
31 => 1,
3434
33 => 1,
3535
41 => 1,
36-
65 => 1,
37-
66 => 1,
3836
67 => 1,
3937
68 => 1,
38+
69 => 1,
39+
70 => 1,
4040
];
4141

4242
}//end getErrorList()

0 commit comments

Comments
 (0)