diff --git a/src/Psalm/Internal/Type/AssertionReconciler.php b/src/Psalm/Internal/Type/AssertionReconciler.php index b33d7b3a9..ac8419f3b 100644 --- a/src/Psalm/Internal/Type/AssertionReconciler.php +++ b/src/Psalm/Internal/Type/AssertionReconciler.php @@ -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; diff --git a/tests/EnumTest.php b/tests/EnumTest.php index f1aa23031..f36ebbef8 100644 --- a/tests/EnumTest.php +++ b/tests/EnumTest.php @@ -527,6 +527,21 @@ class EnumTest extends TestCase 'ignored_issues' => [], 'php_version' => '8.1', ], + 'reconcileCaseWithInterface' => [ + 'code' => <<<'PHP' + [], + 'ignored_issues' => [], + 'php_version' => '8.1', + ], ]; }