Skip to content

Commit 113c0cf

Browse files
committed
Add test
1 parent 9ae7517 commit 113c0cf

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

tests/PHPStan/Rules/Pure/PureFunctionRuleTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,10 @@ public function testBug12224(): void
174174
]);
175175
}
176176

177+
#[RequiresPhp('>= 8.1')]
178+
public function testBug13201(): void
179+
{
180+
$this->analyse([__DIR__ . '/data/bug-13201.php'], []);
181+
}
182+
177183
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php // lint >= 8.1
2+
3+
namespace PHPStan\Rules\Pure\data\Bug13201;
4+
5+
enum Foo: string
6+
{
7+
8+
case Bar = 'bar';
9+
case Unknown = 'unknown';
10+
11+
}
12+
13+
/**
14+
* @pure
15+
*/
16+
function createWithFallback(string $type): Foo
17+
{
18+
return Foo::tryFrom($type) ?? Foo::Unknown;
19+
}

0 commit comments

Comments
 (0)