1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-03 10:07:52 +01:00

Set inside_isset false when analyzing ArrayDimFetch dim

This commit is contained in:
Evan Shaw 2024-02-26 21:19:29 +13:00
parent 71707e6c4e
commit 10ed0f3cd6
2 changed files with 11 additions and 0 deletions

View File

@ -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;

View File

@ -1281,6 +1281,11 @@ class ArrayAccessTest extends TestCase
echo $a[0];',
'error_message' => 'PossiblyInvalidArrayAccess',
],
'insideIssetDisabledForDim' => [
'code' => '<?php
isset($a[$b]);',
'error_message' => 'UndefinedGlobalVariable',
],
'mixedArrayAccess' => [
'code' => '<?php
/** @var mixed */