Skip to content

Commit 2be8600

Browse files
staabmondrejmirtes
authored andcommitted
Added regression test
1 parent 253903a commit 2be8600

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
}

0 commit comments

Comments
 (0)