mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Merge pull request #9457 from weirdan/improve-enum-case-reconciliation
This commit is contained in:
commit
dc4516b408
@ -945,6 +945,15 @@ class AssertionReconciler extends Reconciler
|
||||
$redundant = false;
|
||||
$existing_var_type->removeType($atomic_key);
|
||||
$existing_var_type->addType(new TEnumCase($fq_enum_name, $case_name));
|
||||
} elseif (AtomicTypeComparator::canBeIdentical(
|
||||
$statements_analyzer->getCodebase(),
|
||||
$atomic_type,
|
||||
$assertion_type,
|
||||
)) {
|
||||
$can_be_equal = true;
|
||||
$redundant = $atomic_key === $assertion_type->getKey();
|
||||
$existing_var_type->removeType($atomic_key);
|
||||
$existing_var_type->addType(new TEnumCase($fq_enum_name, $case_name));
|
||||
} elseif ($atomic_key !== $assertion_type->getKey()) {
|
||||
$existing_var_type->removeType($atomic_key);
|
||||
$redundant = false;
|
||||
|
@ -527,6 +527,21 @@ class EnumTest extends TestCase
|
||||
'ignored_issues' => [],
|
||||
'php_version' => '8.1',
|
||||
],
|
||||
'reconcileCaseWithInterface' => [
|
||||
'code' => <<<'PHP'
|
||||
<?php
|
||||
interface I {}
|
||||
enum E implements I { case A; }
|
||||
function f(I $i): void {
|
||||
if ($i === E::A) {
|
||||
} else {
|
||||
}
|
||||
}
|
||||
PHP,
|
||||
'assertions' => [],
|
||||
'ignored_issues' => [],
|
||||
'php_version' => '8.1',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user