1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\Reflection;
4:
5: use PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnumBackedCase;
6: use PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnumUnitCase;
7: use PHPStan\Internal\DeprecatedAttributeHelper;
8: use PHPStan\TrinaryLogic;
9: use PHPStan\Type\Type;
10:
11: /**
12: * @api
13: */
14: final class EnumCaseReflection
15: {
16:
17: /**
18: * @param list<AttributeReflection> $attributes
19: */
20: public function __construct(
21: private ClassReflection $declaringEnum,
22: private ReflectionEnumUnitCase|ReflectionEnumBackedCase $reflection,
23: private ?Type $backingValueType,
24: private array $attributes,
25: )
26: {
27: }
28:
29: public function getDeclaringEnum(): ClassReflection
30: {
31: return $this->declaringEnum;
32: }
33:
34: public function getName(): string
35: {
36: return $this->reflection->getName();
37: }
38:
39: public function getBackingValueType(): ?Type
40: {
41: return $this->backingValueType;
42: }
43:
44: public function isDeprecated(): TrinaryLogic
45: {
46: return TrinaryLogic::createFromBoolean($this->reflection->isDeprecated());
47: }
48:
49: public function getDeprecatedDescription(): ?string
50: {
51: if ($this->reflection->isDeprecated()) {
52: $attributes = $this->reflection->getBetterReflection()->getAttributes();
53: return DeprecatedAttributeHelper::getDeprecatedDescription($attributes);
54: }
55:
56: return null;
57: }
58:
59: /**
60: * @return list<AttributeReflection>
61: */
62: public function getAttributes(): array
63: {
64: return $this->attributes;
65: }
66:
67: }
68: