Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Tests/VariableAnalysisSniff/fixtures/ArrowFunctionFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,8 @@ function staticArrowFunctionAsVariableWithUnusedInside($subject) {
$arrowFunc = static fn($foo) => $subject; // unused variable $foo
echo $arrowFunc('hello');
}

function arrowFunctionAsExpressionInArgumentWithArray() {
$type = do_something(fn($array, $needle) => $array[2] === $needle);
echo $type;
}
6 changes: 0 additions & 6 deletions VariableAnalysis/Lib/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -628,12 +628,6 @@ public static function isArrowFunction(File $phpcsFile, $stackPtr)
public static function getArrowFunctionOpenClose(File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
if (defined('T_FN') && $tokens[$stackPtr]['code'] === T_FN) {
return [
'scope_opener' => $tokens[$stackPtr]['scope_opener'],
'scope_closer' => $tokens[$stackPtr]['scope_closer'],
];
}
if ($tokens[$stackPtr]['content'] !== 'fn') {
return null;
}
Expand Down