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