File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed
tests/PHPStan/Rules/Methods Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -3514,4 +3514,18 @@ public function testBug12544(): void
35143514 ]);
35153515 }
35163516
3517+ public function testBug12422 (): void
3518+ {
3519+ if (PHP_VERSION_ID < 80100 ) {
3520+ self ::markTestSkipped ('Test requires PHP 8.1. ' );
3521+ }
3522+
3523+ $ this ->checkThisOnly = false ;
3524+ $ this ->checkNullables = true ;
3525+ $ this ->checkUnionTypes = true ;
3526+ $ this ->checkExplicitMixed = true ;
3527+
3528+ $ this ->analyse ([__DIR__ . '/data/bug-12422.php ' ], []);
3529+ }
3530+
35173531}
Original file line number Diff line number Diff line change 1+ <?php // lint >= 8.1
2+
3+ namespace Bug12422 ;
4+
5+ enum MyEnum
6+ {
7+ case A;
8+ case B;
9+ }
10+
11+ class MyClass
12+ {
13+ public function fooo (): void
14+ {
15+ }
16+ }
17+
18+ function test (MyEnum $ enum , ?MyClass $ bar ): void
19+ {
20+ if ($ enum === MyEnum::A && $ bar === null ) {
21+ return ;
22+ }
23+
24+ match ($ enum ) {
25+ MyEnum::A => $ bar ->fooo (),
26+ MyEnum::B => null ,
27+ };
28+ }
You can’t perform that action at this time.
0 commit comments