diff --git a/src/Psalm/Internal/Type/TypeParser.php b/src/Psalm/Internal/Type/TypeParser.php index 4707ff9a8..99cf82a4d 100644 --- a/src/Psalm/Internal/Type/TypeParser.php +++ b/src/Psalm/Internal/Type/TypeParser.php @@ -462,12 +462,6 @@ class TypeParser ); } - if (!$as->isSingle()) { - throw new TypeParseTreeException( - 'Invalid templated classname \'' . $as . '\'', - ); - } - foreach ($as->getAtomicTypes() as $t) { if ($t instanceof TObject) { return new TTemplateParamClass( diff --git a/tests/ClassLikeStringTest.php b/tests/ClassLikeStringTest.php index 1e7f5b9ea..b3bcca561 100644 --- a/tests/ClassLikeStringTest.php +++ b/tests/ClassLikeStringTest.php @@ -879,6 +879,27 @@ class ClassLikeStringTest extends TestCase $foo->baz = TypeTwo::class; $foo->baz = TypeTwo::class;', ], + 'classStringOfUnionTypeParameter' => [ + 'code' => ' $class + * @return class-string + */ + function test(string $class): string { + return $class; + } + + $r = test(A::class);', + 'assertions' => [ + '$r' => 'class-string', + ], + ], ]; }