Skip to content

Commit

Permalink
Make ReflectionEnum generic
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Nov 19, 2023
1 parent 58d53bf commit 9ce8faf
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions conf/config.neon
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ parameters:
- InfiniteIterator
- CachingIterator
- RegexIterator
- ReflectionEnum
explicitMixedInUnknownGenericNew: false
explicitMixedForGlobalVariables: false
explicitMixedViaIsArray: false
Expand Down
20 changes: 20 additions & 0 deletions stubs/ReflectionClass.stub
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,23 @@ class ReflectionClass
{
}
}

/**
* @template-covariant T of UnitEnum
* @extends ReflectionClass<T>
*/
class ReflectionEnum extends ReflectionClass

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Compiler Tests

PHPDoc tag @extends has invalid type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Compiler Tests

PHPDoc tag @template T for class ReflectionEnum has invalid bound type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

PHPDoc tag @extends has invalid type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

PHPDoc tag @template T for class ReflectionEnum has invalid bound type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, ubuntu-latest)

PHPDoc tag @extends has invalid type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, ubuntu-latest)

PHPDoc tag @template T for class ReflectionEnum has invalid bound type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

PHPDoc tag @extends has invalid type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

PHPDoc tag @template T for class ReflectionEnum has invalid bound type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.4, ubuntu-latest)

PHPDoc tag @extends has invalid type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.4, ubuntu-latest)

PHPDoc tag @template T for class ReflectionEnum has invalid bound type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (8.0, ubuntu-latest)

PHPDoc tag @extends has invalid type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (8.0, ubuntu-latest)

PHPDoc tag @template T for class ReflectionEnum has invalid bound type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.3, ubuntu-latest)

PHPDoc tag @extends has invalid type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.3, ubuntu-latest)

PHPDoc tag @template T for class ReflectionEnum has invalid bound type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, ubuntu-latest)

PHPDoc tag @extends has invalid type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, ubuntu-latest)

PHPDoc tag @template T for class ReflectionEnum has invalid bound type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

PHPDoc tag @extends has invalid type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

PHPDoc tag @template T for class ReflectionEnum has invalid bound type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests with old PHPUnit (7.2, ubuntu-latest)

PHPDoc tag @extends has invalid type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests with old PHPUnit (7.2, ubuntu-latest)

PHPDoc tag @template T for class ReflectionEnum has invalid bound type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, windows-latest)

PHPDoc tag @extends has invalid type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, windows-latest)

PHPDoc tag @template T for class ReflectionEnum has invalid bound type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

PHPDoc tag @extends has invalid type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

PHPDoc tag @template T for class ReflectionEnum has invalid bound type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.4, windows-latest)

PHPDoc tag @extends has invalid type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.4, windows-latest)

PHPDoc tag @template T for class ReflectionEnum has invalid bound type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (8.0, windows-latest)

PHPDoc tag @extends has invalid type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (8.0, windows-latest)

PHPDoc tag @template T for class ReflectionEnum has invalid bound type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.3, windows-latest)

PHPDoc tag @extends has invalid type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.3, windows-latest)

PHPDoc tag @template T for class ReflectionEnum has invalid bound type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, windows-latest)

PHPDoc tag @extends has invalid type UnitEnum.

Check failure on line 56 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, windows-latest)

