1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Improve static resolution a little more

This commit is contained in:
Brown 2020-03-28 08:14:35 -04:00
parent 5835c34a29
commit 60613462fe

View File

@ -1306,17 +1306,21 @@ class ExpressionAnalyzer
} elseif ($return_type->was_static
&& ($static_class_type instanceof Type\Atomic\TNamedObject
|| $static_class_type instanceof Type\Atomic\TTemplateParam)
&& $static_class_type->getKey(false) !== $return_type->getKey(false)
) {
$return_type = clone $return_type;
$cloned_static = clone $static_class_type;
$extra_static = $cloned_static->extra_types ?: [];
$cloned_static->extra_types = null;
if ($cloned_static->getKey(false) !== $return_type->getKey(false)) {
$return_type->extra_types[$static_class_type->getKey()] = clone $cloned_static;
}
foreach ($extra_static as $extra_static_type) {
if ($extra_static_type->getKey(false) !== $return_type->getKey(false)) {
$return_type->extra_types[$extra_static_type->getKey()] = clone $extra_static_type;
}
}
} elseif ($return_type_lc === 'self') {
if (!$self_class) {
throw new \UnexpectedValueException(