From a7c4f0052be81f72671a5a20af87fdf199a3f4e5 Mon Sep 17 00:00:00 2001 From: orklah Date: Thu, 7 Oct 2021 19:32:25 +0200 Subject: [PATCH] foreach on list gives a positive|0 offset --- .../Internal/Analyzer/Statements/Block/ForeachAnalyzer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php index 713de3d8d..1a0cac0a8 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php @@ -347,7 +347,7 @@ class ForeachAnalyzer * @param PhpParser\Node\Stmt\Foreach_|PhpParser\Node\Expr\YieldFrom $stmt * @return false|null */ - public static function checkIteratorType( + public static function checkIteratorType( StatementsAnalyzer $statements_analyzer, PhpParser\NodeAbstract $stmt, PhpParser\Node\Expr $expr, @@ -449,7 +449,7 @@ class ForeachAnalyzer ? new Type\Union([ new Type\Atomic\TDependentListKey($list_var_id) ]) - : Type::getInt(), + : new Type\Union([new Type\Atomic\TIntRange(0, null)]), $iterator_atomic_type->type_param ]); } elseif (!$iterator_atomic_type instanceof Type\Atomic\TNonEmptyArray) {