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

Allow templated static type in fleshOutType

This commit is contained in:
Brown 2019-06-24 15:08:55 -04:00
parent 2a1ed6ca6a
commit 4baa4d70d8
2 changed files with 16 additions and 3 deletions

View File

@ -773,11 +773,24 @@ class StaticCallAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\
);
}
if ($lhs_type_part instanceof Type\Atomic\TTemplateParam) {
$static_type = $lhs_type_part;
} elseif ($lhs_type_part instanceof Type\Atomic\TTemplateParamClass) {
$static_type = new Type\Atomic\TTemplateParam(
$lhs_type_part->param_name,
$lhs_type_part->as_type
? new Type\Union([$lhs_type_part->as_type])
: Type::getObject()
);
} else {
$static_type = $fq_class_name;
}
$return_type_candidate = ExpressionAnalyzer::fleshOutType(
$codebase,
$return_type_candidate,
$self_fq_class_name,
$fq_class_name,
$static_type,
$class_storage->parent_class
);

View File

@ -995,7 +995,7 @@ class ExpressionAnalyzer
/**
* @param Type\Union $return_type
* @param string|null $self_class
* @param string|Type\Atomic\TNamedObject|null $static_class_type
* @param string|Type\Atomic\TNamedObject|Type\Atomic\TTemplateParam|null $static_class_type
*
* @return Type\Union
*/
@ -1044,7 +1044,7 @@ class ExpressionAnalyzer
/**
* @param Type\Atomic &$return_type
* @param string|null $self_class
* @param string|Type\Atomic\TNamedObject|null $static_class_type
* @param string|Type\Atomic\TNamedObject|Type\Atomic\TTemplateParam|null $static_class_type
*
* @return Type\Atomic|array<int, Type\Atomic>
*/