1 | <?php |
||
12 | class ClassMetadata |
||
13 | { |
||
14 | const LOGIN_PROPERTY = 'login'; |
||
15 | const PASSWORD_PROPERTY = 'password'; |
||
16 | const API_KEY_PROPERTY = 'apiKey'; |
||
17 | const LAST_ACTION_PROPERTY = 'lastAction'; |
||
18 | |||
19 | /** |
||
20 | * @var int[] |
||
21 | */ |
||
22 | private static $requiredProperties = array( |
||
23 | self::LOGIN_PROPERTY, |
||
24 | self::PASSWORD_PROPERTY, |
||
25 | self::API_KEY_PROPERTY, |
||
26 | ); |
||
27 | |||
28 | /** |
||
29 | * @var ReflectionProperty[] |
||
30 | */ |
||
31 | private $properties = array(); |
||
32 | |||
33 | /** |
||
34 | * @var string[] |
||
35 | */ |
||
36 | private $lazyPropertyNameCache = array(); |
||
37 | |||
38 | /** |
||
39 | * @var string[] |
||
40 | */ |
||
41 | private $lazyValueCache = array(); |
||
42 | |||
43 | /** |
||
44 | * Constructor. |
||
45 | * |
||
46 | * @param ReflectionProperty|string[] $properties |
||
47 | * |
||
48 | * @throws \InvalidArgumentException If one necessary property is missing |
||
49 | */ |
||
50 | 22 | public function __construct(array $properties) |
|
63 | |||
64 | /** |
||
65 | * Gets the value of the given property. |
||
66 | * |
||
67 | * @param object $user |
||
68 | * @param string $property |
||
69 | * @param bool $strict |
||
70 | * |
||
71 | * @return mixed |
||
72 | */ |
||
73 | 11 | public function getPropertyValue($user, $property = self::LOGIN_PROPERTY, $strict = false) |
|
89 | |||
90 | /** |
||
91 | * Gets the name of a specific property by its metadata constant. |
||
92 | * |
||
93 | * @param string $property |
||
94 | * @param bool $strict |
||
95 | * |
||
96 | * @return null|string |
||
97 | */ |
||
98 | 18 | public function getPropertyName($property = self::LOGIN_PROPERTY, $strict = false) |
|
111 | |||
112 | /** |
||
113 | * Modifies a property and clears the cache. |
||
114 | * |
||
115 | * @param object $user |
||
116 | * @param mixed $newValue |
||
117 | * @param string $property |
||
118 | */ |
||
119 | 11 | public function modifyProperty($user, $newValue, $property = self::LOGIN_PROPERTY) |
|
138 | |||
139 | /** |
||
140 | * Validates a property. |
||
141 | * |
||
142 | * @param string $property |
||
143 | * @param bool $strict |
||
144 | * |
||
145 | * @return bool |
||
146 | */ |
||
147 | 19 | private function checkProperty($property = self::LOGIN_PROPERTY, $strict = false) |
|
162 | |||
163 | /** |
||
164 | * Resolves the lazy value cache. |
||
165 | * |
||
166 | * @param string $oid |
||
167 | * @param string $property |
||
168 | * |
||
169 | * @return mixed|null |
||
170 | */ |
||
171 | 11 | private function resolveCache($oid, $property) |
|
183 | } |
||
184 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..