1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\Reflection;
4:
5: use PHPStan\TrinaryLogic;
6: use PHPStan\Type\Type;
7:
8: /**
9: * Reflection for a class property.
10: *
11: * This is the interface extension developers should implement when creating
12: * custom PropertiesClassReflectionExtension implementations for magic properties.
13: *
14: * Properties have separate readable and writable types to support:
15: * - Asymmetric types (PHP 8.4+ property hooks with different get/set types)
16: * - Read-only properties (readable but not writable)
17: * - Write-only properties (writable but not readable, rare)
18: *
19: * For additional property metadata (native types, PHPDoc types, hooks, attributes),
20: * see ExtendedPropertyReflection which extends this interface.
21: *
22: * @api
23: */
24: interface PropertyReflection extends ClassMemberReflection
25: {
26:
27: public function getReadableType(): Type;
28:
29: /**
30: * May differ from the readable type for properties with asymmetric visibility
31: * or property hooks with different get/set types.
32: */
33: public function getWritableType(): Type;
34:
35: /**
36: * Returns true when the readable and writable types are the same and no property hooks
37: * transform the value — PHPStan can then narrow the property's type based on assignments.
38: * Returns false when read and write types differ (e.g. `@property` with asymmetric types,
39: * property hooks, virtual properties).
40: */
41: public function canChangeTypeAfterAssignment(): bool;
42:
43: public function isReadable(): bool;
44:
45: public function isWritable(): bool;
46:
47: public function isDeprecated(): TrinaryLogic;
48:
49: public function getDeprecatedDescription(): ?string;
50:
51: public function isInternal(): TrinaryLogic;
52:
53: }
54: