Skip to content

Commit

Permalink
Merge pull request #8376 from Daeroni/fix-8373
Browse files Browse the repository at this point in the history
Use classlike_storage_provider only if it has the required data
  • Loading branch information
AndrolGenhald committed Aug 8, 2022
2 parents 57fcc39 + 89b7b32 commit aae5395
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Psalm/Internal/Type/TemplateStandinTypeReplacer.php
Expand Up @@ -1138,7 +1138,7 @@ public static function getMappedGenericTypeParams(
): array {
if ($input_type_part instanceof TGenericObject || $input_type_part instanceof TIterable) {
$input_type_params = $input_type_part->type_params;
} else {
} elseif ($codebase->classlike_storage_provider->has($input_type_part->value)) {
$class_storage = $codebase->classlike_storage_provider->get($input_type_part->value);

$container_class = $container_type_part->value;
Expand All @@ -1150,6 +1150,8 @@ public static function getMappedGenericTypeParams(
} else {
$input_type_params = array_fill(0, count($class_storage->template_types ?? []), Type::getMixed());
}
} else {
$input_type_params = [];
}

try {
Expand Down
16 changes: 16 additions & 0 deletions tests/Template/ClassTemplateTest.php
Expand Up @@ -3826,6 +3826,22 @@ private function acceptA(A $_a): void
}
}',
],
'undefined class in function dockblock' => [
'<?php
/**
* @psalm-suppress UndefinedDocblockClass
*
* @param DoesNotExist<int> $baz
*/
function foobar(DoesNotExist $baz): void {}
/**
* @psalm-suppress UndefinedDocblockClass, UndefinedClass
* @var DoesNotExist
*/
$baz = new DoesNotExist();
foobar($baz);',
],
];
}

Expand Down

0 comments on commit aae5395

Please sign in to comment.