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: public function __construct(private ClassReflection $declaringEnum, private ReflectionEnumUnitCase|ReflectionEnumBackedCase $reflection, private ?Type $backingValueType)
18: {
19: }
20:
21: public function getDeclaringEnum(): ClassReflection
22: {
23: return $this->declaringEnum;
24: }
25:
26: public function getName(): string
27: {
28: return $this->reflection->getName();
29: }
30:
31: public function getBackingValueType(): ?Type
32: {
33: return $this->backingValueType;
34: }
35:
36: public function isDeprecated(): TrinaryLogic
37: {
38: return TrinaryLogic::createFromBoolean($this->reflection->isDeprecated());
39: }
40:
41: public function getDeprecatedDescription(): ?string
42: {
43: if ($this->reflection->isDeprecated()) {
44: $attributes = $this->reflection->getBetterReflection()->getAttributes();
45: return DeprecatedAttributeHelper::getDeprecatedDescription($attributes);
46: }
47:
48: return null;
49: }
50:
51: }
52: