@@ -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; |
@@ -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 | } |
@@ -71,7 +71,7 @@ |
||
71 | 71 | * |
72 | 72 | * @return void |
73 | 73 | */ |
74 | - public function addCommand(string $sName, array|JsonSerializable $aOptions) |
|
74 | + public function addCommand(string $sName, array | JsonSerializable $aOptions) |
|
75 | 75 | { |
76 | 76 | $this->xResponse->addPluginCommand($this, $sName, $aOptions); |
77 | 77 | } |
@@ -17,14 +17,14 @@ |
||
17 | 17 | |
18 | 18 | trait HtmlDomTrait |
19 | 19 | { |
20 | - /** |
|
21 | - * Add a response command to the array of commands that will be sent to the browser |
|
22 | - * |
|
23 | - * @param string $sName The command name |
|
24 | - * @param array|JsonSerializable $aOptions The command options |
|
25 | - * |
|
26 | - * @return ResponseInterface |
|
27 | - */ |
|
20 | + /** |
|
21 | + * Add a response command to the array of commands that will be sent to the browser |
|
22 | + * |
|
23 | + * @param string $sName The command name |
|
24 | + * @param array|JsonSerializable $aOptions The command options |
|
25 | + * |
|
26 | + * @return ResponseInterface |
|
27 | + */ |
|
28 | 28 | abstract public function addCommand(string $sName, array|JsonSerializable $aOptions): ResponseInterface; |
29 | 29 | |
30 | 30 | /** |
@@ -25,7 +25,7 @@ |
||
25 | 25 | * |
26 | 26 | * @return ResponseInterface |
27 | 27 | */ |
28 | - abstract public function addCommand(string $sName, array|JsonSerializable $aOptions): ResponseInterface; |
|
28 | + abstract public function addCommand(string $sName, array | JsonSerializable $aOptions): ResponseInterface; |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Convert to string |
@@ -20,14 +20,14 @@ |
||
20 | 20 | |
21 | 21 | trait ScriptTrait |
22 | 22 | { |
23 | - /** |
|
24 | - * Add a response command to the array of commands that will be sent to the browser |
|
25 | - * |
|
26 | - * @param string $sName The command name |
|
27 | - * @param array|JsonSerializable $aOptions The command options |
|
28 | - * |
|
29 | - * @return ResponseInterface |
|
30 | - */ |
|
23 | + /** |
|
24 | + * Add a response command to the array of commands that will be sent to the browser |
|
25 | + * |
|
26 | + * @param string $sName The command name |
|
27 | + * @param array|JsonSerializable $aOptions The command options |
|
28 | + * |
|
29 | + * @return ResponseInterface |
|
30 | + */ |
|
31 | 31 | abstract public function addCommand(string $sName, array|JsonSerializable $aOptions): ResponseInterface; |
32 | 32 | |
33 | 33 | /** |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return ResponseInterface |
30 | 30 | */ |
31 | - abstract public function addCommand(string $sName, array|JsonSerializable $aOptions): ResponseInterface; |
|
31 | + abstract public function addCommand(string $sName, array | JsonSerializable $aOptions): ResponseInterface; |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Convert to string |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | { |
70 | 70 | $aArgs = func_get_args(); |
71 | 71 | array_shift($aArgs); |
72 | - return $this->addCommand('script.call', ['func' => $this->str($sFunc),'args' => $aArgs]); |
|
72 | + return $this->addCommand('script.call', ['func' => $this->str($sFunc), 'args' => $aArgs]); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -73,7 +73,7 @@ |
||
73 | 73 | * @return ResponseInterface |
74 | 74 | */ |
75 | 75 | public function addPluginCommand(ResponsePlugin $xPlugin, string $sName, |
76 | - array|JsonSerializable $aOptions): ResponseInterface; |
|
76 | + array | JsonSerializable $aOptions): ResponseInterface; |
|
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Convert this response to a PSR7 response object |
@@ -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.call', ['selector' => $xSelector]); |
81 | 81 | } |
@@ -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('databag.set', ['values' => $this->xDataBag]); |
95 | 93 | } |
@@ -135,18 +135,18 @@ |
||
135 | 135 | { |
136 | 136 | $xPaginator = new Paginator($nCurrentPage, $nItemsPerPage, $nTotalItems); |
137 | 137 | $aPages = $xPaginator->pages(); |
138 | - if(count($aPages) === 0) |
|
138 | + if (count($aPages) === 0) |
|
139 | 139 | { |
140 | 140 | return; |
141 | 141 | } |
142 | 142 | $xStore = $this->_render($aPages); |
143 | - if(!$xStore) |
|
143 | + if (!$xStore) |
|
144 | 144 | { |
145 | 145 | return; |
146 | 146 | } |
147 | 147 | |
148 | 148 | // Append the page number to the parameter list, if not yet given. |
149 | - if(!$xCall->hasPageNumber()) |
|
149 | + if (!$xCall->hasPageNumber()) |
|
150 | 150 | { |
151 | 151 | $xCall->addParameter(Parameter::PAGE_NUMBER, 0); |
152 | 152 | } |