1 | <?php |
||
22 | class ClassFieldAccess extends AbstractJoinpoint implements FieldAccess |
||
23 | { |
||
24 | |||
25 | /** |
||
26 | * Instance of object for accessing |
||
27 | * |
||
28 | * @var object |
||
29 | */ |
||
30 | protected $instance; |
||
31 | |||
32 | /** |
||
33 | * Instance of reflection property |
||
34 | * |
||
35 | * @var ReflectionProperty |
||
36 | */ |
||
37 | protected $reflectionProperty; |
||
38 | |||
39 | /** |
||
40 | * New value to set |
||
41 | * |
||
42 | * @var mixed |
||
43 | */ |
||
44 | protected $newValue; |
||
45 | |||
46 | /** |
||
47 | * Access type for field access |
||
48 | * |
||
49 | * @var integer |
||
50 | */ |
||
51 | private $accessType; |
||
52 | |||
53 | /** |
||
54 | * Copy of the original value of property |
||
55 | * |
||
56 | * @var mixed |
||
57 | */ |
||
58 | private $value; |
||
59 | |||
60 | /** |
||
61 | * Constructor for field access |
||
62 | * |
||
63 | * @param string $className Class name |
||
64 | * @param string $fieldName Field name |
||
65 | * @param $advices array List of advices for this invocation |
||
66 | */ |
||
67 | 3 | public function __construct(string $className, string $fieldName, array $advices) |
|
77 | |||
78 | /** |
||
79 | * Returns the access type. |
||
80 | */ |
||
81 | public function getAccessType(): int |
||
85 | |||
86 | /** |
||
87 | * Gets the field being accessed. |
||
88 | * |
||
89 | * @return ReflectionProperty|AnnotatedReflectionProperty the property which is being accessed. |
||
90 | */ |
||
91 | 3 | public function getField(): ReflectionProperty |
|
95 | |||
96 | /** |
||
97 | * Gets the current value of property |
||
98 | * |
||
99 | * @return mixed |
||
100 | */ |
||
101 | public function &getValue() |
||
107 | |||
108 | /** |
||
109 | * Gets the value that must be set to the field. |
||
110 | * |
||
111 | * @return mixed |
||
112 | */ |
||
113 | public function &getValueToSet() |
||
119 | |||
120 | /** |
||
121 | * Checks scope rules for accessing property |
||
122 | * |
||
123 | * @param int $stackLevel Stack level for check |
||
124 | */ |
||
125 | public function ensureScopeRule($stackLevel = 2) |
||
141 | |||
142 | /** |
||
143 | * Proceed to the next interceptor in the Chain |
||
144 | * |
||
145 | * Typically this method is called inside previous closure, as instance of Joinpoint is passed to callback |
||
146 | * Do not call this method directly, only inside callback closures. |
||
147 | * |
||
148 | * @return void For field interceptor there is no return values |
||
149 | */ |
||
150 | final public function proceed() |
||
158 | |||
159 | /** |
||
160 | * Invokes current field access with all interceptors |
||
161 | * |
||
162 | * @param object $instance Instance of object |
||
163 | * @param integer $accessType Type of access: READ or WRITE |
||
164 | * @param mixed $originalValue Original value of property |
||
165 | * @param mixed $newValue New value to set |
||
166 | * |
||
167 | * @return mixed |
||
168 | */ |
||
169 | final public function &__invoke($instance, $accessType, &$originalValue, $newValue = NAN) |
||
200 | |||
201 | /** |
||
202 | * Returns the object that holds the current joinpoint's static |
||
203 | * part. |
||
204 | * |
||
205 | * @return object|null the object (can be null if the accessible object is |
||
206 | * static). |
||
207 | */ |
||
208 | final public function getThis() |
||
212 | |||
213 | /** |
||
214 | * Returns the static part of this joinpoint. |
||
215 | * |
||
216 | * @return object |
||
217 | */ |
||
218 | 1 | final public function getStaticPart() |
|
222 | |||
223 | /** |
||
224 | * Returns a friendly description of current joinpoint |
||
225 | * |
||
226 | * @return string |
||
227 | */ |
||
228 | final public function __toString() |
||
238 | } |
||
239 |