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

Merge pull request #8376 from Daeroni/fix-8373

Use classlike_storage_provider only if it has the required data
This commit is contained in:
AndrolGenhald 2022-08-08 16:01:49 -05:00 committed by GitHub
commit aae539560b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -1138,7 +1138,7 @@ class TemplateStandinTypeReplacer
): 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;
@ -1150,6 +1150,8 @@ class TemplateStandinTypeReplacer
} else {
$input_type_params = array_fill(0, count($class_storage->template_types ?? []), Type::getMixed());
}
} else {
$input_type_params = [];
}
try {

View File

@ -3826,6 +3826,22 @@ class ClassTemplateTest extends TestCase
}
}',
],
'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);',
],
];
}