diff --git a/src/Analyser/MutatingScope.php b/src/Analyser/MutatingScope.php index bb7f76168a..8189dbfd44 100644 --- a/src/Analyser/MutatingScope.php +++ b/src/Analyser/MutatingScope.php @@ -2926,7 +2926,7 @@ public function enterAnonymousFunction( true, [], [], - [], + $this->inFunctionCallsStack, false, $this, $this->nativeTypesPromoted, @@ -3105,7 +3105,7 @@ public function enterArrowFunction(Expr\ArrowFunction $arrowFunction, ?array $ca true, [], [], - [], + $this->inFunctionCallsStack, $scope->afterExtractCall, $scope->parentScope, $this->nativeTypesPromoted, diff --git a/tests/PHPStan/Rules/ScopeFunctionCallStackRuleTest.php b/tests/PHPStan/Rules/ScopeFunctionCallStackRuleTest.php index b7a1a53c23..d59d22835e 100644 --- a/tests/PHPStan/Rules/ScopeFunctionCallStackRuleTest.php +++ b/tests/PHPStan/Rules/ScopeFunctionCallStackRuleTest.php @@ -27,6 +27,14 @@ public function testRule(): void "var_dump\nprint_r\nsleep", 7, ], + [ + "var_dump\nprint_r\nsleep", + 10, + ], + [ + "var_dump\nprint_r\nsleep", + 13, + ], ]); } diff --git a/tests/PHPStan/Rules/data/scope-function-call-stack.php b/tests/PHPStan/Rules/data/scope-function-call-stack.php index 1b5d729ca9..700494fa88 100644 --- a/tests/PHPStan/Rules/data/scope-function-call-stack.php +++ b/tests/PHPStan/Rules/data/scope-function-call-stack.php @@ -5,4 +5,10 @@ function (): void { var_dump(print_r(sleep(throw new \Exception()))); + + var_dump(print_r(function () { + sleep(throw new \Exception()); + })); + + var_dump(print_r(fn () => sleep(throw new \Exception()))); };