1
0
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:
orklah 2023-01-07 21:05:35 +01:00 committed by GitHub
commit d64023548c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -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 {

View File

@ -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',
],
];
}