From 2b0e979ee9434afdeb9dd59a3219bf4029c62dc8 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Tue, 29 Nov 2022 17:43:27 +0100 Subject: [PATCH] Fixes --- .../Expression/AssignmentAnalyzer.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php index ad15ad23a..6d8fe4255 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php @@ -52,6 +52,7 @@ use Psalm\Issue\NullReference; use Psalm\Issue\PossiblyInvalidArrayAccess; use Psalm\Issue\PossiblyNullArrayAccess; use Psalm\Issue\PossiblyUndefinedArrayOffset; +use Psalm\Issue\PossiblyUndefinedIntArrayOffset; use Psalm\Issue\ReferenceConstraintViolation; use Psalm\Issue\ReferenceReusedFromConfusingScope; use Psalm\Issue\UnnecessaryVarAnnotation; @@ -1417,13 +1418,15 @@ class AssignmentAnalyzer && $assign_value_atomic_type->is_list && $assign_value_atomic_type->fallback_params ) { - IssueBuffer::maybeAdd( - new PossiblyUndefinedArrayOffset( - 'Possibly undefined array key', - new CodeLocation($statements_analyzer->getSource(), $var) - ), - $statements_analyzer->getSuppressedIssues() - ); + if ($codebase->config->ensure_array_int_offsets_exist) { + IssueBuffer::maybeAdd( + new PossiblyUndefinedIntArrayOffset( + 'Possibly undefined array key', + new CodeLocation($statements_analyzer->getSource(), $var) + ), + $statements_analyzer->getSuppressedIssues() + ); + } $new_assign_type = $assign_value_atomic_type->fallback_params[1];