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