1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Fix #2443 - templates are not valid PHPDoc

This commit is contained in:
Brown 2019-12-10 14:03:51 -05:00
parent 423288d2fe
commit 9d22f56560
2 changed files with 40 additions and 0 deletions

View File

@ -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,

View File

@ -735,6 +735,37 @@ class ReturnTypeManipulationTest extends FileManipulationTest
['MissingReturnType'],
true,
],
'addMissingTemplateReturnType' => [
'<?php
/**
* @template T as object
*
* @param object $t Flabble
*
* @psalm-param T $t
*/
function foo($t) {
return $t;
}',
'<?php
/**
* @template T as object
*
* @param object $t Flabble
*
* @psalm-param T $t
*
* @return object
*
* @psalm-return T
*/
function foo($t) {
return $t;
}',
'7.4',
['MissingReturnType'],
true
],
'fixInvalidIntReturnType56' => [
'<?php
/**