From 202ab3812402420e73f7d409bbc46757bcda3f36 Mon Sep 17 00:00:00 2001 From: Andrew Nagy <564256+tm1000@users.noreply.github.com> Date: Thu, 20 Feb 2025 22:32:52 -0800 Subject: [PATCH 1/3] Fixes PHP Error: Undefined array key 1 --- src/Psalm/Internal/Analyzer/ClassAnalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php index bb2edb6e1c8..5d935766f1e 100644 --- a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php @@ -772,7 +772,7 @@ public static function addContextProperties( if ($covariant) { // If template_covariants is set template_types should also be set assert($parent_storage->template_types !== null); - $pt_name = array_keys($parent_storage->template_types)[$pt_offset]; + $pt_name = array_keys($parent_storage->template_types)[$pt_offset] ?? null; if (isset($template_standins->lower_bounds[$pt_name][$parent_class])) { $lower_bounds[$pt_name][$parent_class] = TemplateStandinTypeReplacer::getMostSpecificTypeFromBounds( From bf089bb1a61b1538598344f28c4ab2acd9ad4d8c Mon Sep 17 00:00:00 2001 From: Andrew Nagy <564256+tm1000@users.noreply.github.com> Date: Thu, 20 Feb 2025 22:39:00 -0800 Subject: [PATCH 2/3] if null then continue --- src/Psalm/Internal/Analyzer/ClassAnalyzer.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php index 5d935766f1e..d1e317706eb 100644 --- a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php @@ -773,6 +773,9 @@ public static function addContextProperties( // If template_covariants is set template_types should also be set assert($parent_storage->template_types !== null); $pt_name = array_keys($parent_storage->template_types)[$pt_offset] ?? null; + if($pt_name === null) { + continue; + } if (isset($template_standins->lower_bounds[$pt_name][$parent_class])) { $lower_bounds[$pt_name][$parent_class] = TemplateStandinTypeReplacer::getMostSpecificTypeFromBounds( From 5bc56f8dc7669f9b5c0a95089b9d3086d9763832 Mon Sep 17 00:00:00 2001 From: Andrew Nagy <564256+tm1000@users.noreply.github.com> Date: Thu, 20 Feb 2025 22:40:37 -0800 Subject: [PATCH 3/3] styles --- src/Psalm/Internal/Analyzer/ClassAnalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php index d1e317706eb..40b374a8224 100644 --- a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php @@ -773,7 +773,7 @@ public static function addContextProperties( // If template_covariants is set template_types should also be set assert($parent_storage->template_types !== null); $pt_name = array_keys($parent_storage->template_types)[$pt_offset] ?? null; - if($pt_name === null) { + if ($pt_name === null) { continue; } if (isset($template_standins->lower_bounds[$pt_name][$parent_class])) {