diff --git a/resources/functionMap_php81delta.php b/resources/functionMap_php81delta.php index 48f1f8decf..54a3199934 100644 --- a/resources/functionMap_php81delta.php +++ b/resources/functionMap_php81delta.php @@ -27,6 +27,7 @@ 'mysqli_result::fetch_field' => ['(stdClass&object{name: string, orgname: string, table: string, orgtable: string, def: string, db: string, catalog: "def", max_length: 0, length: int, charsetnr: string, flags: int, type: int, decimals: int})|false'], 'mysqli_result::fetch_field_direct' => ['(stdClass&object{name: string, orgname: string, table: string, orgtable: string, def: string, db: string, catalog: "def", max_length: 0, length: int, charsetnr: string, flags: int, type: int, decimals: int})|false', 'fieldnr'=>'int'], 'mysqli_result::fetch_fields' => ['list'], + 'UnitEnum::cases' => ['list'], ], 'old' => [ 'pg_escape_bytea' => ['string', 'connection'=>'resource', 'data'=>'string'], diff --git a/stubs/runtime/Enum/UnitEnum.php b/stubs/runtime/Enum/UnitEnum.php index a8d1a8d468..0a9e6282e6 100644 --- a/stubs/runtime/Enum/UnitEnum.php +++ b/stubs/runtime/Enum/UnitEnum.php @@ -8,7 +8,7 @@ interface UnitEnum { /** - * @return static[] + * @return list */ public static function cases(): array; } diff --git a/tests/PHPStan/Analyser/nsrt/bug-11233.php b/tests/PHPStan/Analyser/nsrt/bug-11233.php new file mode 100644 index 0000000000..e8191d37a5 --- /dev/null +++ b/tests/PHPStan/Analyser/nsrt/bug-11233.php @@ -0,0 +1,30 @@ += 8.1 + +namespace Bug11233; + +use function PHPStan\Testing\assertType; + +class EnumExtension +{ + /** + * @template T of \UnitEnum + * + * @param class-string $enum + */ + public static function getEnumCases(string $enum): void + { + assertType('list', $enum::cases()); + } + + /** + * @template T of \BackedEnum + * + * @param class-string $enum + * + * @return list + */ + public static function getEnumCases2(string $enum): void + { + assertType('list', $enum::cases()); + } +} diff --git a/tests/PHPStan/Analyser/nsrt/bug-7162.php b/tests/PHPStan/Analyser/nsrt/bug-7162.php index f613daba6d..9b1fb4f54b 100644 --- a/tests/PHPStan/Analyser/nsrt/bug-7162.php +++ b/tests/PHPStan/Analyser/nsrt/bug-7162.php @@ -29,7 +29,7 @@ enum Test{ * @phpstan-param TEnum $case */ function dumpCases(\UnitEnum $case) : void{ - assertType('array', $case::cases()); + assertType('list', $case::cases()); } function dumpCases2(Test $case) : void{