1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

resolve ClassConstant for both sides in isContainedBy

This commit is contained in:
orklah 2022-01-03 23:21:59 +01:00
parent 36c7fece2f
commit 60732d00ba

View File

@ -84,27 +84,6 @@ class UnionTypeComparator
continue;
}
if ($input_type_part instanceof TClassConstant) {
$expanded = TypeExpander::expandAtomic(
$codebase,
$input_type_part,
$input_type_part->fq_classlike_name,
$input_type_part->fq_classlike_name,
null,
true,
true
);
if ($expanded instanceof Atomic) {
if (!$expanded instanceof TClassConstant) {
$input_atomic_types[] = $expanded;
continue;
}
} else {
$input_atomic_types = array_merge($expanded, $input_atomic_types);
continue;
}
}
$type_match_found = false;
$scalar_type_match_found = false;
@ -485,15 +464,22 @@ class UnionTypeComparator
): array {
$atomic_types = [];
foreach ($union_type->getAtomicTypes() as $atomic_type) {
if (!$atomic_type instanceof TTypeAlias) {
if (!$atomic_type instanceof TTypeAlias && !$atomic_type instanceof TClassConstant) {
$atomic_types[] = $atomic_type;
continue;
}
if ($atomic_type instanceof TTypeAlias) {
$fq_classlike_name = $atomic_type->declaring_fq_classlike_name;
} else {
$fq_classlike_name = $atomic_type->fq_classlike_name;
}
$expanded = TypeExpander::expandAtomic(
$codebase,
$atomic_type,
$atomic_type->declaring_fq_classlike_name,
$atomic_type->declaring_fq_classlike_name,
$fq_classlike_name,
$fq_classlike_name,
null,
true,
true