1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 12:55:26 +01:00

Improve handling of T::class when mixed is passed

This commit is contained in:
Matthew Brown 2018-12-13 01:54:15 -05:00
parent 8b5e8402a1
commit a8851ff425
2 changed files with 7 additions and 2 deletions

View File

@ -90,7 +90,8 @@ class ConstFetchAnalyzer
) {
$codebase = $statements_analyzer->getCodebase();
if ($context->check_consts
if (($context->check_consts
|| ($stmt->name instanceof PhpParser\Node\Identifier && $stmt->name->name === 'class'))
&& $stmt->class instanceof PhpParser\Node\Name
) {
$first_part_lc = strtolower($stmt->class->parts[0]);

View File

@ -778,6 +778,8 @@ class Union
if ($valid_input_atomic_types) {
$generic_params[$atomic_type->param_name] = new Union($valid_input_atomic_types);
$generic_params[$atomic_type->param_name]->setFromDocblock();
} else {
$generic_params[$atomic_type->param_name] = Type::getMixed();
}
}
} else {
@ -848,7 +850,9 @@ class Union
$is_mixed = false;
foreach ($this->types as $key => $atomic_type) {
if (isset($template_types[$key])) {
if ($atomic_type instanceof Type\Atomic\TGenericParam
&& isset($template_types[$key])
) {
$keys_to_unset[] = $key;
$template_type = clone $template_types[$key];