Skip to content

Commit 9ca9a54

Browse files
committed
Squiz.PHP.DisallowMultipleAssignmentsSniff: Ignore default value assignments in arrow functions
1 parent b245bb3 commit 9ca9a54

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function process(File $phpcsFile, $stackPtr)
4343
$tokens = $phpcsFile->getTokens();
4444

4545
// Ignore default value assignments in function definitions.
46-
$function = $phpcsFile->findPrevious([T_FUNCTION, T_CLOSURE], ($stackPtr - 1), null, false, null, true);
46+
$function = $phpcsFile->findPrevious([T_FUNCTION, T_CLOSURE, T_FN], ($stackPtr - 1), null, false, null, true);
4747
if ($function !== false) {
4848
$opener = $tokens[$function]['parenthesis_opener'];
4949
$closer = $tokens[$function]['parenthesis_closer'];

src/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,5 @@ $array = [
8787
false => 0
8888
},
8989
];
90+
91+
$arrow_function = fn ($a = null) => $a;

0 commit comments

Comments
 (0)