From 8c236f411a20ad96bbaf650095fe30fa1cec7bda Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Tue, 12 May 2020 15:07:10 -0400 Subject: [PATCH] Fix #3353 - allow extending nested when nested as type is mixed --- src/Psalm/Internal/Analyzer/ClassAnalyzer.php | 6 +++++- tests/Template/ClassTemplateExtendsTest.php | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php index 6f69394ea..d15d42a07 100644 --- a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php @@ -2038,7 +2038,7 @@ class ClassAnalyzer extends ClassLikeAnalyzer if (IssueBuffer::accepts( new InvalidTemplateParam( 'Extended template param ' . $template_name - . ' expects type ' . $template_type[0]->getId() + . ' expects type ' . $template_type_copy->getId() . ', type ' . $extended_type->getId() . ' given', $code_location ), @@ -2051,6 +2051,10 @@ class ClassAnalyzer extends ClassLikeAnalyzer $declaring_class => [$extended_type] ]; } + } else { + $previous_extended[$template_name] = [ + $declaring_class => [$extended_type] + ]; } } } diff --git a/tests/Template/ClassTemplateExtendsTest.php b/tests/Template/ClassTemplateExtendsTest.php index d70d2624c..4a50f3a9b 100644 --- a/tests/Template/ClassTemplateExtendsTest.php +++ b/tests/Template/ClassTemplateExtendsTest.php @@ -4079,6 +4079,19 @@ class ClassTemplateExtendsTest extends TestCase } }' ], + 'extendIteratorIterator' => [ + '> + */ + abstract class MyFilterIterator extends IteratorIterator { + /** @return bool */ + public abstract function accept () {} + }' + ], ]; }