mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Allow class-string<T> where T is a union
This commit is contained in:
parent
7d8d74d32a
commit
3b775f4617
@ -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(
|
||||
|
@ -879,6 +879,27 @@ class ClassLikeStringTest extends TestCase
|
||||
$foo->baz = TypeTwo::class;
|
||||
$foo->baz = TypeTwo::class;',
|
||||
],
|
||||
'classStringOfUnionTypeParameter' => [
|
||||
'code' => '<?php
|
||||
|
||||
class A {}
|
||||
class B {}
|
||||
|
||||
/**
|
||||
* @template T as A|B
|
||||
*
|
||||
* @param class-string<T> $class
|
||||
* @return class-string<T>
|
||||
*/
|
||||
function test(string $class): string {
|
||||
return $class;
|
||||
}
|
||||
|
||||
$r = test(A::class);',
|
||||
'assertions' => [
|
||||
'$r' => 'class-string<A>',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user