Skip to content

Commit

Permalink
Merge pull request #10752 from edsrzf/array-isset-disable-dim
Browse files Browse the repository at this point in the history
  • Loading branch information
weirdan committed Feb 27, 2024
2 parents a1352eb + 3535324 commit 60badd0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
Expand Up @@ -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;
Expand Down Expand Up @@ -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)])
),
);
}
Expand Down
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Type/SimpleAssertionReconciler.php
Expand Up @@ -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;
}
Expand Down
5 changes: 5 additions & 0 deletions tests/ArrayAccessTest.php
Expand Up @@ -1281,6 +1281,11 @@ function return_array() {
echo $a[0];',
'error_message' => 'PossiblyInvalidArrayAccess',
],
'insideIssetDisabledForDim' => [
'code' => '<?php
isset($a[$b]);',
'error_message' => 'UndefinedGlobalVariable',
],
'mixedArrayAccess' => [
'code' => '<?php
/** @var mixed */
Expand Down

0 comments on commit 60badd0

Please sign in to comment.