From 9d22f565604cdc5bf2145fbfd37f5ebde5323c72 Mon Sep 17 00:00:00 2001 From: Brown Date: Tue, 10 Dec 2019 14:03:51 -0500 Subject: [PATCH] Fix #2443 - templates are not valid PHPDoc --- src/Psalm/Type/Atomic/TTemplateParam.php | 9 ++++++ .../ReturnTypeManipulationTest.php | 31 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/Psalm/Type/Atomic/TTemplateParam.php b/src/Psalm/Type/Atomic/TTemplateParam.php index c186b8305..312aec822 100644 --- a/src/Psalm/Type/Atomic/TTemplateParam.php +++ b/src/Psalm/Type/Atomic/TTemplateParam.php @@ -108,6 +108,15 @@ class TTemplateParam extends \Psalm\Type\Atomic ?string $this_class, bool $use_phpdoc_format ) { + if ($use_phpdoc_format) { + return $this->as->toNamespacedString( + $namespace, + $aliased_classes, + $this_class, + $use_phpdoc_format + ); + } + $intersection_types = $this->getNamespacedIntersectionTypes( $namespace, $aliased_classes, diff --git a/tests/FileManipulation/ReturnTypeManipulationTest.php b/tests/FileManipulation/ReturnTypeManipulationTest.php index 0cd40c690..92fcd0207 100644 --- a/tests/FileManipulation/ReturnTypeManipulationTest.php +++ b/tests/FileManipulation/ReturnTypeManipulationTest.php @@ -735,6 +735,37 @@ class ReturnTypeManipulationTest extends FileManipulationTest ['MissingReturnType'], true, ], + 'addMissingTemplateReturnType' => [ + ' [ '