1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 13:51:54 +01:00

Ignore non-existing classes during initial scan of intersection types

This commit is contained in:
Daniil Gentili 2022-11-30 17:33:58 +01:00
parent 870f5817d2
commit 9c35ed2eb7

View File

@ -850,12 +850,16 @@ abstract class Type
) { ) {
/** @psalm-suppress TypeDoesNotContainType */ /** @psalm-suppress TypeDoesNotContainType */
if ($type_1_atomic instanceof TNamedObject && $type_2_atomic instanceof TNamedObject) { if ($type_1_atomic instanceof TNamedObject && $type_2_atomic instanceof TNamedObject) {
$first = $codebase->classlike_storage_provider->get($type_1_atomic->value); try {
$second = $codebase->classlike_storage_provider->get($type_2_atomic->value); $first = $codebase->classlike_storage_provider->get($type_1_atomic->value);
$first_is_class = !$first->is_interface && !$first->is_trait; $second = $codebase->classlike_storage_provider->get($type_2_atomic->value);
$second_is_class = !$second->is_interface && !$second->is_trait; $first_is_class = !$first->is_interface && !$first->is_trait;
if ($first_is_class && $second_is_class) { $second_is_class = !$second->is_interface && !$second->is_trait;
return $intersection_atomic; if ($first_is_class && $second_is_class) {
return $intersection_atomic;
}
} catch (InvalidArgumentException $e) {
// Ignore non-existing classes during initial scan
} }
} }
if ($intersection_atomic === null && $wider_type === null) { if ($intersection_atomic === null && $wider_type === null) {
@ -914,7 +918,12 @@ abstract class Type
if (!$type instanceof TNamedObject) { if (!$type instanceof TNamedObject) {
return false; return false;
} }
$storage = $codebase->classlike_storage_provider->get($type->value); try {
$storage = $codebase->classlike_storage_provider->get($type->value);
} catch (InvalidArgumentException $e) {
// Ignore non-existing classes during initial scan
return true;
}
return !$storage->final; return !$storage->final;
} }