1: <?php
2:
3: declare(strict_types=1);
4:
5: namespace PHPStan\BetterReflection\Reflection;
6:
7: use PropertyHookType as CoreReflectionPropertyHookType;
8:
9: /**
10: * It's a copy of native PropertyHookType enum.
11: *
12: * It's used to avoid dependency on native enum in better ReflectionProperty class.
13: * Thanks to this we can support PHP version < 8.4.
14: *
15: * @see CoreReflectionPropertyHookType
16: */
17: class ReflectionPropertyHookType
18: {
19: const Get = 'get';
20: const Set = 'set';
21:
22: /** @psalm-suppress UndefinedClass */
23: public static function fromCoreReflectionPropertyHookType(CoreReflectionPropertyHookType $hookType): string
24: {
25: if ($hookType === CoreReflectionPropertyHookType::Get) {
26: return self::Get;
27: }
28:
29: if ($hookType === CoreReflectionPropertyHookType::Set) {
30: return self::Set;
31: }
32:
33: throw new \LogicException('Unknown hook type');
34: }
35: }
36: