diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/IfConditionalAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/IfConditionalAnalyzer.php index 349eaf5ff0a..c00803dd1da 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/IfConditionalAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/IfConditionalAnalyzer.php @@ -23,7 +23,7 @@ use function array_diff_key; use function array_filter; -use function array_keys; +use function array_key_first; use function array_merge; use function array_values; use function count; @@ -80,7 +80,7 @@ public static function analyze( $entry_clauses, static fn(Clause $c): bool => count($c->possibilities) > 1 || $c->wedge - || !isset($changed_var_ids[array_keys($c->possibilities)[0]]) + || !isset($changed_var_ids[array_key_first($c->possibilities)]) ), ); } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php index 753e2891920..d71499606c6 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 @@ public static function analyze( $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/src/Psalm/Internal/Type/SimpleAssertionReconciler.php b/src/Psalm/Internal/Type/SimpleAssertionReconciler.php index c8bd3c1b21d..ed40b070143 100644 --- a/src/Psalm/Internal/Type/SimpleAssertionReconciler.php +++ b/src/Psalm/Internal/Type/SimpleAssertionReconciler.php @@ -2982,7 +2982,7 @@ private static function reconcileValueOf( continue; } - $enum_case = $class_storage->enum_cases[$atomic_type->const_name] ?? null; + $enum_case = $class_storage->enum_cases[$enum_case_to_assert] ?? null; if ($enum_case === null) { return null; } diff --git a/tests/ArrayAccessTest.php b/tests/ArrayAccessTest.php index 88eb7d15e52..8481ac569e4 100644 --- a/tests/ArrayAccessTest.php +++ b/tests/ArrayAccessTest.php @@ -1281,6 +1281,11 @@ function return_array() { echo $a[0];', 'error_message' => 'PossiblyInvalidArrayAccess', ], + 'insideIssetDisabledForDim' => [ + 'code' => ' 'UndefinedGlobalVariable', + ], 'mixedArrayAccess' => [ 'code' => '