Skip to content

Commit

Permalink
Squiz.PHP.DisallowMultipleAssignmentsSniff: Ignore default value assi…
Browse files Browse the repository at this point in the history
…gnments in arrow functions
  • Loading branch information
kukulich committed Apr 8, 2021
1 parent b245bb3 commit 9ca9a54
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function process(File $phpcsFile, $stackPtr)
$tokens = $phpcsFile->getTokens();

// Ignore default value assignments in function definitions.
$function = $phpcsFile->findPrevious([T_FUNCTION, T_CLOSURE], ($stackPtr - 1), null, false, null, true);
$function = $phpcsFile->findPrevious([T_FUNCTION, T_CLOSURE, T_FN], ($stackPtr - 1), null, false, null, true);
if ($function !== false) {
$opener = $tokens[$function]['parenthesis_opener'];
$closer = $tokens[$function]['parenthesis_closer'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,5 @@ $array = [
false => 0
},
];

$arrow_function = fn ($a = null) => $a;

0 comments on commit 9ca9a54

Please sign in to comment.