diff --git a/Tests/VariableAnalysisSniff/fixtures/ArrowFunctionFixture.php b/Tests/VariableAnalysisSniff/fixtures/ArrowFunctionFixture.php index 9873fff..f81518d 100644 --- a/Tests/VariableAnalysisSniff/fixtures/ArrowFunctionFixture.php +++ b/Tests/VariableAnalysisSniff/fixtures/ArrowFunctionFixture.php @@ -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; +} diff --git a/VariableAnalysis/Lib/Helpers.php b/VariableAnalysis/Lib/Helpers.php index 1324eab..5e961e7 100644 --- a/VariableAnalysis/Lib/Helpers.php +++ b/VariableAnalysis/Lib/Helpers.php @@ -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; }