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 | * children classes to be mapped to another option definition. |
||
55 | * |
||
56 | * Please note that the full class name of the option must be written. |
||
57 | * |
||
58 | * @var \Romm\Formz\Middleware\Option\DefaultOptionDefinition |
||
59 | */ |
||
60 | protected $options; |
||
61 | |||
62 | /** |
||
63 | * Can be overridden in child class with custom priority value. |
||
64 | * |
||
65 | * The higher the priority is, the earlier the middleware is called. |
||
66 | * |
||
67 | * Note that you can also override the method `getPriority()` for advanced |
||
68 | * priority calculation. |
||
69 | * |
||
70 | * @var int |
||
71 | */ |
||
72 | protected $priority = 0; |
||
73 | |||
74 | /** |
||
75 | * @var ReflectionService |
||
76 | */ |
||
77 | protected $reflectionService; |
||
78 | |||
79 | /** |
||
80 | * @param OptionDefinitionInterface $options |
||
81 | */ |
||
82 | final public function __construct(OptionDefinitionInterface $options) |
||
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\SendsSignal::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\SendsSignal::afterSignal() |
||
118 | * |
||
119 | * @param string $signal |
||
120 | * @return SignalObject |
||
121 | */ |
||
122 | final public function afterSignal($signal = null) |
||
126 | |||
127 | /** |
||
128 | * @return OptionDefinitionInterface |
||
129 | */ |
||
130 | public function getOptions() |
||
134 | |||
135 | /** |
||
136 | * @return string |
||
137 | */ |
||
138 | public static function getOptionsClassName() |
||
142 | |||
143 | /** |
||
144 | * Returns a new forward dispatcher, on which you can add options by calling |
||
145 | * its fluent methods. |
||
146 | * |
||
147 | * You must call the method `dispatch()` to actually dispatch the forward |
||
148 | * signal. |
||
149 | * |
||
150 | * @return Forward |
||
151 | */ |
||
152 | final protected function forward() |
||
156 | |||
157 | /** |
||
158 | * Returns a new redirect dispatcher, on which you can add options by |
||
159 | * calling its fluent methods. |
||
160 | * |
||
161 | * You must call the method `dispatch()` to actually dispatch the redirect |
||
162 | * signal. |
||
163 | * |
||
164 | * @return Redirect |
||
165 | */ |
||
166 | final protected function redirect() |
||
170 | |||
171 | /** |
||
172 | * @return FormObject |
||
173 | */ |
||
174 | final protected function getFormObject() |
||
178 | |||
179 | /** |
||
180 | * @return Request |
||
181 | */ |
||
182 | final protected function getRequest() |
||
186 | |||
187 | /** |
||
188 | * @return Arguments |
||
189 | */ |
||
190 | final protected function getRequestArguments() |
||
194 | |||
195 | /** |
||
196 | * @return int |
||
197 | */ |
||
198 | public function getPriority() |
||
202 | |||
203 | /** |
||
204 | * @param MiddlewareProcessor $middlewareProcessor |
||
205 | */ |
||
206 | final public function bindMiddlewareProcessor(MiddlewareProcessor $middlewareProcessor) |
||
210 | |||
211 | /** |
||
212 | * Returns the name of the signal on which this middleware is bound. |
||
213 | * |
||
214 | * @return string |
||
215 | * @throws SignalNotFoundException |
||
216 | */ |
||
217 | final public function getBoundSignalName() |
||
229 | |||
230 | /** |
||
231 | * Will inject empty options if no option has been defined at all. |
||
232 | * |
||
233 | * @param DataPreProcessor $processor |
||
234 | */ |
||
235 | public static function dataPreProcessor(DataPreProcessor $processor) |
||
245 | |||
246 | /** |
||
247 | * Returns a signal object, that will be used to dispatch a signal coming |
||
248 | * from this middleware. |
||
249 | * |
||
250 | * @param string $signal |
||
251 | * @param string $type |
||
252 | * @return SignalObject |
||
253 | * @throws InvalidArgumentValueException |
||
254 | * @throws InvalidEntryException |
||
255 | * @throws MissingArgumentException |
||
256 | */ |
||
257 | private function getSignalObject($signal, $type) |
||
281 | |||
282 | /** |
||
283 | * @return array |
||
284 | */ |
||
285 | public function __sleep() |
||
289 | |||
290 | /** |
||
291 | * @param ReflectionService $reflectionService |
||
292 | */ |
||
293 | public function injectReflectionService(ReflectionService $reflectionService) |
||
297 | } |
||
298 |
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.