diff --git a/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php b/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php index fd44ac82e..b0f461ccf 100644 --- a/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php @@ -301,6 +301,13 @@ class AtomicTypeComparator return false; } + if ($container_type_part instanceof TEnumCase + && $input_type_part instanceof TEnumCase + ) { + return $container_type_part->value === $input_type_part->value + && $container_type_part->case_name === $input_type_part->case_name; + } + if (($input_type_part instanceof TNamedObject || ($input_type_part instanceof TTemplateParam && $input_type_part->as->hasObjectType()) diff --git a/tests/EnumTest.php b/tests/EnumTest.php index 74483e04b..f1aa23031 100644 --- a/tests/EnumTest.php +++ b/tests/EnumTest.php @@ -861,6 +861,77 @@ class EnumTest extends TestCase 'ignored_issues' => [], 'php_version' => '8.1', ], + 'functionCallWithInvalidCase' => [ + 'code' => ' 'InvalidArgument', + 'ignored_issues' => [], + 'php_version' => '8.1', + ], + 'issue-7814-1' => [ + 'code' => ' 'InvalidArgument', + 'ignored_issues' => [], + 'php_version' => '8.1', + ], + 'issue-7814-2' => [ + 'code' => ' $_ + */ + function withA(WithState $_): void {} + + // Should be issue here. But nothing + // Argument 1 of withA expects WithState, WithState provided + withA(new WithState(State::C)); + ', + 'error_message' => 'InvalidArgument', + 'ignored_issues' => [], + 'php_version' => '8.1', + ], ]; } }