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

Reconcile IsNotType between EnumCase and NamedObject

This commit is contained in:
orklah 2022-02-13 17:43:40 +01:00
parent 59d3d2aa31
commit 586c70c8d3

View File

@ -16,7 +16,6 @@ use Psalm\Type;
use Psalm\Type\Atomic;
use Psalm\Type\Atomic\TArray;
use Psalm\Type\Atomic\TClassString;
use Psalm\Type\Atomic\TEmptyMixed;
use Psalm\Type\Atomic\TEnumCase;
use Psalm\Type\Atomic\TFalse;
use Psalm\Type\Atomic\TFloat;
@ -162,6 +161,14 @@ class NegatedAssertionReconciler extends Reconciler
return $existing_var_type;
}
if (!$is_equality && $assertion_type instanceof TNamedObject) {
foreach ($existing_var_type->getAtomicTypes() as $key => $type) {
if ($type instanceof TEnumCase && $type->value === $assertion_type->value) {
$existing_var_type->removeType($key);
}
}
}
$codebase = $statements_analyzer->getCodebase();
if ($assertion_type instanceof TNamedObject
@ -291,7 +298,7 @@ class NegatedAssertionReconciler extends Reconciler
$failed_reconciliation = Reconciler::RECONCILIATION_EMPTY;
return new Union([new TEmptyMixed]);
return Type::getNever();
}
return $existing_var_type;