1 | <?php |
||
44 | abstract class AbstractMiddleware implements MiddlewareInterface, DataPreProcessorInterface |
||
45 | { |
||
46 | /** |
||
47 | * @var MiddlewareProcessor |
||
48 | */ |
||
49 | private $processor; |
||
50 | |||
51 | /** |
||
52 | * This is the default option class, this property can be overridden in |
||
53 | * children classes to be mapped to another option definition. |
||
54 | * |
||
55 | * @var \Romm\Formz\Middleware\Option\DefaultOptionDefinition |
||
56 | */ |
||
57 | protected $options; |
||
58 | |||
59 | /** |
||
60 | * Can be overridden in child class with custom priority value. |
||
61 | * |
||
62 | * The higher the priority is, the earlier the middleware is called. |
||
63 | * |
||
64 | * Note that you can also override the method `getPriority()` for advanced |
||
65 | * priority calculation. |
||
66 | * |
||
67 | * @var int |
||
68 | */ |
||
69 | protected $priority = 0; |
||
70 | |||
71 | /** |
||
72 | * @var ReflectionService |
||
73 | */ |
||
74 | protected $reflectionService; |
||
75 | |||
76 | /** |
||
77 | * @param OptionDefinitionInterface $options |
||
78 | */ |
||
79 | final public function __construct(OptionDefinitionInterface $options) |
||
83 | |||
84 | /** |
||
85 | * Abstraction for processing the middleware initialization. |
||
86 | * |
||
87 | * For own initialization, @see initializeMiddleware() |
||
88 | */ |
||
89 | final public function initialize() |
||
93 | |||
94 | /** |
||
95 | * You can override this method in your child class to initialize your |
||
96 | * middleware correctly. |
||
97 | */ |
||
98 | protected function initializeMiddleware() |
||
101 | |||
102 | /** |
||
103 | * @see \Romm\Formz\Middleware\Signal\SendsMiddlewareSignal::beforeSignal() |
||
104 | * |
||
105 | * @param string $signal |
||
106 | * @return SignalObject |
||
107 | */ |
||
108 | final public function beforeSignal($signal = null) |
||
112 | |||
113 | /** |
||
114 | * @see \Romm\Formz\Middleware\Signal\SendsMiddlewareSignal::afterSignal() |
||
115 | * |
||
116 | * @param string $signal |
||
117 | * @return SignalObject |
||
118 | */ |
||
119 | final public function afterSignal($signal = null) |
||
123 | |||
124 | /** |
||
125 | * @return OptionDefinitionInterface |
||
126 | */ |
||
127 | public function getOptions() |
||
131 | |||
132 | /** |
||
133 | * @return string |
||
134 | */ |
||
135 | public static function getOptionsClassName() |
||
139 | |||
140 | /** |
||
141 | * Returns a new forward dispatcher, on which you can add options by calling |
||
142 | * its fluent methods. |
||
143 | * |
||
144 | * You must call the method `dispatch()` to actually dispatch the forward |
||
145 | * signal. |
||
146 | * |
||
147 | * @return Forward |
||
148 | */ |
||
149 | final protected function forward() |
||
153 | |||
154 | /** |
||
155 | * Returns a new redirect dispatcher, on which you can add options by |
||
156 | * calling its fluent methods. |
||
157 | * |
||
158 | * You must call the method `dispatch()` to actually dispatch the redirect |
||
159 | * signal. |
||
160 | * |
||
161 | * @return Redirect |
||
162 | */ |
||
163 | final protected function redirect() |
||
167 | |||
168 | /** |
||
169 | * @return FormObject |
||
170 | */ |
||
171 | final protected function getFormObject() |
||
175 | |||
176 | /** |
||
177 | * @return Request |
||
178 | */ |
||
179 | final protected function getRequest() |
||
183 | |||
184 | /** |
||
185 | * @return Arguments |
||
186 | */ |
||
187 | final protected function getRequestArguments() |
||
191 | |||
192 | /** |
||
193 | * @return int |
||
194 | */ |
||
195 | public function getPriority() |
||
199 | |||
200 | /** |
||
201 | * @param MiddlewareProcessor $middlewareProcessor |
||
202 | */ |
||
203 | final public function bindMiddlewareProcessor(MiddlewareProcessor $middlewareProcessor) |
||
207 | |||
208 | /** |
||
209 | * Returns the name of the signal on which this middleware is bound. |
||
210 | * |
||
211 | * @return string |
||
212 | * @throws SignalNotFoundException |
||
213 | */ |
||
214 | final public function getBoundSignalName() |
||
226 | |||
227 | /** |
||
228 | * Will inject empty options if no option has been defined at all. |
||
229 | * |
||
230 | * @param DataPreProcessor $processor |
||
231 | */ |
||
232 | public static function dataPreProcessor(DataPreProcessor $processor) |
||
242 | |||
243 | /** |
||
244 | * Returns a signal object, that will be used to dispatch a signal coming |
||
245 | * from this middleware. |
||
246 | * |
||
247 | * @param string $signal |
||
248 | * @param string $type |
||
249 | * @return SignalObject |
||
250 | * @throws InvalidArgumentValueException |
||
251 | * @throws InvalidEntryException |
||
252 | * @throws MissingArgumentException |
||
253 | */ |
||
254 | private function getSignalObject($signal, $type) |
||
278 | |||
279 | /** |
||
280 | * @return array |
||
281 | */ |
||
282 | public function __sleep() |
||
286 | |||
287 | /** |
||
288 | * @param ReflectionService $reflectionService |
||
289 | */ |
||
290 | public function injectReflectionService(ReflectionService $reflectionService) |
||
294 | } |
||
295 |
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.