@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | */ |
215 | 215 | public function set(string $sClass, Closure $xClosure) |
216 | 216 | { |
217 | - $this->xLibContainer->offsetSet($sClass, function() use($xClosure) { |
|
217 | + $this->xLibContainer->offsetSet($sClass, function() use($xClosure) { |
|
218 | 218 | return $xClosure($this); |
219 | 219 | }); |
220 | 220 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | */ |
230 | 230 | public function val(string $sKey, $xValue) |
231 | 231 | { |
232 | - $this->xLibContainer->offsetSet($sKey, $xValue); |
|
232 | + $this->xLibContainer->offsetSet($sKey, $xValue); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function has(string $sClass): bool |
159 | 159 | { |
160 | - if($this->xAppContainer != null && $this->xAppContainer->has($sClass)) |
|
160 | + if ($this->xAppContainer != null && $this->xAppContainer->has($sClass)) |
|
161 | 161 | { |
162 | 162 | return true; |
163 | 163 | } |
@@ -188,13 +188,13 @@ discard block |
||
188 | 188 | { |
189 | 189 | try |
190 | 190 | { |
191 | - if($this->xAppContainer != null && $this->xAppContainer->has($sClass)) |
|
191 | + if ($this->xAppContainer != null && $this->xAppContainer->has($sClass)) |
|
192 | 192 | { |
193 | 193 | return $this->xAppContainer->get($sClass); |
194 | 194 | } |
195 | 195 | return $this->xLibContainer->offsetGet($sClass); |
196 | 196 | } |
197 | - catch(Exception|Throwable $e) |
|
197 | + catch (Exception | Throwable $e) |
|
198 | 198 | { |
199 | 199 | $xLogger = $this->g(LoggerInterface::class); |
200 | 200 | $xTranslator = $this->g(Translator::class); |
@@ -258,15 +258,15 @@ discard block |
||
258 | 258 | { |
259 | 259 | $xType = $xParameter->getType(); |
260 | 260 | // Check the parameter class first. |
261 | - if($xType instanceof ReflectionNamedType) |
|
261 | + if ($xType instanceof ReflectionNamedType) |
|
262 | 262 | { |
263 | 263 | // Check the class + the name |
264 | - if($this->has($xType->getName() . ' $' . $xParameter->getName())) |
|
264 | + if ($this->has($xType->getName() . ' $' . $xParameter->getName())) |
|
265 | 265 | { |
266 | 266 | return $this->get($xType->getName() . ' $' . $xParameter->getName()); |
267 | 267 | } |
268 | 268 | // Check the class only |
269 | - if($this->get($xType->getName())) |
|
269 | + if ($this->get($xType->getName())) |
|
270 | 270 | { |
271 | 271 | return $this->get($xType->getName()); |
272 | 272 | } |
@@ -286,16 +286,16 @@ discard block |
||
286 | 286 | */ |
287 | 287 | public function make($xClass) |
288 | 288 | { |
289 | - if(is_string($xClass)) |
|
289 | + if (is_string($xClass)) |
|
290 | 290 | { |
291 | 291 | $xClass = new ReflectionClass($xClass); // Create the reflection class instance |
292 | 292 | } |
293 | - if(!($xClass instanceof ReflectionClass)) |
|
293 | + if (!($xClass instanceof ReflectionClass)) |
|
294 | 294 | { |
295 | 295 | return null; |
296 | 296 | } |
297 | 297 | // Use the Reflection class to get the parameters of the constructor |
298 | - if(($constructor = $xClass->getConstructor()) === null) |
|
298 | + if (($constructor = $xClass->getConstructor()) === null) |
|
299 | 299 | { |
300 | 300 | return $xClass->newInstance(); |
301 | 301 | } |
@@ -193,8 +193,7 @@ |
||
193 | 193 | return $this->xAppContainer->get($sClass); |
194 | 194 | } |
195 | 195 | return $this->xLibContainer->offsetGet($sClass); |
196 | - } |
|
197 | - catch(Exception|Throwable $e) |
|
196 | + } catch(Exception|Throwable $e) |
|
198 | 197 | { |
199 | 198 | $xLogger = $this->g(LoggerInterface::class); |
200 | 199 | $xTranslator = $this->g(Translator::class); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $this->xUploadHandler = $this->di->getUploadHandler(); |
109 | 109 | |
110 | 110 | // Return true if the request plugin was already found |
111 | - if($this->xRequestPlugin !== null) |
|
111 | + if ($this->xRequestPlugin !== null) |
|
112 | 112 | { |
113 | 113 | return true; |
114 | 114 | } |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | // The HTTP request |
117 | 117 | $xRequest = $this->di->getRequest(); |
118 | 118 | // Find a plugin to process the request |
119 | - foreach($this->xPluginManager->getRequestHandlers() as $sClassName) |
|
119 | + foreach ($this->xPluginManager->getRequestHandlers() as $sClassName) |
|
120 | 120 | { |
121 | - if($sClassName::canProcessRequest($xRequest)) |
|
121 | + if ($sClassName::canProcessRequest($xRequest)) |
|
122 | 122 | { |
123 | 123 | $this->xRequestPlugin = $this->di->g($sClassName); |
124 | 124 | $this->xRequestPlugin->setTarget($xRequest); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | // Check if the upload plugin is enabled |
130 | - if($this->xUploadHandler === null) |
|
130 | + if ($this->xUploadHandler === null) |
|
131 | 131 | { |
132 | 132 | return false; |
133 | 133 | } |
@@ -149,15 +149,15 @@ discard block |
||
149 | 149 | // The HTTP request |
150 | 150 | $xRequest = $this->di->getRequest(); |
151 | 151 | // Process uploaded files, if the upload plugin is enabled |
152 | - if($this->xUploadHandler !== null && $this->xUploadHandler->canProcessRequest($xRequest)) |
|
152 | + if ($this->xUploadHandler !== null && $this->xUploadHandler->canProcessRequest($xRequest)) |
|
153 | 153 | { |
154 | 154 | $this->xUploadHandler->processRequest($xRequest); |
155 | 155 | } |
156 | 156 | // Process the request |
157 | - if(($this->xRequestPlugin)) |
|
157 | + if (($this->xRequestPlugin)) |
|
158 | 158 | { |
159 | 159 | $xResponse = $this->xRequestPlugin->processRequest(); |
160 | - if(($xResponse)) |
|
160 | + if (($xResponse)) |
|
161 | 161 | { |
162 | 162 | $this->xResponseManager->append($xResponse); |
163 | 163 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | public function processRequest() |
179 | 179 | { |
180 | 180 | // Check if there is a plugin to process this request |
181 | - if(!$this->canProcessRequest()) |
|
181 | + if (!$this->canProcessRequest()) |
|
182 | 182 | { |
183 | 183 | return; |
184 | 184 | } |
@@ -187,11 +187,11 @@ discard block |
||
187 | 187 | { |
188 | 188 | $bEndRequest = false; |
189 | 189 | // Handle before processing event |
190 | - if(($this->xRequestPlugin)) |
|
190 | + if (($this->xRequestPlugin)) |
|
191 | 191 | { |
192 | 192 | $this->xCallbackManager->onBefore($this->xRequestPlugin->getTarget(), $bEndRequest); |
193 | 193 | } |
194 | - if($bEndRequest) |
|
194 | + if ($bEndRequest) |
|
195 | 195 | { |
196 | 196 | return; |
197 | 197 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $this->_processRequest(); |
200 | 200 | |
201 | 201 | // Handle after processing event |
202 | - if(($this->xRequestPlugin)) |
|
202 | + if (($this->xRequestPlugin)) |
|
203 | 203 | { |
204 | 204 | $this->xCallbackManager->onAfter($this->xRequestPlugin->getTarget(), $bEndRequest); |
205 | 205 | } |
@@ -207,12 +207,12 @@ discard block |
||
207 | 207 | // An exception was thrown while processing the request. |
208 | 208 | // The request missed the corresponding handler function, |
209 | 209 | // or an error occurred while attempting to execute the handler. |
210 | - catch(RequestException $e) |
|
210 | + catch (RequestException $e) |
|
211 | 211 | { |
212 | 212 | $this->xResponseManager->error($e->getMessage()); |
213 | 213 | $this->xCallbackManager->onInvalid($e); |
214 | 214 | } |
215 | - catch(Exception $e) |
|
215 | + catch (Exception $e) |
|
216 | 216 | { |
217 | 217 | $this->xResponseManager->error($e->getMessage()); |
218 | 218 | $this->xCallbackManager->onError($e); |
@@ -211,8 +211,7 @@ |
||
211 | 211 | { |
212 | 212 | $this->xResponseManager->error($e->getMessage()); |
213 | 213 | $this->xCallbackManager->onInvalid($e); |
214 | - } |
|
215 | - catch(Exception $e) |
|
214 | + } catch(Exception $e) |
|
216 | 215 | { |
217 | 216 | $this->xResponseManager->error($e->getMessage()); |
218 | 217 | $this->xCallbackManager->onError($e); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function popBootCallbacks(): array |
101 | 101 | { |
102 | - if(empty($this->aBootCallbacks)) |
|
102 | + if (empty($this->aBootCallbacks)) |
|
103 | 103 | { |
104 | 104 | return []; |
105 | 105 | } |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | private function getExceptionCallbacks(Exception $xException): array |
119 | 119 | { |
120 | 120 | $aExceptionCallbacks = []; |
121 | - foreach($this->aExceptionCallbacks as $sExClass => $aCallbacks) |
|
121 | + foreach ($this->aExceptionCallbacks as $sExClass => $aCallbacks) |
|
122 | 122 | { |
123 | - if(is_a($xException, $sExClass)) |
|
123 | + if (is_a($xException, $sExClass)) |
|
124 | 124 | { |
125 | 125 | $aExceptionCallbacks = array_merge($aExceptionCallbacks, $aCallbacks); |
126 | 126 | } |
@@ -190,13 +190,13 @@ discard block |
||
190 | 190 | */ |
191 | 191 | public function error(callable $xCallable, string $sExClass = ''): CallbackManager |
192 | 192 | { |
193 | - if($sExClass === '' || $sExClass === Exception::class) |
|
193 | + if ($sExClass === '' || $sExClass === Exception::class) |
|
194 | 194 | { |
195 | 195 | $this->aErrorCallbacks[] = $xCallable; |
196 | 196 | return $this; |
197 | 197 | } |
198 | 198 | // Callback for a given exception class |
199 | - if(isset($this->aExceptionCallbacks[$sExClass])) |
|
199 | + if (isset($this->aExceptionCallbacks[$sExClass])) |
|
200 | 200 | { |
201 | 201 | $this->aExceptionCallbacks[$sExClass][] = $xCallable; |
202 | 202 | return $this; |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | private function executeCallback(callable $xCallback, array $aParameters) |
228 | 228 | { |
229 | 229 | $xReturn = call_user_func_array($xCallback, $aParameters); |
230 | - if($xReturn instanceof ResponseInterface) |
|
230 | + if ($xReturn instanceof ResponseInterface) |
|
231 | 231 | { |
232 | 232 | $this->xResponseManager->append($xReturn); |
233 | 233 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | */ |
242 | 242 | private function executeCallbacks(array $aCallbacks, array $aParameters) |
243 | 243 | { |
244 | - foreach($aCallbacks as $xCallback) |
|
244 | + foreach ($aCallbacks as $xCallback) |
|
245 | 245 | { |
246 | 246 | $this->executeCallback($xCallback, $aParameters); |
247 | 247 | } |
@@ -271,10 +271,10 @@ discard block |
||
271 | 271 | public function onBefore(Target $xTarget, bool &$bEndRequest) |
272 | 272 | { |
273 | 273 | // Call the user defined callback |
274 | - foreach($this->aBeforeCallbacks as $xCallback) |
|
274 | + foreach ($this->aBeforeCallbacks as $xCallback) |
|
275 | 275 | { |
276 | 276 | $this->executeCallback($xCallback, [$xTarget, &$bEndRequest]); |
277 | - if($bEndRequest) |
|
277 | + if ($bEndRequest) |
|
278 | 278 | { |
279 | 279 | return; |
280 | 280 | } |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | { |
322 | 322 | $aExceptionCallbacks = $this->getExceptionCallbacks($xException); |
323 | 323 | $this->executeCallbacks($aExceptionCallbacks, [$xException]); |
324 | - if(count($aExceptionCallbacks) > 0) |
|
324 | + if (count($aExceptionCallbacks) > 0) |
|
325 | 325 | { |
326 | 326 | // Do not throw the exception if a custom handler is defined |
327 | 327 | return; |
@@ -317,14 +317,14 @@ discard block |
||
317 | 317 | public function toArray(): array |
318 | 318 | { |
319 | 319 | $aCall = parent::toArray(); |
320 | - if($this->bConfirm) |
|
320 | + if ($this->bConfirm) |
|
321 | 321 | { |
322 | 322 | $aCall['confirm'] = $this->aConfirmArgs; |
323 | 323 | } |
324 | - if(($this->aCondition)) |
|
324 | + if (($this->aCondition)) |
|
325 | 325 | { |
326 | 326 | $aCall['condition'] = $this->aCondition; |
327 | - if(($this->aMessageArgs)) |
|
327 | + if (($this->aMessageArgs)) |
|
328 | 328 | { |
329 | 329 | $aCall['else'] = $this->getMessage(); |
330 | 330 | } |
@@ -339,9 +339,9 @@ discard block |
||
339 | 339 | */ |
340 | 340 | private function findPageNumber(): ?ParameterInterface |
341 | 341 | { |
342 | - foreach($this->aParameters as $xParameter) |
|
342 | + foreach ($this->aParameters as $xParameter) |
|
343 | 343 | { |
344 | - if($xParameter->getType() === Parameter::PAGE_NUMBER) |
|
344 | + if ($xParameter->getType() === Parameter::PAGE_NUMBER) |
|
345 | 345 | { |
346 | 346 | return $xParameter; |
347 | 347 | } |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | { |
371 | 371 | /** @var Parameter */ |
372 | 372 | $xParameter = $this->findPageNumber(); |
373 | - if($xParameter !== null) |
|
373 | + if ($xParameter !== null) |
|
374 | 374 | { |
375 | 375 | $xParameter->setValue($nPageNumber); |
376 | 376 | } |
@@ -154,8 +154,7 @@ discard block |
||
154 | 154 | */ |
155 | 155 | protected function updateTotalPages(): Paginator |
156 | 156 | { |
157 | - $this->nTotalPages = ($this->nItemsPerPage === 0 ? 0 : |
|
158 | - (int)ceil($this->nTotalItems / $this->nItemsPerPage)); |
|
157 | + $this->nTotalPages = ($this->nItemsPerPage === 0 ? 0 : (int) ceil($this->nTotalItems / $this->nItemsPerPage)); |
|
159 | 158 | return $this; |
160 | 159 | } |
161 | 160 | |
@@ -219,8 +218,7 @@ discard block |
||
219 | 218 | protected function getPrevPage(): Page |
220 | 219 | { |
221 | 220 | return $this->nCurrentPage <= 1 ? |
222 | - new Page('disabled', $this->sPreviousText, 0) : |
|
223 | - new Page('enabled', $this->sPreviousText, $this->nCurrentPage - 1); |
|
221 | + new Page('disabled', $this->sPreviousText, 0) : new Page('enabled', $this->sPreviousText, $this->nCurrentPage - 1); |
|
224 | 222 | } |
225 | 223 | |
226 | 224 | /** |
@@ -231,8 +229,7 @@ discard block |
||
231 | 229 | protected function getNextPage(): Page |
232 | 230 | { |
233 | 231 | return $this->nCurrentPage >= $this->nTotalPages ? |
234 | - new Page('disabled', $this->sNextText, 0) : |
|
235 | - new Page('enabled', $this->sNextText, $this->nCurrentPage + 1); |
|
232 | + new Page('disabled', $this->sNextText, 0) : new Page('enabled', $this->sNextText, $this->nCurrentPage + 1); |
|
236 | 233 | } |
237 | 234 | |
238 | 235 | /** |
@@ -244,7 +241,7 @@ discard block |
||
244 | 241 | */ |
245 | 242 | protected function getPage(int $nNumber): Page |
246 | 243 | { |
247 | - if($nNumber < 1) |
|
244 | + if ($nNumber < 1) |
|
248 | 245 | { |
249 | 246 | return new Page('disabled', $this->sEllipsysText, 0); |
250 | 247 | } |
@@ -263,9 +260,9 @@ discard block |
||
263 | 260 | { |
264 | 261 | $aPageNumbers = []; |
265 | 262 | |
266 | - if($this->nTotalPages <= $this->nMaxPages) |
|
263 | + if ($this->nTotalPages <= $this->nMaxPages) |
|
267 | 264 | { |
268 | - for($i = 0; $i < $this->nTotalPages; $i++) |
|
265 | + for ($i = 0; $i < $this->nTotalPages; $i++) |
|
269 | 266 | { |
270 | 267 | $aPageNumbers[] = $i + 1; |
271 | 268 | } |
@@ -274,11 +271,11 @@ discard block |
||
274 | 271 | } |
275 | 272 | |
276 | 273 | // Determine the sliding range, centered around the current page. |
277 | - $nNumAdjacents = (int)floor(($this->nMaxPages - 4) / 2); |
|
274 | + $nNumAdjacents = (int) floor(($this->nMaxPages - 4) / 2); |
|
278 | 275 | |
279 | 276 | $nSlidingStart = 1; |
280 | 277 | $nSlidingEndOffset = $nNumAdjacents + 3 - $this->nCurrentPage; |
281 | - if($nSlidingEndOffset < 0) |
|
278 | + if ($nSlidingEndOffset < 0) |
|
282 | 279 | { |
283 | 280 | $nSlidingStart = $this->nCurrentPage - $nNumAdjacents; |
284 | 281 | $nSlidingEndOffset = 0; |
@@ -286,23 +283,23 @@ discard block |
||
286 | 283 | |
287 | 284 | $nSlidingEnd = $this->nTotalPages; |
288 | 285 | $nSlidingStartOffset = $this->nCurrentPage + $nNumAdjacents + 2 - $this->nTotalPages; |
289 | - if($nSlidingStartOffset < 0) |
|
286 | + if ($nSlidingStartOffset < 0) |
|
290 | 287 | { |
291 | 288 | $nSlidingEnd = $this->nCurrentPage + $nNumAdjacents; |
292 | 289 | $nSlidingStartOffset = 0; |
293 | 290 | } |
294 | 291 | |
295 | 292 | // Build the list of page numbers. |
296 | - if($nSlidingStart > 1) |
|
293 | + if ($nSlidingStart > 1) |
|
297 | 294 | { |
298 | 295 | $aPageNumbers[] = 1; |
299 | 296 | $aPageNumbers[] = 0; // Ellipsys; |
300 | 297 | } |
301 | - for($i = $nSlidingStart - $nSlidingStartOffset; $i <= $nSlidingEnd + $nSlidingEndOffset; $i++) |
|
298 | + for ($i = $nSlidingStart - $nSlidingStartOffset; $i <= $nSlidingEnd + $nSlidingEndOffset; $i++) |
|
302 | 299 | { |
303 | 300 | $aPageNumbers[] = $i; |
304 | 301 | } |
305 | - if($nSlidingEnd < $this->nTotalPages) |
|
302 | + if ($nSlidingEnd < $this->nTotalPages) |
|
306 | 303 | { |
307 | 304 | $aPageNumbers[] = 0; // Ellipsys; |
308 | 305 | $aPageNumbers[] = $this->nTotalPages; |
@@ -318,7 +315,7 @@ discard block |
||
318 | 315 | */ |
319 | 316 | public function pages(): array |
320 | 317 | { |
321 | - if($this->nTotalPages < 2) |
|
318 | + if ($this->nTotalPages < 2) |
|
322 | 319 | { |
323 | 320 | return []; |
324 | 321 | } |
@@ -166,30 +166,30 @@ |
||
166 | 166 | { |
167 | 167 | switch($this->getType()) |
168 | 168 | { |
169 | - case self::JS_CALL: |
|
170 | - return $this->getValue()->toArray(); |
|
171 | - case self::JS_VALUE: |
|
172 | - return [ |
|
173 | - '_type' => 'expr', |
|
174 | - 'calls' => [['_type' => 'attr', '_name' => $this->getValue()]], |
|
175 | - ]; |
|
176 | - case self::FORM_VALUES: |
|
177 | - return ['_type' => 'form', '_name' => $this->getValue()]; |
|
178 | - case self::INPUT_VALUE: |
|
179 | - return ['_type' => 'input', '_name' => $this->getValue()]; |
|
180 | - case self::CHECKED_VALUE: |
|
181 | - return ['_type' => 'checked', '_name' => $this->getValue()]; |
|
182 | - case self::ELEMENT_INNERHTML: |
|
183 | - return ['_type' => 'html', '_name' => $this->getValue()]; |
|
184 | - case self::PAGE_NUMBER: |
|
185 | - return ['_type' => 'page', '_name' => '']; |
|
186 | - case self::QUOTED_VALUE: |
|
187 | - case self::BOOL_VALUE: |
|
188 | - case self::NUMERIC_VALUE: |
|
189 | - case self::JSON_VALUE: |
|
190 | - default: |
|
191 | - // Return the value as is. |
|
192 | - return $this->getValue(); |
|
169 | + case self::JS_CALL: |
|
170 | + return $this->getValue()->toArray(); |
|
171 | + case self::JS_VALUE: |
|
172 | + return [ |
|
173 | + '_type' => 'expr', |
|
174 | + 'calls' => [['_type' => 'attr', '_name' => $this->getValue()]], |
|
175 | + ]; |
|
176 | + case self::FORM_VALUES: |
|
177 | + return ['_type' => 'form', '_name' => $this->getValue()]; |
|
178 | + case self::INPUT_VALUE: |
|
179 | + return ['_type' => 'input', '_name' => $this->getValue()]; |
|
180 | + case self::CHECKED_VALUE: |
|
181 | + return ['_type' => 'checked', '_name' => $this->getValue()]; |
|
182 | + case self::ELEMENT_INNERHTML: |
|
183 | + return ['_type' => 'html', '_name' => $this->getValue()]; |
|
184 | + case self::PAGE_NUMBER: |
|
185 | + return ['_type' => 'page', '_name' => '']; |
|
186 | + case self::QUOTED_VALUE: |
|
187 | + case self::BOOL_VALUE: |
|
188 | + case self::NUMERIC_VALUE: |
|
189 | + case self::JSON_VALUE: |
|
190 | + default: |
|
191 | + // Return the value as is. |
|
192 | + return $this->getValue(); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | } |
@@ -131,23 +131,23 @@ discard block |
||
131 | 131 | */ |
132 | 132 | public static function make($xValue): ParameterInterface |
133 | 133 | { |
134 | - if($xValue instanceof ParameterInterface) |
|
134 | + if ($xValue instanceof ParameterInterface) |
|
135 | 135 | { |
136 | 136 | return $xValue; |
137 | 137 | } |
138 | - if(is_numeric($xValue)) |
|
138 | + if (is_numeric($xValue)) |
|
139 | 139 | { |
140 | 140 | return new Parameter(self::NUMERIC_VALUE, $xValue); |
141 | 141 | } |
142 | - if(is_string($xValue)) |
|
142 | + if (is_string($xValue)) |
|
143 | 143 | { |
144 | 144 | return new Parameter(self::QUOTED_VALUE, $xValue); |
145 | 145 | } |
146 | - if(is_bool($xValue)) |
|
146 | + if (is_bool($xValue)) |
|
147 | 147 | { |
148 | 148 | return new Parameter(self::BOOL_VALUE, $xValue); |
149 | 149 | } |
150 | - if($xValue instanceof JsCall) |
|
150 | + if ($xValue instanceof JsCall) |
|
151 | 151 | { |
152 | 152 | return new Parameter(self::JS_CALL, $xValue); |
153 | 153 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function jsonSerialize() |
166 | 166 | { |
167 | - switch($this->getType()) |
|
167 | + switch ($this->getType()) |
|
168 | 168 | { |
169 | 169 | case self::JS_CALL: |
170 | 170 | return $this->getValue()->toArray(); |
@@ -75,7 +75,7 @@ |
||
75 | 75 | public function selector(string $sPath = '', $xContext = null): DomSelector |
76 | 76 | { |
77 | 77 | $xSelector = new DomSelector($sPath, $xContext); |
78 | - if($this->bCommand && $this->response() !== null) |
|
78 | + if ($this->bCommand && $this->response() !== null) |
|
79 | 79 | { |
80 | 80 | $this->addCommand('jquery', ['selector' => $xSelector]); |
81 | 81 | } |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function __call(string $sMethod, array $aArguments) |
101 | 101 | { |
102 | - if(count($aArguments) === 1) |
|
102 | + if (count($aArguments) === 1) |
|
103 | 103 | { |
104 | 104 | // If the only parameter is a selector, and the first call |
105 | 105 | // on that selector is a method, then the selector is a callback. |
106 | 106 | $xArgument = $aArguments[0]; |
107 | - if(is_a($xArgument, self::class) && $xArgument->bIsCallback === null && |
|
107 | + if (is_a($xArgument, self::class) && $xArgument->bIsCallback === null && |
|
108 | 108 | count($xArgument->aCalls) > 0 && is_a($xArgument->aCalls[0], JsCall::class)) |
109 | 109 | { |
110 | 110 | $xArgument->bIsCallback = true; |
@@ -174,12 +174,12 @@ discard block |
||
174 | 174 | */ |
175 | 175 | private function selectCalls() |
176 | 176 | { |
177 | - if(!$this->sPath) |
|
177 | + if (!$this->sPath) |
|
178 | 178 | { |
179 | 179 | // If an empty selector is given, use the event target instead |
180 | 180 | return [['_type' => 'select', '_name' => 'this']]; |
181 | 181 | } |
182 | - if(!$this->xContext) |
|
182 | + if (!$this->xContext) |
|
183 | 183 | { |
184 | 184 | return [['_type' => 'select', '_name' => $this->sPath]]; |
185 | 185 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | private function makeCallsArray($xParam): array |
197 | 197 | { |
198 | - if(!is_a($xParam, Method::class)) |
|
198 | + if (!is_a($xParam, Method::class)) |
|
199 | 199 | { |
200 | 200 | // Return an array of array. |
201 | 201 | return [$xParam->jsonSerialize()]; |
@@ -213,17 +213,17 @@ discard block |
||
213 | 213 | public function toArray(): array |
214 | 214 | { |
215 | 215 | $aCalls = $this->selectCalls(); |
216 | - foreach($this->aCalls as $xCall) |
|
216 | + foreach ($this->aCalls as $xCall) |
|
217 | 217 | { |
218 | 218 | $aCalls = array_merge($aCalls, $this->makeCallsArray($xCall)); |
219 | 219 | } |
220 | - if($this->bToInt) |
|
220 | + if ($this->bToInt) |
|
221 | 221 | { |
222 | 222 | $aCalls[] = [ |
223 | 223 | '_type' => 'func', |
224 | 224 | '_name' => 'jaxon.utils.string.toInt', |
225 | 225 | 'params' => [ |
226 | - [ '_type' => '_', '_name' => 'this' ], |
|
226 | + ['_type' => '_', '_name' => 'this'], |
|
227 | 227 | ], |
228 | 228 | ]; |
229 | 229 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | private function initDataBag() |
41 | 41 | { |
42 | - if($this->xDataBag !== null) |
|
42 | + if ($this->xDataBag !== null) |
|
43 | 43 | { |
44 | 44 | return; |
45 | 45 | } |
@@ -48,8 +48,7 @@ discard block |
||
48 | 48 | $aBody = $xRequest->getParsedBody(); |
49 | 49 | $aParams = $xRequest->getQueryParams(); |
50 | 50 | $aData = is_array($aBody) ? |
51 | - $this->readData($aBody['jxnbags'] ?? []) : |
|
52 | - $this->readData($aParams['jxnbags'] ?? []); |
|
51 | + $this->readData($aBody['jxnbags'] ?? []) : $this->readData($aParams['jxnbags'] ?? []); |
|
53 | 52 | $this->xDataBag = new DataBag($aData); |
54 | 53 | } |
55 | 54 | |
@@ -70,8 +69,7 @@ discard block |
||
70 | 69 | { |
71 | 70 | // Todo: clean input data. |
72 | 71 | return is_string($xData) ? |
73 | - (json_decode($xData, true) ?: []) : |
|
74 | - (is_array($xData) ? $xData : []); |
|
72 | + (json_decode($xData, true) ?: []) : (is_array($xData) ? $xData : []); |
|
75 | 73 | } |
76 | 74 | |
77 | 75 | /** |
@@ -89,7 +87,7 @@ discard block |
||
89 | 87 | public function writeCommand() |
90 | 88 | { |
91 | 89 | $this->initDataBag(); |
92 | - if($this->xDataBag->touched()) |
|
90 | + if ($this->xDataBag->touched()) |
|
93 | 91 | { |
94 | 92 | $this->addCommand('bags.set', ['bags' => $this->xDataBag]); |
95 | 93 | } |