1 | <?php |
||
45 | abstract class AbstractMiddleware implements MiddlewareInterface, DataPreProcessorInterface |
||
46 | { |
||
47 | /** |
||
48 | * @var MiddlewareProcessor |
||
49 | */ |
||
50 | private $processor; |
||
51 | |||
52 | /** |
||
53 | * This is the default option class, this property can be overridden in |
||
54 | * child classes to be mapped to another option definition. |
||
55 | * |
||
56 | * @var \Romm\Formz\Middleware\Option\DefaultOptionDefinition |
||
57 | */ |
||
58 | protected $options; |
||
59 | |||
60 | /** |
||
61 | * @var \Romm\Formz\Form\Definition\Middleware\MiddlewareScopes |
||
62 | */ |
||
63 | protected $scopes = []; |
||
64 | |||
65 | /** |
||
66 | * Can be overridden in child class with custom priority value. |
||
67 | * |
||
68 | * The higher the priority is, the earlier the middleware is called. |
||
69 | * |
||
70 | * Note that you can also override the method `getPriority()` for advanced |
||
71 | * priority calculation. |
||
72 | * |
||
73 | * @var int |
||
74 | */ |
||
75 | protected $priority = 0; |
||
76 | |||
77 | /** |
||
78 | * @param OptionInterface $options |
||
79 | * @param MiddlewareScopes $scopes |
||
80 | */ |
||
81 | final public function __construct(OptionInterface $options, MiddlewareScopes $scopes) |
||
86 | |||
87 | /** |
||
88 | * Abstraction for processing the middleware initialization. |
||
89 | * |
||
90 | * For own initialization, @see initializeMiddleware() |
||
91 | */ |
||
92 | final public function initialize() |
||
96 | |||
97 | /** |
||
98 | * You can override this method in your child class to initialize your |
||
99 | * middleware correctly. |
||
100 | */ |
||
101 | protected function initializeMiddleware() |
||
104 | |||
105 | /** |
||
106 | * @see \Romm\Formz\Middleware\Signal\SendsMiddlewareSignal::beforeSignal() |
||
107 | * |
||
108 | * @param string $signal |
||
109 | * @return SignalObject |
||
110 | */ |
||
111 | final public function beforeSignal($signal = null) |
||
115 | |||
116 | /** |
||
117 | * @see \Romm\Formz\Middleware\Signal\SendsMiddlewareSignal::afterSignal() |
||
118 | * |
||
119 | * @param string $signal |
||
120 | * @return SignalObject |
||
121 | */ |
||
122 | final public function afterSignal($signal = null) |
||
126 | |||
127 | /** |
||
128 | * @return AbstractOptionDefinition |
||
129 | */ |
||
130 | public function getOptions() |
||
134 | |||
135 | /** |
||
136 | * @todo |
||
137 | */ |
||
138 | protected function redirectToNextStep() |
||
157 | |||
158 | /** |
||
159 | * @return MiddlewareScopes |
||
160 | */ |
||
161 | public function getScopes() |
||
165 | |||
166 | /** |
||
167 | * Returns a new forward dispatcher, on which you can add options by calling |
||
168 | * its fluent methods. |
||
169 | * |
||
170 | * You must call the method `dispatch()` to actually dispatch the forward |
||
171 | * signal. |
||
172 | * |
||
173 | * @return Forward |
||
174 | */ |
||
175 | final protected function forward() |
||
179 | |||
180 | /** |
||
181 | * Returns a new redirect dispatcher, on which you can add options by |
||
182 | * calling its fluent methods. |
||
183 | * |
||
184 | * You must call the method `dispatch()` to actually dispatch the redirect |
||
185 | * signal. |
||
186 | * |
||
187 | * @return Redirect |
||
188 | */ |
||
189 | final protected function redirect() |
||
193 | |||
194 | /** |
||
195 | * @return FormObject |
||
196 | */ |
||
197 | final protected function getFormObject() |
||
201 | |||
202 | /** |
||
203 | * @return Request |
||
204 | */ |
||
205 | final protected function getRequest() |
||
209 | |||
210 | /** |
||
211 | * @return Arguments |
||
212 | */ |
||
213 | final protected function getRequestArguments() |
||
217 | |||
218 | /** |
||
219 | * @return array |
||
220 | */ |
||
221 | final protected function getSettings() |
||
225 | |||
226 | /** |
||
227 | * @return Step|null |
||
228 | */ |
||
229 | final protected function getCurrentStep() |
||
233 | |||
234 | /** |
||
235 | * @return int |
||
236 | */ |
||
237 | public function getPriority() |
||
241 | |||
242 | /** |
||
243 | * @param MiddlewareProcessor $middlewareProcessor |
||
244 | */ |
||
245 | final public function bindMiddlewareProcessor(MiddlewareProcessor $middlewareProcessor) |
||
249 | |||
250 | /** |
||
251 | * Returns the name of the signal on which this middleware is bound. |
||
252 | * |
||
253 | * @return string |
||
254 | * @throws SignalNotFoundException |
||
255 | */ |
||
256 | final public function getBoundSignalName() |
||
268 | |||
269 | /** |
||
270 | * Will inject empty options if no option has been defined at all. |
||
271 | * |
||
272 | * @param DataPreProcessor $processor |
||
273 | */ |
||
274 | public static function dataPreProcessor(DataPreProcessor $processor) |
||
288 | |||
289 | /** |
||
290 | * @param string $signal |
||
291 | * @param string $type |
||
292 | * @return SignalObject |
||
293 | * @throws InvalidArgumentValueException |
||
294 | * @throws InvalidEntryException |
||
295 | * @throws MissingArgumentException |
||
296 | */ |
||
297 | private function getSignalObject($signal, $type) |
||
318 | |||
319 | /** |
||
320 | * @return array |
||
321 | */ |
||
322 | public function __sleep() |
||
326 | } |
||
327 |
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.