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

Fix #1263 - return proper class string

This commit is contained in:
Matthew Brown 2019-01-31 21:06:21 -05:00
parent 0be6aac30c
commit ac79e9a311
2 changed files with 16 additions and 1 deletions

View File

@ -1059,7 +1059,10 @@ class Union
$new_types[$unknown_class_string->getKey()] = $unknown_class_string;
} elseif ($template_type_part instanceof Type\Atomic\TNamedObject) {
$literal_class_string = new Type\Atomic\TClassString($template_type_part->value);
$literal_class_string = new Type\Atomic\TClassString(
$template_type_part->value,
$template_type_part
);
$new_types[$literal_class_string->getKey()] = $literal_class_string;
}

View File

@ -485,6 +485,18 @@ class ClassStringTest extends TestCase
}
}'
],
'returnTemplatedClassString' => [
'<?php
/**
* @template T
*
* @param class-string<T> $shouldBe
* @return class-string<T>
*/
function identity(string $shouldBe) : string { return $shouldBe; }
identity(DateTimeImmutable::class)::createFromMutable(new DateTime());',
],
];
}