Passed
Push — v5.x ( 87a13b...e527ef )
by Thierry
02:13
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/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   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      *
33 33
      * @return ResponseInterface
34 34
      */
35
-    abstract public function addCommand(string $sName, array|JsonSerializable $aOptions): ResponseInterface;
35
+    abstract public function addCommand(string $sName, array | JsonSerializable $aOptions): ResponseInterface;
36 36
 
37 37
     /**
38 38
      * Convert to string
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     {
60 60
         $aArgs = func_get_args();
61 61
         array_shift($aArgs);
62
-        return $this->addCommand('script.call', ['func' => $this->str($sFunc),'args' => $aArgs]);
62
+        return $this->addCommand('script.call', ['func' => $this->str($sFunc), 'args' => $aArgs]);
63 63
     }
64 64
 
65 65
     /**
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
     {
79 79
         $xResponse = jaxon()->newResponse();
80 80
         $fCalls($xResponse);
81
-        if(($nCommandCount = $xResponse->getCommandCount()) > 0)
81
+        if (($nCommandCount = $xResponse->getCommandCount()) > 0)
82 82
         {
83 83
             $this->addCommand('script.confirm', [
84 84
                 'count' => $nCommandCount,
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/Plugin/Response/DataBag/DataBagPlugin.php 1 patch
Spacing   +4 added lines, -6 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/Plugin/Request/CallableClass/CallableDirPlugin.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     private function checkDirectory(string $sDirectory): string
81 81
     {
82 82
         $sDirectory = rtrim(trim($sDirectory), '/\\');
83
-        if(!is_dir($sDirectory))
83
+        if (!is_dir($sDirectory))
84 84
         {
85 85
             throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration'));
86 86
         }
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
      */
94 94
     public function checkOptions(string $sCallable, $xOptions): array
95 95
     {
96
-        if(is_string($xOptions))
96
+        if (is_string($xOptions))
97 97
         {
98 98
             $xOptions = ['namespace' => $xOptions];
99 99
         }
100
-        if(!is_array($xOptions))
100
+        if (!is_array($xOptions))
101 101
         {
102 102
             throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration'));
103 103
         }
@@ -105,14 +105,14 @@  discard block
 block discarded – undo
105 105
         $xOptions['directory'] = $this->checkDirectory($sCallable);
106 106
         // Check the namespace
107 107
         $sNamespace = $xOptions['namespace'] ?? '';
108
-        if(!($xOptions['namespace'] = trim($sNamespace, ' \\')))
108
+        if (!($xOptions['namespace'] = trim($sNamespace, ' \\')))
109 109
         {
110 110
             $xOptions['namespace'] = '';
111 111
         }
112 112
 
113 113
         // Change the keys in $xOptions to have "\" as separator
114 114
         $_aOptions = [];
115
-        foreach($xOptions as $sName => $aOption)
115
+        foreach ($xOptions as $sName => $aOption)
116 116
         {
117 117
             $sName = trim(str_replace('.', '\\', $sName), ' \\');
118 118
             $_aOptions[$sName] = $aOption;
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public function register(string $sType, string $sCallable, array $aOptions): bool
127 127
     {
128
-        if(($aOptions['namespace']))
128
+        if (($aOptions['namespace']))
129 129
         {
130 130
             $this->xRegistry->addNamespace($aOptions['namespace'], $aOptions);
131 131
             return true;
Please login to merge, or discard this patch.
src/Response/Response.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      */
127 127
     protected function str($xData): string
128 128
     {
129
-        return trim((string)$xData, " \t\n");
129
+        return trim((string) $xData, " \t\n");
130 130
     }
131 131
 
132 132
     /**
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
     public function toPsr(): PsrResponseInterface
186 186
     {
187 187
         $xPsrResponse = $this->xPsr17Factory->createResponse(200);
188
-        if($this->xRequest->getMethod() === 'GET')
188
+        if ($this->xRequest->getMethod() === 'GET')
189 189
         {
190 190
             $xPsrResponse = $xPsrResponse
191 191
                 ->withHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT')
Please login to merge, or discard this patch.