1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\Reflection;
4:
5: use PHPStan\TrinaryLogic;
6: use PHPStan\Turbo\ReferencedByTurboExtension;
7: use PHPStan\Type\Type;
8:
9: /**
10: * Extended property reflection with additional metadata beyond PropertyReflection.
11: *
12: * This interface exists to allow PHPStan to add new property query methods in minor
13: * versions without breaking existing PropertiesClassReflectionExtension implementations.
14: * Extension developers should implement PropertyReflection, not this interface — PHPStan
15: * wraps PropertyReflection implementations to provide ExtendedPropertyReflection.
16: *
17: * Provides access to:
18: * - Separate PHPDoc type vs native type (for resolving the effective type)
19: * - Property hooks (PHP 8.4+) — get/set hooks with their own method reflections
20: * - Asymmetric visibility (PHP 8.4+) — different read/write visibility
21: * - Abstract/final/virtual modifiers
22: * - PHP attributes
23: *
24: * This is the return type of Type::getProperty(), Type::getInstanceProperty(),
25: * and Type::getStaticProperty().
26: *
27: * @api
28: * @api-do-not-implement
29: */
30: #[ReferencedByTurboExtension(key: 'extendedPropertyReflection')]
31: interface ExtendedPropertyReflection extends PropertyReflection
32: {
33:
34: public const HOOK_GET = 'get';
35:
36: public const HOOK_SET = 'set';
37:
38: public function getName(): string;
39:
40: public function hasPhpDocType(): bool;
41:
42: public function getPhpDocType(): Type;
43:
44: public function hasNativeType(): bool;
45:
46: public function getNativeType(): Type;
47:
48: public function isAbstract(): TrinaryLogic;
49:
50: public function isFinalByKeyword(): TrinaryLogic;
51:
52: public function isFinal(): TrinaryLogic;
53:
54: /**
55: * Virtual properties (PHP 8.4+) exist only through their get/set hooks
56: * and don't occupy memory in the object.
57: */
58: public function isVirtual(): TrinaryLogic;
59:
60: /** @param self::HOOK_* $hookType */
61: public function hasHook(string $hookType): bool;
62:
63: /**
64: * Property hooks (PHP 8.4+) are internally represented as methods.
65: *
66: * @param self::HOOK_* $hookType
67: */
68: public function getHook(string $hookType): ExtendedMethodReflection;
69:
70: public function isProtectedSet(): bool;
71:
72: public function isPrivateSet(): bool;
73:
74: /** @return list<AttributeReflection> */
75: public function getAttributes(): array;
76:
77: /**
78: * Returns yes() for properties that represent possibly-defined properties
79: * on non-final classes, mixed, object, etc. — placeholders PHPStan creates
80: * when it cannot prove a property doesn't exist.
81: */
82: public function isDummy(): TrinaryLogic;
83:
84: }
85: