1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Added pure annotations to enum functions

This commit is contained in:
Ricardo Boss 2021-12-20 23:20:50 +01:00
parent 8182684941
commit f0d7556200

View File

@ -4,14 +4,25 @@ namespace {
/** @var non-empty-string $name */
public readonly string $name;
/** @return non-empty-list<static> */
/**
* @psalm-pure
* @return non-empty-list<static>
*/
public static function cases(): array;
}
interface BackedEnum
{
public readonly int|string $value;
/**
* @psalm-pure
*/
public static function from(string|int $value): static;
/**
* @psalm-pure
*/
public static function tryFrom(string|int $value): ?static;
}
@ -27,12 +38,22 @@ namespace {
class ReflectionEnumUnitCase extends ReflectionClassConstant implements Reflector
{
/**
* @psalm-pure
*/
public function getEnum(): ReflectionEnum;
/**
* @psalm-pure
*/
public function getValue(): UnitEnum;
}
class ReflectionEnumBackedCase extends ReflectionEnumUnitCase implements Reflector
{
/**
* @psalm-pure
*/
public function getBackingValue(): int|string;
}
}