From 22f32c1392f1e8922a8294d1fc23e5a28a197888 Mon Sep 17 00:00:00 2001 From: Evan Shaw Date: Tue, 27 Feb 2024 22:09:03 +1300 Subject: [PATCH] Set inside_isset = false when analyzing arguments --- .../Statements/Expression/Call/ArgumentsAnalyzer.php | 5 +++++ tests/FunctionCallTest.php | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php index 81843d56a15..3d825668dc9 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php @@ -231,6 +231,9 @@ public static function analyze( $was_inside_call = $context->inside_call; $context->inside_call = true; + $was_inside_isset = $context->inside_isset; + $context->inside_isset = false; + if (ExpressionAnalyzer::analyze( $statements_analyzer, $arg->value, @@ -240,11 +243,13 @@ public static function analyze( false, $high_order_template_result, ) === false) { + $context->inside_isset = $was_inside_isset; $context->inside_call = $was_inside_call; return false; } + $context->inside_isset = $was_inside_isset; $context->inside_call = $was_inside_call; if ($high_order_callable_info && $high_order_template_result) { diff --git a/tests/FunctionCallTest.php b/tests/FunctionCallTest.php index c2ca6040367..d667552666a 100644 --- a/tests/FunctionCallTest.php +++ b/tests/FunctionCallTest.php @@ -2506,6 +2506,16 @@ public function foo() : void { }', 'error_message' => 'InvalidArgument', ], + 'clearIssetContext' => [ + 'code' => ' 'UndefinedGlobalVariable', + ], 'mixedArgument' => [ 'code' => '