1 | <?php |
||
47 | abstract class AbstractMiddleware implements MiddlewareInterface, DataPreProcessorInterface |
||
48 | { |
||
49 | /** |
||
50 | * @var MiddlewareProcessor |
||
51 | */ |
||
52 | private $processor; |
||
53 | |||
54 | /** |
||
55 | * This is the default option class, this property can be overridden in |
||
56 | * children classes to be mapped to another option definition. |
||
57 | * |
||
58 | * Please note that the full class name of the option must be written. |
||
59 | * |
||
60 | * @var \Romm\Formz\Middleware\Option\DefaultOption |
||
61 | */ |
||
62 | protected $options; |
||
63 | |||
64 | /** |
||
65 | * @var \Romm\Formz\Form\Definition\Middleware\MiddlewareScopes |
||
66 | */ |
||
67 | protected $scopes = []; |
||
68 | |||
69 | /** |
||
70 | * @var array |
||
71 | */ |
||
72 | protected static $defaultScopesWhiteList = []; |
||
73 | |||
74 | /** |
||
75 | * @var array |
||
76 | */ |
||
77 | protected static $defaultScopesBlackList = []; |
||
78 | |||
79 | |||
80 | /** |
||
81 | * Can be overridden in child class with custom priority value. |
||
82 | * |
||
83 | * The higher the priority is, the earlier the middleware is called. |
||
84 | * |
||
85 | * Note that you can also override the method `getPriority()` for advanced |
||
86 | * priority calculation. |
||
87 | * |
||
88 | * @var int |
||
89 | */ |
||
90 | protected $priority = 0; |
||
91 | |||
92 | /** |
||
93 | * @var ReflectionService |
||
94 | */ |
||
95 | protected $reflectionService; |
||
96 | |||
97 | /** |
||
98 | * @param OptionInterface $options |
||
99 | * @param MiddlewareScopes $scopes |
||
100 | */ |
||
101 | final public function __construct(OptionInterface $options, MiddlewareScopes $scopes) |
||
106 | |||
107 | /** |
||
108 | * Abstraction for processing the middleware initialization. |
||
109 | * |
||
110 | * For own initialization, @see initializeMiddleware() |
||
111 | */ |
||
112 | final public function initialize() |
||
116 | |||
117 | /** |
||
118 | * You can override this method in your child class to initialize your |
||
119 | * middleware correctly. |
||
120 | */ |
||
121 | protected function initializeMiddleware() |
||
124 | |||
125 | /** |
||
126 | * @see \Romm\Formz\Middleware\Signal\SendsSignal::beforeSignal() |
||
127 | * |
||
128 | * @param string $signal |
||
129 | * @return SignalObject |
||
130 | */ |
||
131 | final public function beforeSignal($signal = null) |
||
135 | |||
136 | /** |
||
137 | * @see \Romm\Formz\Middleware\Signal\SendsSignal::afterSignal() |
||
138 | * |
||
139 | * @param string $signal |
||
140 | * @return SignalObject |
||
141 | */ |
||
142 | final public function afterSignal($signal = null) |
||
146 | |||
147 | /** |
||
148 | * @return OptionInterface |
||
149 | */ |
||
150 | public function getOptions() |
||
154 | |||
155 | /** |
||
156 | * @return string |
||
157 | */ |
||
158 | public static function getOptionsClassName() |
||
162 | |||
163 | /** |
||
164 | * @return MiddlewareScopes |
||
165 | */ |
||
166 | public function getScopes() |
||
170 | |||
171 | /** |
||
172 | * Returns a new forward dispatcher, on which you can add options by calling |
||
173 | * its fluent methods. |
||
174 | * |
||
175 | * You must call the method `dispatch()` to actually dispatch the forward |
||
176 | * signal. |
||
177 | * |
||
178 | * @return Forward |
||
179 | */ |
||
180 | final protected function forward() |
||
184 | |||
185 | /** |
||
186 | * Returns a new redirect dispatcher, on which you can add options by |
||
187 | * calling its fluent methods. |
||
188 | * |
||
189 | * You must call the method `dispatch()` to actually dispatch the redirect |
||
190 | * signal. |
||
191 | * |
||
192 | * @return Redirect |
||
193 | */ |
||
194 | final protected function redirect() |
||
198 | |||
199 | /** |
||
200 | * @return FormObject |
||
201 | */ |
||
202 | final protected function getFormObject() |
||
206 | |||
207 | /** |
||
208 | * @return Request |
||
209 | */ |
||
210 | final protected function getRequest() |
||
214 | |||
215 | /** |
||
216 | * @return Arguments |
||
217 | */ |
||
218 | final protected function getRequestArguments() |
||
222 | |||
223 | /** |
||
224 | * @return int |
||
225 | */ |
||
226 | public function getPriority() |
||
230 | |||
231 | /** |
||
232 | * @param MiddlewareProcessor $middlewareProcessor |
||
233 | */ |
||
234 | final public function bindMiddlewareProcessor(MiddlewareProcessor $middlewareProcessor) |
||
238 | |||
239 | /** |
||
240 | * Returns the name of the signal on which this middleware is bound. |
||
241 | * |
||
242 | * @return string |
||
243 | * @throws SignalNotFoundException |
||
244 | */ |
||
245 | final public function getBoundSignalName() |
||
257 | |||
258 | /** |
||
259 | * Will inject empty options if no option has been defined at all. |
||
260 | * |
||
261 | * @param DataPreProcessor $processor |
||
262 | */ |
||
263 | public static function dataPreProcessor(DataPreProcessor $processor) |
||
288 | |||
289 | /** |
||
290 | * Returns a signal object, that will be used to dispatch a signal coming |
||
291 | * from this middleware. |
||
292 | * |
||
293 | * @param string $signal |
||
294 | * @param string $type |
||
295 | * @return SignalObject |
||
296 | * @throws InvalidArgumentValueException |
||
297 | * @throws InvalidEntryException |
||
298 | * @throws MissingArgumentException |
||
299 | */ |
||
300 | private function getSignalObject($signal, $type) |
||
324 | |||
325 | /** |
||
326 | * @return array |
||
327 | */ |
||
328 | public function __sleep() |
||
332 | |||
333 | /** |
||
334 | * @param ReflectionService $reflectionService |
||
335 | */ |
||
336 | public function injectReflectionService(ReflectionService $reflectionService) |
||
340 | } |
||
341 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.