Skip to content

Commit 033b431

Browse files
committed
Generic.WhiteSpace.ScopeIndent now supports static arrow functions (ref #2523)
1 parent c8fca56 commit 033b431

File tree

7 files changed

+27
-5
lines changed

7 files changed

+27
-5
lines changed

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
3333
- File::getMethodProperties() now supports arrow functions
3434
- Generic.CodeAnalysis.EmptyPhpStatement now reports unnecessary semicolons after control structure closing braces
3535
-- Thanks to Vincent Langlet for the patch
36+
- Generic.WhiteSpace.ScopeIndent now supports static arrow functions
3637
- Fixed bug #2638 : Squiz.CSS.DuplicateClassDefinitionSniff sees comments as part of the class name
3738
-- Thanks to Raphael Horber for the patch
3839
- Fixed bug #2674 : Squiz.Functions.FunctionDeclarationArgumentSpacing prints wrong argument name in error message

src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,8 @@ public function process(File $phpcsFile, $stackPtr)
846846
$next = $phpcsFile->findNext(Tokens::$emptyTokens, ($checkToken + 1), null, true);
847847
if ($next === false
848848
|| ($tokens[$next]['code'] !== T_CLOSURE
849-
&& $tokens[$next]['code'] !== T_VARIABLE)
849+
&& $tokens[$next]['code'] !== T_VARIABLE
850+
&& $tokens[$next]['code'] !== T_FN)
850851
) {
851852
if ($this->debug === true) {
852853
$line = $tokens[$checkToken]['line'];

src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,6 +1434,11 @@ $query = Model::query()
14341434
static $b = '';
14351435
});
14361436

1437+
$result = array_map(
1438+
static fn(int $number) : int => $number + 1,
1439+
$numbers
1440+
);
1441+
14371442
?>
14381443

14391444
<?php

src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc.fixed

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,6 +1434,11 @@ $query = Model::query()
14341434
static $b = '';
14351435
});
14361436

1437+
$result = array_map(
1438+
static fn(int $number) : int => $number + 1,
1439+
$numbers
1440+
);
1441+
14371442
?>
14381443

14391444
<?php

src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,6 +1434,11 @@ $query = Model::query()
14341434
static $b = '';
14351435
});
14361436

1437+
$result = array_map(
1438+
static fn(int $number) : int => $number + 1,
1439+
$numbers
1440+
);
1441+
14371442
?>
14381443

14391444
<?php

src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc.fixed

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,6 +1434,11 @@ $query = Model::query()
14341434
static $b = '';
14351435
});
14361436

1437+
$result = array_map(
1438+
static fn(int $number) : int => $number + 1,
1439+
$numbers
1440+
);
1441+
14371442
?>
14381443

14391444
<?php

src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,10 @@ public function getErrorList($testFile='ScopeIndentUnitTest.inc')
178178
1340 => 1,
179179
1342 => 1,
180180
1345 => 1,
181-
1440 => 1,
182-
1441 => 1,
183-
1442 => 1,
184-
1443 => 1,
181+
1445 => 1,
182+
1446 => 1,
183+
1447 => 1,
184+
1448 => 1,
185185
];
186186

187187
}//end getErrorList()

0 commit comments

Comments
 (0)