Skip to content

Commit 76045f5

Browse files
committed
Add unit test for #13048
1 parent 8bb2a20 commit 76045f5

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

tests/PHPStan/Rules/Comparison/MatchExpressionRuleTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,4 +435,11 @@ public function testPropertyHooks(): void
435435
]);
436436
}
437437

438+
439+
#[RequiresPhp('>= 8.0')]
440+
public function testBug13048(): void
441+
{
442+
$this->analyse([__DIR__ . '/data/bug-13048.php'], []);
443+
}
444+
438445
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php // lint >= 8.0
2+
3+
namespace Bug11852;
4+
5+
enum IndexBy {
6+
case A;
7+
case B;
8+
}
9+
10+
/**
11+
* @template T of IndexBy|null
12+
* @param T $indexBy
13+
* @return (T is null ? null : string)
14+
*/
15+
function run(?IndexBy $indexBy = null): ?string
16+
{
17+
return match ($indexBy) {
18+
IndexBy::A => 'by A',
19+
IndexBy::B => 'by B',
20+
null => null,
21+
};
22+
}

0 commit comments

Comments
 (0)