1 | <?php |
||
43 | abstract class AbstractMiddleware implements MiddlewareInterface, DataPreProcessorInterface |
||
44 | { |
||
45 | /** |
||
46 | * @var MiddlewareState |
||
47 | */ |
||
48 | private $state; |
||
49 | |||
50 | /** |
||
51 | * This is the default option class, this property can be overridden in |
||
52 | * child classes to be mapped to another option definition. |
||
53 | * |
||
54 | * @var \Romm\Formz\Middleware\Option\DefaultOptionDefinition |
||
55 | */ |
||
56 | protected $options; |
||
57 | |||
58 | /** |
||
59 | * Can be overridden in child class with custom priority value. |
||
60 | * |
||
61 | * The higher the priority is, the earlier the middleware is called. |
||
62 | * |
||
63 | * Note that you can also override the method `getPriority()` for advanced |
||
64 | * priority calculation. |
||
65 | * |
||
66 | * @var int |
||
67 | */ |
||
68 | protected $priority = 0; |
||
69 | |||
70 | /** |
||
71 | * @param AbstractOptionDefinition $options |
||
72 | */ |
||
73 | final public function __construct(AbstractOptionDefinition $options) |
||
77 | |||
78 | /** |
||
79 | * Abstraction for processing the middleware initialization. |
||
80 | * |
||
81 | * For own initialization, @see initializeMiddleware() |
||
82 | */ |
||
83 | final public function initialize() |
||
87 | |||
88 | /** |
||
89 | * You can override this method in your child class to initialize your |
||
90 | * middleware correctly. |
||
91 | */ |
||
92 | protected function initializeMiddleware() |
||
95 | |||
96 | /** |
||
97 | * @see \Romm\Formz\Middleware\Signal\SendsMiddlewareSignal::beforeSignal() |
||
98 | * |
||
99 | * @param string $signal |
||
100 | * @return SignalObject |
||
101 | */ |
||
102 | final public function beforeSignal($signal = null) |
||
106 | |||
107 | /** |
||
108 | * @see \Romm\Formz\Middleware\Signal\SendsMiddlewareSignal::afterSignal() |
||
109 | * |
||
110 | * @param string $signal |
||
111 | * @return SignalObject |
||
112 | */ |
||
113 | final public function afterSignal($signal = null) |
||
117 | |||
118 | /** |
||
119 | * @return AbstractOptionDefinition |
||
120 | */ |
||
121 | public function getOptions() |
||
122 | { |
||
123 | return $this->options; |
||
124 | } |
||
125 | |||
126 | /** |
||
127 | * Returns a new forward dispatcher, on which you can add options by calling |
||
128 | * its fluent methods. |
||
129 | * |
||
130 | * You must call the method `dispatch()` to actually dispatch the forward |
||
131 | * signal. |
||
132 | * |
||
133 | * @return Forward |
||
134 | */ |
||
135 | final protected function forward() |
||
136 | { |
||
137 | return new Forward($this->getRequest()); |
||
138 | } |
||
139 | |||
140 | /** |
||
141 | * Returns a new redirect dispatcher, on which you can add options by |
||
142 | * calling its fluent methods. |
||
143 | * |
||
144 | * You must call the method `dispatch()` to actually dispatch the redirect |
||
145 | * signal. |
||
146 | * |
||
147 | * @return Redirect |
||
148 | */ |
||
149 | final protected function redirect() { |
||
150 | return new Redirect($this->getRequest()); |
||
151 | } |
||
152 | |||
153 | /** |
||
154 | * Will stop the propagation of middlewares: the next middlewares wont be |
||
155 | * processed. |
||
156 | * |
||
157 | * Use with caution! |
||
158 | */ |
||
159 | final protected function stopPropagation() |
||
160 | { |
||
161 | throw new StopPropagationException; |
||
162 | } |
||
163 | |||
164 | /** |
||
165 | * @return FormObject |
||
166 | */ |
||
167 | final protected function getFormObject() |
||
168 | { |
||
169 | return $this->state->getFormObject(); |
||
170 | } |
||
171 | |||
172 | /** |
||
173 | * @return Request |
||
174 | */ |
||
175 | final protected function getRequest() |
||
179 | |||
180 | /** |
||
181 | * @return Arguments |
||
182 | */ |
||
183 | final protected function getRequestArguments() |
||
187 | |||
188 | /** |
||
189 | * @return array |
||
190 | */ |
||
191 | final protected function getSettings() |
||
195 | |||
196 | /** |
||
197 | * @return StepItem|null |
||
198 | */ |
||
199 | final protected function getCurrentStep() |
||
200 | { |
||
207 | |||
208 | /** |
||
209 | * @return int |
||
210 | */ |
||
211 | public function getPriority() |
||
215 | |||
216 | /** |
||
217 | * @param MiddlewareState $middlewareState |
||
218 | */ |
||
219 | final public function bindMiddlewareState(MiddlewareState $middlewareState) |
||
223 | |||
224 | /** |
||
225 | * Returns the name of the signal on which this middleware is bound. |
||
226 | * |
||
227 | * @return string |
||
228 | * @throws SignalNotFoundException |
||
229 | */ |
||
230 | final public function getBoundSignalName() |
||
242 | |||
243 | /** |
||
244 | * Will inject empty options if no option has been defined at all. |
||
245 | * |
||
246 | * @param DataPreProcessor $processor |
||
247 | */ |
||
248 | public static function dataPreProcessor(DataPreProcessor $processor) |
||
258 | |||
259 | /** |
||
260 | * @param string $signal |
||
261 | * @param string $type |
||
262 | * @return SignalObject |
||
263 | * @throws InvalidArgumentValueException |
||
264 | * @throws InvalidEntryException |
||
265 | * @throws MissingArgumentException |
||
266 | */ |
||
267 | private function getSignalObject($signal, $type) |
||
288 | |||
289 | /** |
||
290 | * @return array |
||
291 | */ |
||
292 | public function __sleep() |
||
296 | } |
||
297 |
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.