Passed
Push — v5.x ( 73bdb8...59ec3d )
by Thierry
02:02
created
src/Request/Handler/CallbackManager.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/Plugin/Response/Pagination/Paginator.php 1 patch
Spacing   +13 added lines, -16 removed lines patch added patch discarded remove patch
@@ -154,8 +154,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/Plugin/Response/JQuery/DomSelector.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -99,12 +99,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/Plugin/ResponsePlugin.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/Response/Traits/HtmlDomTrait.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@
 block discarded – undo
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
     /**
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
src/Response/Traits/ScriptTrait.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -20,14 +20,14 @@
 block discarded – undo
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
     /**
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     /**
Please login to merge, or discard this patch.
src/Response/ResponseInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
src/Request/Call/JsCall.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      */
124 124
     public function addParameters(array $aParameters): JsCall
125 125
     {
126
-        foreach($aParameters as $xParameter)
126
+        foreach ($aParameters as $xParameter)
127 127
         {
128 128
             $this->pushParameter(Parameter::make($xParameter));
129 129
         }
@@ -144,12 +144,12 @@  discard block
 block discarded – undo
144 144
                 return $xParam->jsonSerialize();
145 145
             }, $this->aParameters),
146 146
         ]];
147
-        if($this->bToInt)
147
+        if ($this->bToInt)
148 148
         {
149 149
             $aCalls[] = [
150 150
                 '_type' => 'func',
151 151
                 '_name' => 'jaxon.utils.string.toInt',
152
-                'params' => [[ '_type' => '_', '_name' => 'this' ]],
152
+                'params' => [['_type' => '_', '_name' => 'this']],
153 153
             ];
154 154
         }
155 155
         return [
Please login to merge, or discard this patch.
src/Plugin/Response/JQuery/JQueryPlugin.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@
 block discarded – undo
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
         }
Please login to merge, or discard this patch.