1 | <?php |
||
46 | abstract class AbstractMiddleware implements MiddlewareInterface, DataPreProcessorInterface |
||
47 | { |
||
48 | /** |
||
49 | * @var MiddlewareProcessor |
||
50 | */ |
||
51 | private $processor; |
||
52 | |||
53 | /** |
||
54 | * This is the default option class, this property can be overridden in |
||
55 | * children classes to be mapped to another option definition. |
||
56 | * |
||
57 | * Please note that the full class name of the option must be written. |
||
58 | * |
||
59 | * @var \Romm\Formz\Middleware\Option\DefaultOption |
||
60 | */ |
||
61 | protected $options; |
||
62 | |||
63 | /** |
||
64 | * @var \Romm\Formz\Form\Definition\Middleware\MiddlewareScopes |
||
65 | */ |
||
66 | protected $scopes = []; |
||
67 | |||
68 | /** |
||
69 | * Can be overridden in child class with custom priority value. |
||
70 | * |
||
71 | * The higher the priority is, the earlier the middleware is called. |
||
72 | * |
||
73 | * Note that you can also override the method `getPriority()` for advanced |
||
74 | * priority calculation. |
||
75 | * |
||
76 | * @var int |
||
77 | */ |
||
78 | protected $priority = 0; |
||
79 | |||
80 | /** |
||
81 | * @var ReflectionService |
||
82 | */ |
||
83 | protected $reflectionService; |
||
84 | |||
85 | /** |
||
86 | * @param OptionInterface $options |
||
87 | * @param MiddlewareScopes $scopes |
||
88 | */ |
||
89 | final public function __construct(OptionInterface $options, MiddlewareScopes $scopes) |
||
94 | |||
95 | /** |
||
96 | * Abstraction for processing the middleware initialization. |
||
97 | * |
||
98 | * For own initialization, @see initializeMiddleware() |
||
99 | */ |
||
100 | final public function initialize() |
||
104 | |||
105 | /** |
||
106 | * You can override this method in your child class to initialize your |
||
107 | * middleware correctly. |
||
108 | */ |
||
109 | protected function initializeMiddleware() |
||
112 | |||
113 | /** |
||
114 | * @see \Romm\Formz\Middleware\Signal\SendsSignal::beforeSignal() |
||
115 | * |
||
116 | * @param string $signal |
||
117 | * @return SignalObject |
||
118 | */ |
||
119 | final public function beforeSignal($signal = null) |
||
123 | |||
124 | /** |
||
125 | * @see \Romm\Formz\Middleware\Signal\SendsSignal::afterSignal() |
||
126 | * |
||
127 | * @param string $signal |
||
128 | * @return SignalObject |
||
129 | */ |
||
130 | final public function afterSignal($signal = null) |
||
134 | |||
135 | /** |
||
136 | * @return OptionInterface |
||
137 | */ |
||
138 | public function getOptions() |
||
142 | |||
143 | /** |
||
144 | * @return string |
||
145 | */ |
||
146 | public static function getOptionsClassName() |
||
150 | |||
151 | /** |
||
152 | * @return MiddlewareScopes |
||
153 | */ |
||
154 | public function getScopes() |
||
158 | |||
159 | /** |
||
160 | * Returns a new forward dispatcher, on which you can add options by calling |
||
161 | * its fluent methods. |
||
162 | * |
||
163 | * You must call the method `dispatch()` to actually dispatch the forward |
||
164 | * signal. |
||
165 | * |
||
166 | * @return Forward |
||
167 | */ |
||
168 | final protected function forward() |
||
172 | |||
173 | /** |
||
174 | * Returns a new redirect dispatcher, on which you can add options by |
||
175 | * calling its fluent methods. |
||
176 | * |
||
177 | * You must call the method `dispatch()` to actually dispatch the redirect |
||
178 | * signal. |
||
179 | * |
||
180 | * @return Redirect |
||
181 | */ |
||
182 | final protected function redirect() |
||
186 | |||
187 | /** |
||
188 | * @return FormObject |
||
189 | */ |
||
190 | final protected function getFormObject() |
||
194 | |||
195 | /** |
||
196 | * @return Request |
||
197 | */ |
||
198 | final protected function getRequest() |
||
202 | |||
203 | /** |
||
204 | * @return Arguments |
||
205 | */ |
||
206 | final protected function getRequestArguments() |
||
210 | |||
211 | /** |
||
212 | * @return int |
||
213 | */ |
||
214 | public function getPriority() |
||
218 | |||
219 | /** |
||
220 | * @param MiddlewareProcessor $middlewareProcessor |
||
221 | */ |
||
222 | final public function bindMiddlewareProcessor(MiddlewareProcessor $middlewareProcessor) |
||
226 | |||
227 | /** |
||
228 | * Returns the name of the signal on which this middleware is bound. |
||
229 | * |
||
230 | * @return string |
||
231 | * @throws SignalNotFoundException |
||
232 | */ |
||
233 | final public function getBoundSignalName() |
||
245 | |||
246 | /** |
||
247 | * Will inject empty options if no option has been defined at all. |
||
248 | * |
||
249 | * @param DataPreProcessor $processor |
||
250 | */ |
||
251 | public static function dataPreProcessor(DataPreProcessor $processor) |
||
265 | |||
266 | /** |
||
267 | * Returns a signal object, that will be used to dispatch a signal coming |
||
268 | * from this middleware. |
||
269 | * |
||
270 | * @param string $signal |
||
271 | * @param string $type |
||
272 | * @return SignalObject |
||
273 | * @throws InvalidArgumentValueException |
||
274 | * @throws InvalidEntryException |
||
275 | * @throws MissingArgumentException |
||
276 | */ |
||
277 | private function getSignalObject($signal, $type) |
||
301 | |||
302 | /** |
||
303 | * @return array |
||
304 | */ |
||
305 | public function __sleep() |
||
309 | |||
310 | /** |
||
311 | * @param ReflectionService $reflectionService |
||
312 | */ |
||
313 | public function injectReflectionService(ReflectionService $reflectionService) |
||
317 | } |
||
318 |
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.