Skip to content

Commit

Permalink
Fix psalm issues in CallableTypeComparator
Browse files Browse the repository at this point in the history
  • Loading branch information
klimick committed Jan 18, 2022
1 parent 7e623ed commit 5fb1df8
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/Psalm/Internal/Type/Comparator/CallableTypeComparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,9 @@ public static function getCallableFromAtomic(
$template_result = null;

if ($input_type_part instanceof Atomic\TGenericObject) {
$invokable_storage = $codebase->methods->getClassLikeStorageForMethod($declaring_method_id);
$invokable_storage = $codebase->methods->getClassLikeStorageForMethod(
$declaring_method_id ?? $invoke_id
);
$type_params = [];

foreach ($invokable_storage->template_types ?? [] as $template => $for_class) {
Expand All @@ -402,16 +404,18 @@ public static function getCallableFromAtomic(
}
}

$input_with_templates = new Atomic\TGenericObject($input_type_part->value, $type_params);
$template_result = new TemplateResult($invokable_storage->template_types ?? [], []);
if (!empty($type_params)) {
$input_with_templates = new Atomic\TGenericObject($input_type_part->value, $type_params);
$template_result = new TemplateResult($invokable_storage->template_types ?? [], []);

TemplateStandinTypeReplacer::replace(
new Type\Union([$input_with_templates]),
$template_result,
$codebase,
null,
new Type\Union([$input_type_part])
);
TemplateStandinTypeReplacer::replace(
new Type\Union([$input_with_templates]),
$template_result,
$codebase,
null,
new Type\Union([$input_type_part])
);
}
}

if ($declaring_method_id) {
Expand Down

0 comments on commit 5fb1df8

Please sign in to comment.