1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-04 18:48:03 +01:00

Simplify some logic around negations to prevent unecessary looping

This commit is contained in:
Matthew Brown 2022-01-04 16:08:06 +00:00
parent 2c6d4f8687
commit 0fffb55a83

View File

@ -176,20 +176,15 @@ class NegatedAssertionReconciler extends Reconciler
// if there wasn't a direct hit, go deeper, eliminating subtypes
if (!$existing_var_type->removeType($assertion)) {
foreach ($existing_var_type->getAtomicTypes() as $part_name => $existing_var_type_part) {
if (!$existing_var_type_part->isObjectType() || strpos($assertion, '-')) {
continue;
}
if (!strpos($assertion, '-')) {
$assertion_type = Type::parseString($assertion, null, $template_type_map);
if (!$assertion_type->isSingle()) {
continue;
}
if ($assertion_type->isSingle()) {
$new_type_part = $assertion_type->getSingleAtomic();
if (!$new_type_part instanceof TNamedObject) {
if ($new_type_part instanceof TNamedObject) {
foreach ($existing_var_type->getAtomicTypes() as $part_name => $existing_var_type_part) {
if (!$existing_var_type_part->isObjectType()) {
continue;
}
@ -213,6 +208,9 @@ class NegatedAssertionReconciler extends Reconciler
}
}
}
}
}
}
if ($is_strict_equality
&& $assertion !== 'isset'