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: /**
23: * @param \PropertyHookType::* $hookType
24: */
25: public static function fromCoreReflectionPropertyHookType($hookType): string
26: {
27: if ($hookType === CoreReflectionPropertyHookType::Get) {
28: return self::Get;
29: }
30:
31: if ($hookType === CoreReflectionPropertyHookType::Set) {
32: return self::Set;
33: }
34:
35: throw new \LogicException('Unknown hook type');
36: }
37: }
38: