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