1 | <?php |
||
21 | class ClassFieldAccess extends AbstractJoinpoint implements FieldAccess |
||
22 | { |
||
23 | |||
24 | /** |
||
25 | * Instance of object for accessing |
||
26 | * |
||
27 | * @var object |
||
28 | */ |
||
29 | protected $instance = null; |
||
30 | |||
31 | /** |
||
32 | * Instance of reflection property |
||
33 | * |
||
34 | * @var ReflectionProperty |
||
35 | */ |
||
36 | protected $reflectionProperty; |
||
37 | |||
38 | /** |
||
39 | * New value to set |
||
40 | * |
||
41 | * @var mixed |
||
42 | */ |
||
43 | protected $newValue = null; |
||
44 | |||
45 | /** |
||
46 | * Access type for field access |
||
47 | * |
||
48 | * @var integer |
||
49 | */ |
||
50 | private $accessType; |
||
51 | |||
52 | /** |
||
53 | * Copy of the original value of property |
||
54 | * |
||
55 | * @var mixed |
||
56 | */ |
||
57 | private $value = null; |
||
58 | |||
59 | /** |
||
60 | * Constructor for field access |
||
61 | * |
||
62 | * @param string $className Class name |
||
63 | * @param string $fieldName Field name |
||
64 | * @param $advices array List of advices for this invocation |
||
65 | */ |
||
66 | public function __construct($className, $fieldName, array $advices) |
||
76 | |||
77 | /** |
||
78 | * Returns the access type. |
||
79 | * |
||
80 | * @return integer |
||
81 | */ |
||
82 | public function getAccessType() |
||
86 | |||
87 | /** |
||
88 | * Gets the field being accessed. |
||
89 | * |
||
90 | * @return ReflectionProperty the field being accessed. |
||
91 | */ |
||
92 | public function getField() |
||
96 | |||
97 | /** |
||
98 | * Gets the current value of property |
||
99 | * |
||
100 | * @return mixed |
||
101 | */ |
||
102 | public function &getValue() |
||
108 | |||
109 | /** |
||
110 | * Gets the value that must be set to the field. |
||
111 | * |
||
112 | * @return mixed |
||
113 | */ |
||
114 | public function &getValueToSet() |
||
120 | |||
121 | /** |
||
122 | * Checks scope rules for accessing property |
||
123 | * |
||
124 | * @param int $stackLevel Stack level for check |
||
125 | * |
||
126 | * @return true if access is OK |
||
127 | */ |
||
128 | public function ensureScopeRule($stackLevel = 2) |
||
146 | |||
147 | /** |
||
148 | * Proceed to the next interceptor in the Chain |
||
149 | * |
||
150 | * Typically this method is called inside previous closure, as instance of Joinpoint is passed to callback |
||
151 | * Do not call this method directly, only inside callback closures. |
||
152 | * |
||
153 | * @return void For field interceptor there is no return values |
||
154 | */ |
||
155 | final public function proceed() |
||
164 | |||
165 | /** |
||
166 | * Invokes current field access with all interceptors |
||
167 | * |
||
168 | * @param object $instance Instance of object |
||
169 | * @param integer $accessType Type of access: READ or WRITE |
||
170 | * @param mixed $originalValue Original value of property |
||
171 | * @param mixed $newValue New value to set |
||
172 | * |
||
173 | * @return mixed |
||
174 | */ |
||
175 | final public function &__invoke($instance, $accessType, &$originalValue, $newValue = NAN) |
||
206 | |||
207 | /** |
||
208 | * Returns the object that holds the current joinpoint's static |
||
209 | * part. |
||
210 | * |
||
211 | * @return object|null the object (can be null if the accessible object is |
||
212 | * static). |
||
213 | */ |
||
214 | final public function getThis() |
||
218 | |||
219 | /** |
||
220 | * Returns the static part of this joinpoint. |
||
221 | * |
||
222 | * @return object |
||
223 | */ |
||
224 | final public function getStaticPart() |
||
228 | |||
229 | /** |
||
230 | * Returns a friendly description of current joinpoint |
||
231 | * |
||
232 | * @return string |
||
233 | */ |
||
234 | final public function __toString() |
||
244 | } |
||
245 |