1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

fix I::cases() where interface I extends BackedEnum

Fixes vimeo/psalm#9065

Inheritance in stubs seems to be broken
This commit is contained in:
Bruce Weirdan 2023-01-05 21:35:47 -04:00
parent 8329309999
commit afb8c8891b
No known key found for this signature in database
GPG Key ID: CFC3AAB181751B0D
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',
],
];
}