1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-04 10:38:49 +01:00

makes Psalm understand templates in lhs

This commit is contained in:
orklah 2021-10-05 10:37:51 +02:00
parent 213644d48e
commit 12ecaaa84d
2 changed files with 15 additions and 0 deletions

View File

@ -450,6 +450,16 @@ class CallableTypeComparator
foreach ($lhs->getAtomicTypes() as $lhs_atomic_type) {
if ($lhs_atomic_type instanceof TNamedObject) {
$class_name = $lhs_atomic_type->value;
} elseif ($lhs_atomic_type instanceof Atomic\TTemplateParam) {
$lhs_template_type = $lhs_atomic_type->as;
if ($lhs_template_type->isSingle()) {
$lhs_template_atomic_type = $lhs_template_type->getSingleAtomic();
if ($lhs_template_atomic_type instanceof TNamedObject) {
$class_name = $lhs_template_atomic_type->value;
} elseif ($lhs_template_atomic_type instanceof Type\Atomic\TClassString) {
$class_name = $lhs_template_atomic_type->as;
}
}
} elseif ($lhs_atomic_type instanceof Type\Atomic\TClassString
&& $lhs_atomic_type->as
) {

View File

@ -1680,4 +1680,9 @@ class Union implements TypeNode
{
return count($this->literal_float_types) > 0;
}
public function getSingleAtomic(): Atomic
{
return reset($this->types);
}
}