PHPDoc tag @template T for class ReflectionEnum has invalid bound type UnitEnum.
{

/**
* @return (T is BackedEnum ? ReflectionEnumBackedCase[] : ReflectionEnumUnitCase[])
*/
public function getCases(): array {}

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Compiler Tests

Method ReflectionEnum::getCases() has invalid return type BackedEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Compiler Tests

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumBackedCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Compiler Tests

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumUnitCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Compiler Tests

Method ReflectionEnum::getCases() has invalid return type UnitEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type BackedEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumBackedCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumUnitCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type UnitEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type BackedEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumBackedCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumUnitCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type UnitEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type BackedEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumBackedCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumUnitCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type UnitEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.4, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type BackedEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.4, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumBackedCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.4, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumUnitCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.4, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type UnitEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (8.0, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type BackedEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (8.0, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumBackedCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (8.0, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumUnitCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (8.0, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type UnitEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.3, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type BackedEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.3, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumBackedCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.3, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumUnitCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.3, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type UnitEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type BackedEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumBackedCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumUnitCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type UnitEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Method ReflectionEnum::getCases() has invalid return type BackedEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumBackedCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumUnitCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Method ReflectionEnum::getCases() has invalid return type UnitEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests with old PHPUnit (7.2, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type BackedEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests with old PHPUnit (7.2, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumBackedCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests with old PHPUnit (7.2, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumUnitCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests with old PHPUnit (7.2, ubuntu-latest)

Method ReflectionEnum::getCases() has invalid return type UnitEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, windows-latest)

Method ReflectionEnum::getCases() has invalid return type BackedEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, windows-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumBackedCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, windows-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumUnitCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, windows-latest)

Method ReflectionEnum::getCases() has invalid return type UnitEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Method ReflectionEnum::getCases() has invalid return type BackedEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumBackedCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumUnitCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Method ReflectionEnum::getCases() has invalid return type UnitEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.4, windows-latest)

Method ReflectionEnum::getCases() has invalid return type BackedEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.4, windows-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumBackedCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.4, windows-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumUnitCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.4, windows-latest)

Method ReflectionEnum::getCases() has invalid return type UnitEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (8.0, windows-latest)

Method ReflectionEnum::getCases() has invalid return type BackedEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (8.0, windows-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumBackedCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (8.0, windows-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumUnitCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (8.0, windows-latest)

Method ReflectionEnum::getCases() has invalid return type UnitEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.3, windows-latest)

Method ReflectionEnum::getCases() has invalid return type BackedEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.3, windows-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumBackedCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.3, windows-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumUnitCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.3, windows-latest)

Method ReflectionEnum::getCases() has invalid return type UnitEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, windows-latest)

Method ReflectionEnum::getCases() has invalid return type BackedEnum.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, windows-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumBackedCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, windows-latest)

Method ReflectionEnum::getCases() has invalid return type ReflectionEnumUnitCase.

Check failure on line 62 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, windows-latest)

Method ReflectionEnum::getCases() has invalid return type UnitEnum.

/**
* @return (T is BackedEnum ? ReflectionEnumBackedCase : ReflectionEnumUnitCase)
* @throws ReflectionException If no found single reflection object for the corresponding case
*/
public function getCase(string $name): ReflectionEnumUnitCase {}

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Compiler Tests

Method ReflectionEnum::getCase() has invalid return type BackedEnum.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Compiler Tests

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumBackedCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Compiler Tests

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Compiler Tests

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type BackedEnum.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumBackedCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type BackedEnum.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumBackedCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type BackedEnum.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumBackedCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.4, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type BackedEnum.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.4, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumBackedCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.4, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.4, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (8.0, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type BackedEnum.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (8.0, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumBackedCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (8.0, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (8.0, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.3, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type BackedEnum.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.3, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumBackedCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.3, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.3, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type BackedEnum.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumBackedCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Method ReflectionEnum::getCase() has invalid return type BackedEnum.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumBackedCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests with old PHPUnit (7.2, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type BackedEnum.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests with old PHPUnit (7.2, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumBackedCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests with old PHPUnit (7.2, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests with old PHPUnit (7.2, ubuntu-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, windows-latest)

Method ReflectionEnum::getCase() has invalid return type BackedEnum.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, windows-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumBackedCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, windows-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, windows-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Method ReflectionEnum::getCase() has invalid return type BackedEnum.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumBackedCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.4, windows-latest)

Method ReflectionEnum::getCase() has invalid return type BackedEnum.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.4, windows-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumBackedCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.4, windows-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.4, windows-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (8.0, windows-latest)

Method ReflectionEnum::getCase() has invalid return type BackedEnum.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (8.0, windows-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumBackedCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (8.0, windows-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (8.0, windows-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.3, windows-latest)

Method ReflectionEnum::getCase() has invalid return type BackedEnum.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.3, windows-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumBackedCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.3, windows-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / Tests (7.3, windows-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, windows-latest)

Method ReflectionEnum::getCase() has invalid return type BackedEnum.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, windows-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumBackedCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, windows-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

Check failure on line 68 in stubs/ReflectionClass.stub

View workflow job for this annotation

GitHub Actions / PHPStan (7.2, windows-latest)

Method ReflectionEnum::getCase() has invalid return type ReflectionEnumUnitCase.

}
1 change: 1 addition & 0 deletions tests/PHPStan/Analyser/NodeScopeResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ public function dataFileAsserts(): iterable

if (PHP_VERSION_ID >= 80100) {
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-9734.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/enum-reflection.php');
}

yield from $this->gatherAssertTypes(__DIR__ . '/data/match-expr.php');
Expand Down
43 changes: 43 additions & 0 deletions tests/PHPStan/Analyser/data/enum-reflection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php // lint >= 8.1

namespace EnumReflection;

use ReflectionEnum;
use ReflectionEnumBackedCase;
use ReflectionEnumUnitCase;
use function PHPStan\Testing\assertType;

enum Foo: int
{

case FOO = 1;
case BAR = 2;

public function doFoo(): void
{
$r = new ReflectionEnum(self::class);
foreach ($r->getCases() as $case) {
assertType(ReflectionEnumBackedCase::class, $case);
}

assertType(ReflectionEnumBackedCase::class, $r->getCase('FOO'));
}

}

enum Bar
{

case FOO;
case BAR;

public function doFoo(): void
{
$r = new ReflectionEnum(self::class);
foreach ($r->getCases() as $case) {
assertType(ReflectionEnumUnitCase::class, $case);
}
assertType(ReflectionEnumUnitCase::class, $r->getCase('FOO'));
}

}

0 comments on commit 9ce8faf

Please sign in to comment.