mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Merge pull request #9067 from weirdan/backed-enum-cases
fix `I::cases()` where `interface I extends BackedEnum`
This commit is contained in:
commit
d64023548c
@ -26,6 +26,12 @@ namespace {
|
||||
* @psalm-pure
|
||||
*/
|
||||
public static function tryFrom(string|int $value): ?static;
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @return list<static>
|
||||
*/
|
||||
public static function cases(): array;
|
||||
}
|
||||
|
||||
class ReflectionClass implements Reflector {
|
||||
|
@ -453,6 +453,22 @@ class EnumTest extends TestCase
|
||||
'ignored_issues' => [],
|
||||
'php_version' => '8.1',
|
||||
],
|
||||
'methodInheritanceByInterfaces' => [
|
||||
'code' => '<?php
|
||||
interface I extends BackedEnum {}
|
||||
/** @var I $i */
|
||||
$a = $i::cases();
|
||||
$b = $i::from(1);
|
||||
$c = $i::tryFrom(2);
|
||||
',
|
||||
'assertions' => [
|
||||
'$a===' => 'list<I>',
|
||||
'$b===' => 'I',
|
||||
'$c===' => 'I|null',
|
||||
],
|
||||
'ignored_issues' => [],
|
||||
'php_version' => '8.1',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user