diff --git a/src/Psalm/Internal/Analyzer/CommentAnalyzer.php b/src/Psalm/Internal/Analyzer/CommentAnalyzer.php index 83c5545b2..06da33015 100644 --- a/src/Psalm/Internal/Analyzer/CommentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/CommentAnalyzer.php @@ -577,9 +577,9 @@ class CommentAnalyzer || isset($comments['specials']['extends']) ) { $all_inheritance = array_merge( - $comments['specials']['template-extends'] ?: [], - $comments['specials']['inherits'] ?: [], - $comments['specials']['extends'] ?: [] + $comments['specials']['template-extends'] ?? [], + $comments['specials']['inherits'] ?? [], + $comments['specials']['extends'] ?? [] ); foreach ($all_inheritance as $template_line) { diff --git a/tests/TemplateTest.php b/tests/TemplateTest.php index 892213930..d607cad76 100644 --- a/tests/TemplateTest.php +++ b/tests/TemplateTest.php @@ -1627,6 +1627,56 @@ class TemplateTest extends TestCase '$f2' => 'Foo', ] ], + 'supportBareExtends' => [ + ' + */ + class FooContainer extends Container + { + /** + * @return Foo + */ + public function getItem() + { + return new Foo(); + } + } + + /** + * @template TItem + * @param Container $c + * @return TItem + */ + function getItemFromContainer(Container $c) { + return $c->getItem(); + } + + $fc = new FooContainer(); + + $f1 = $fc->getItem(); + $f2 = getItemFromContainer($fc);', + [ + '$fc' => 'FooContainer', + '$f1' => 'Foo', + '$f2' => 'Foo', + ] + ], 'allowExtendingParameterisedTypeParam' => [ '