mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 12:55:26 +01:00
Fix #8414
This commit is contained in:
parent
ffc8c8080d
commit
1401bf94db
@ -3,6 +3,7 @@
|
||||
namespace Psalm\Internal\Analyzer\Statements\Expression\Call;
|
||||
|
||||
use Psalm\Codebase;
|
||||
use Psalm\Internal\Type\TemplateResult;
|
||||
use Psalm\Internal\Type\TypeExpander;
|
||||
use Psalm\Storage\ClassLikeStorage;
|
||||
use Psalm\Type;
|
||||
@ -118,6 +119,7 @@ class ClassTemplateParamCollector
|
||||
$input_type_extends = $e[$class_storage->name][$type_name];
|
||||
|
||||
$output_type_extends = self::resolveTemplateParam(
|
||||
$codebase,
|
||||
$input_type_extends,
|
||||
$static_class_storage,
|
||||
$lhs_type_part
|
||||
@ -163,11 +165,23 @@ class ClassTemplateParamCollector
|
||||
return $class_template_params;
|
||||
}
|
||||
|
||||
public static function resolveTemplateParam(
|
||||
private static function resolveTemplateParam(
|
||||
Codebase $codebase,
|
||||
Union $input_type_extends,
|
||||
ClassLikeStorage $static_class_storage,
|
||||
TGenericObject $lhs_type_part
|
||||
TGenericObject $lhs_type_part,
|
||||
?TemplateResult $template_result = null
|
||||
): ?Union {
|
||||
if ($template_result === null) {
|
||||
$templates = self::collect(
|
||||
$codebase,
|
||||
$static_class_storage,
|
||||
$static_class_storage,
|
||||
null,
|
||||
$lhs_type_part
|
||||
);
|
||||
$template_result = new TemplateResult($static_class_storage->template_types, $templates);
|
||||
}
|
||||
$output_type_extends = null;
|
||||
foreach ($input_type_extends->getAtomicTypes() as $type_extends_atomic) {
|
||||
if ($type_extends_atomic instanceof TTemplateParam) {
|
||||
@ -199,12 +213,14 @@ class ClassTemplateParamCollector
|
||||
[$type_extends_atomic->param_name]
|
||||
)) {
|
||||
$nested_output_type = self::resolveTemplateParam(
|
||||
$codebase,
|
||||
$static_class_storage
|
||||
->template_extended_params
|
||||
[$type_extends_atomic->defining_class]
|
||||
[$type_extends_atomic->param_name],
|
||||
$static_class_storage,
|
||||
$lhs_type_part
|
||||
$lhs_type_part,
|
||||
$template_result
|
||||
);
|
||||
if ($nested_output_type !== null) {
|
||||
$output_type_extends = Type::combineUnionTypes(
|
||||
@ -214,6 +230,10 @@ class ClassTemplateParamCollector
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$type_extends_atomic->replaceTemplateTypesWithArgTypes(
|
||||
$template_result,
|
||||
$codebase
|
||||
);
|
||||
$output_type_extends = Type::combineUnionTypes(
|
||||
new Union([$type_extends_atomic]),
|
||||
$output_type_extends
|
||||
|
Loading…
Reference in New Issue
Block a user