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

Process reconciliation more aptly

This commit is contained in:
Brown 2019-10-08 14:33:06 -04:00
parent 6b012f8fa6
commit 5265aee278
2 changed files with 31 additions and 0 deletions

View File

@ -273,6 +273,14 @@ class NegatedAssertionReconciler extends Reconciler
false
)) {
$existing_var_type->removeType($part_name);
} elseif (TypeAnalyzer::isAtomicContainedBy(
$codebase,
$new_type_part,
$existing_var_type_part,
false,
false
)) {
$existing_var_type->different = true;
}
}
}

View File

@ -1474,6 +1474,29 @@ class TypeReconciliationTest extends TestCase
takes_int($int);
}'
],
'removeAllObjects' => [
'<?php
class A {}
class B extends A {
public function foo() : void {}
}
class BChild extends B {}
class C extends A {}
class D extends A {}
/** @param B|C|D $a */
function foo(A $a) : B {
if ($a instanceof C) {
$a = new B();
} elseif ($a instanceof D) {
$a = new B();
} elseif (!$a instanceof BChild) {
// do something
}
return $a;
}'
],
];
}