File tree Expand file tree Collapse file tree 3 files changed +39
-0
lines changed
tests/PHPStan/Rules/Comparison Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -327,6 +327,10 @@ public function equals(Type $type): bool
327327 return false ;
328328 }
329329
330+ if ($ type instanceof EnumCaseObjectType) {
331+ return false ;
332+ }
333+
330334 if ($ this ->className !== $ type ->className ) {
331335 return false ;
332336 }
Original file line number Diff line number Diff line change @@ -158,4 +158,13 @@ public function testEnums(): void
158158 ]);
159159 }
160160
161+ public function testBug6394 (): void
162+ {
163+ if (PHP_VERSION_ID < 80100 ) {
164+ $ this ->markTestSkipped ('Test requires PHP 8.1. ' );
165+ }
166+
167+ $ this ->analyse ([__DIR__ . '/data/bug-6394.php ' ], []);
168+ }
169+
161170}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Bug6394 ;
4+
5+ enum EntryType: string
6+ {
7+ case CREDIT = 'credit ' ;
8+ case DEBIT = 'debit ' ;
9+ }
10+
11+ class Foo
12+ {
13+
14+ public function getType (): EntryType
15+ {
16+ return $ this ->type ;
17+ }
18+
19+ public function getAmount (): int
20+ {
21+ return match ($ this ->getType ()) {
22+ EntryType::DEBIT => 1 ,
23+ EntryType::CREDIT => 2 ,
24+ };
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments