1 | <?php |
||
42 | abstract class AbstractMiddleware implements MiddlewareInterface, DataPreProcessorInterface |
||
43 | { |
||
44 | /** |
||
45 | * @var MiddlewareProcessor |
||
46 | */ |
||
47 | private $processor; |
||
48 | |||
49 | /** |
||
50 | * This is the default option class, this property can be overridden in |
||
51 | * children classes to be mapped to another option definition. |
||
52 | * |
||
53 | * @var \Romm\Formz\Middleware\Option\DefaultOptionDefinition |
||
54 | */ |
||
55 | protected $options; |
||
56 | |||
57 | /** |
||
58 | * Can be overridden in child class with custom priority value. |
||
59 | * |
||
60 | * The higher the priority is, the earlier the middleware is called. |
||
61 | * |
||
62 | * Note that you can also override the method `getPriority()` for advanced |
||
63 | * priority calculation. |
||
64 | * |
||
65 | * @var int |
||
66 | */ |
||
67 | protected $priority = 0; |
||
68 | |||
69 | /** |
||
70 | * @param AbstractOptionDefinition $options |
||
71 | */ |
||
72 | final public function __construct(AbstractOptionDefinition $options) |
||
76 | |||
77 | /** |
||
78 | * Abstraction for processing the middleware initialization. |
||
79 | * |
||
80 | * For own initialization, @see initializeMiddleware() |
||
81 | */ |
||
82 | final public function initialize() |
||
86 | |||
87 | /** |
||
88 | * You can override this method in your child class to initialize your |
||
89 | * middleware correctly. |
||
90 | */ |
||
91 | protected function initializeMiddleware() |
||
94 | |||
95 | /** |
||
96 | * @see \Romm\Formz\Middleware\Signal\SendsMiddlewareSignal::beforeSignal() |
||
97 | * |
||
98 | * @param string $signal |
||
99 | * @return SignalObject |
||
100 | */ |
||
101 | final protected function beforeSignal($signal = null) |
||
105 | |||
106 | /** |
||
107 | * @see \Romm\Formz\Middleware\Signal\SendsMiddlewareSignal::afterSignal() |
||
108 | * |
||
109 | * @param string $signal |
||
110 | * @return SignalObject |
||
111 | */ |
||
112 | final protected function afterSignal($signal = null) |
||
116 | |||
117 | /** |
||
118 | * @return AbstractOptionDefinition |
||
119 | */ |
||
120 | public function getOptions() |
||
124 | |||
125 | /** |
||
126 | * Returns a new forward dispatcher, on which you can add options by calling |
||
127 | * its fluent methods. |
||
128 | * |
||
129 | * You must call the method `dispatch()` to actually dispatch the forward |
||
130 | * signal. |
||
131 | * |
||
132 | * @return Forward |
||
133 | */ |
||
134 | final protected function forward() |
||
138 | |||
139 | /** |
||
140 | * Returns a new redirect dispatcher, on which you can add options by |
||
141 | * calling its fluent methods. |
||
142 | * |
||
143 | * You must call the method `dispatch()` to actually dispatch the redirect |
||
144 | * signal. |
||
145 | * |
||
146 | * @return Redirect |
||
147 | */ |
||
148 | final protected function redirect() |
||
152 | |||
153 | /** |
||
154 | * @return FormObject |
||
155 | */ |
||
156 | final protected function getFormObject() |
||
160 | |||
161 | /** |
||
162 | * @return Request |
||
163 | */ |
||
164 | final protected function getRequest() |
||
168 | |||
169 | /** |
||
170 | * @return Arguments |
||
171 | */ |
||
172 | final protected function getRequestArguments() |
||
176 | |||
177 | /** |
||
178 | * @return int |
||
179 | */ |
||
180 | public function getPriority() |
||
184 | |||
185 | /** |
||
186 | * @param MiddlewareProcessor $middlewareProcessor |
||
187 | */ |
||
188 | final public function bindMiddlewareProcessor(MiddlewareProcessor $middlewareProcessor) |
||
192 | |||
193 | /** |
||
194 | * Returns the name of the signal on which this middleware is bound. |
||
195 | * |
||
196 | * @return string |
||
197 | * @throws SignalNotFoundException |
||
198 | */ |
||
199 | final public function getBoundSignalName() |
||
211 | |||
212 | /** |
||
213 | * Will inject empty options if no option has been defined at all. |
||
214 | * |
||
215 | * @param DataPreProcessor $processor |
||
216 | */ |
||
217 | public static function dataPreProcessor(DataPreProcessor $processor) |
||
227 | |||
228 | /** |
||
229 | * @param string $signal |
||
230 | * @param string $type |
||
231 | * @return SignalObject |
||
232 | * @throws InvalidArgumentValueException |
||
233 | * @throws InvalidEntryException |
||
234 | * @throws MissingArgumentException |
||
235 | */ |
||
236 | private function getSignalObject($signal, $type) |
||
260 | |||
261 | /** |
||
262 | * @return array |
||
263 | */ |
||
264 | public function __sleep() |
||
268 | } |
||
269 |
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.