From 98ae4ef4c656f6ebb056f4f39b7b9bfa720a0c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bundyra?= Date: Tue, 19 Nov 2019 12:58:05 +0000 Subject: [PATCH] Hotfix: array indices with PHP 7.4 fn closure --- src/Sniffs/AbstractArraySniff.php | 1 + src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc | 2 ++ .../Generic/Tests/Arrays/ArrayIndentUnitTest.inc.fixed | 2 ++ src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php | 4 ++-- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Sniffs/AbstractArraySniff.php b/src/Sniffs/AbstractArraySniff.php index 072a9d0cb1..2135c1ccc9 100644 --- a/src/Sniffs/AbstractArraySniff.php +++ b/src/Sniffs/AbstractArraySniff.php @@ -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) { diff --git a/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc b/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc index d29e57f759..c11d979cf9 100644 --- a/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc +++ b/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc @@ -57,6 +57,8 @@ $array = [ 'hey' => $baz ?? ['one'] ?? ['two'], + 'fn' => + fn ($x) => yield 'k' => $x, ]; // phpcs:set Generic.Arrays.ArrayIndent indent 2 diff --git a/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc.fixed b/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc.fixed index 40a3705e66..94ea2f44d8 100644 --- a/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc.fixed +++ b/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc.fixed @@ -58,6 +58,8 @@ $array = [ 'hey' => $baz ?? ['one'] ?? ['two'], + 'fn' => + fn ($x) => yield 'k' => $x, ]; // phpcs:set Generic.Arrays.ArrayIndent indent 2 diff --git a/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php b/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php index 730d044906..9f9670f164 100644 --- a/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php +++ b/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php @@ -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()