From 10ed0f3cd61b980983b97723dbf7323865cc9cec Mon Sep 17 00:00:00 2001 From: Evan Shaw Date: Mon, 26 Feb 2024 21:19:29 +1300 Subject: [PATCH] Set inside_isset false when analyzing ArrayDimFetch dim --- .../Statements/Expression/Fetch/ArrayFetchAnalyzer.php | 6 ++++++ tests/ArrayAccessTest.php | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php index 753e28919..d71499606 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php @@ -120,13 +120,19 @@ final class ArrayFetchAnalyzer $was_inside_unset = $context->inside_unset; $context->inside_unset = false; + $was_inside_isset = $context->inside_isset; + $context->inside_isset = false; + if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->dim, $context) === false) { + $context->inside_isset = $was_inside_isset; $context->inside_unset = $was_inside_unset; $context->inside_general_use = $was_inside_general_use; return false; } + $context->inside_isset = $was_inside_isset; + $context->inside_unset = $was_inside_unset; $context->inside_general_use = $was_inside_general_use; diff --git a/tests/ArrayAccessTest.php b/tests/ArrayAccessTest.php index 88eb7d15e..8481ac569 100644 --- a/tests/ArrayAccessTest.php +++ b/tests/ArrayAccessTest.php @@ -1281,6 +1281,11 @@ class ArrayAccessTest extends TestCase echo $a[0];', 'error_message' => 'PossiblyInvalidArrayAccess', ], + 'insideIssetDisabledForDim' => [ + 'code' => ' 'UndefinedGlobalVariable', + ], 'mixedArrayAccess' => [ 'code' => '