From 59ab73fa912863554fee14e44b8c8bb066af7c4f Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Fri, 2 Dec 2022 18:28:43 +0100 Subject: [PATCH] Fixes --- .../Internal/Analyzer/Statements/Block/ForeachAnalyzer.php | 3 ++- .../Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php | 5 +---- src/Psalm/Internal/Codebase/Analyzer.php | 2 +- src/Psalm/Internal/PhpVisitor/PartialParserVisitor.php | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php index 327768800..42f887154 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php @@ -957,7 +957,8 @@ class ForeachAnalyzer ): void { if ($iterator_atomic_type instanceof TIterable || ($iterator_atomic_type instanceof TGenericObject - && strtolower($iterator_atomic_type->value) === 'traversable') + && strtolower($iterator_atomic_type->value) === 'traversable' + && isset($iterator_atomic_type->type_params[1])) ) { $value_type = Type::combineUnionTypes($value_type, $iterator_atomic_type->type_params[1]); $key_type = Type::combineUnionTypes($key_type, $iterator_atomic_type->type_params[0]); diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php index 91237f9f5..5e199aac1 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php @@ -1246,7 +1246,6 @@ class ArgumentAnalyzer $function_id_parts = explode('&', $function_id); $non_existent_method_ids = []; - $has_valid_method = false; foreach ($function_id_parts as $function_id_part) { [$callable_fq_class_name, $method_name] = explode('::', $function_id_part); @@ -1299,12 +1298,10 @@ class ArgumentAnalyzer && !$codebase->methods->methodExists($call_method_id) ) { $non_existent_method_ids[] = $function_id_part; - } else { - $has_valid_method = true; } } - if (!$has_valid_method && !$param_type->hasString() && !$param_type->hasArray()) { + if ($non_existent_method_ids && !$param_type->hasString() && !$param_type->hasArray()) { if (MethodAnalyzer::checkMethodExists( $codebase, $non_existent_method_ids[0], diff --git a/src/Psalm/Internal/Codebase/Analyzer.php b/src/Psalm/Internal/Codebase/Analyzer.php index d8b72caaf..b826d8b62 100644 --- a/src/Psalm/Internal/Codebase/Analyzer.php +++ b/src/Psalm/Internal/Codebase/Analyzer.php @@ -1116,7 +1116,7 @@ class Analyzer } /** - * @param array{0:int, 1:int} $mixed_counts + * @param list{int, int} $mixed_counts * */ public function setMixedCountsForFile(string $file_path, array $mixed_counts): void diff --git a/src/Psalm/Internal/PhpVisitor/PartialParserVisitor.php b/src/Psalm/Internal/PhpVisitor/PartialParserVisitor.php index 4173f47f1..bb8adbaa0 100644 --- a/src/Psalm/Internal/PhpVisitor/PartialParserVisitor.php +++ b/src/Psalm/Internal/PhpVisitor/PartialParserVisitor.php @@ -29,7 +29,7 @@ use const PREG_SET_ORDER; */ class PartialParserVisitor extends PhpParser\NodeVisitorAbstract { - /** @var array */ + /** @var array */ private $offset_map; /** @var bool */