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:
parent
6b012f8fa6
commit
5265aee278
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user