Passed
Push — main ( 87fed9...27211a )
by Thierry
04:04
created
jaxon-core/src/App/View/TemplateView.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
         $sViewName = $store->getViewName();
60 60
         $sNamespace = $store->getNamespace();
61 61
         // In this view renderer, the namespace must always be prepended to the view name.
62
-        if(substr($sViewName, 0, strlen($sNamespace) + 2) != $sNamespace . '::')
62
+        if (substr($sViewName, 0, strlen($sNamespace) + 2) != $sNamespace . '::')
63 63
         {
64 64
             $sViewName = $sNamespace . '::' . $sViewName;
65 65
         }
Please login to merge, or discard this patch.
jaxon-core/src/App/View/Helper/EventAttr.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
      */
60 60
     public function on(string $event, JsExpr $xJsExpr): self
61 61
     {
62
-        if($this->sSelector === '')
62
+        if ($this->sSelector === '')
63 63
         {
64 64
             return $this;
65 65
         }
Please login to merge, or discard this patch.
jaxon-core/src/App/View/Helper/HtmlAttrHelper.php 1 patch
Spacing   +5 added lines, -8 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     public function html(JxnCall $xJsCall): string
55 55
     {
56 56
         $sClassName = $xJsCall->_class();
57
-        if(!$sClassName)
57
+        if (!$sClassName)
58 58
         {
59 59
             return '';
60 60
         }
@@ -88,8 +88,7 @@  discard block
 block discarded – undo
88 88
     public function pagination(JxnCall $xJsCall): string
89 89
     {
90 90
         // The pagination is always rendered with the same Pagination component.
91
-        $sComponent = $this->sPaginationComponent ?:
92
-            ($this->sPaginationComponent = rq(Pagination::class)->_class());
91
+        $sComponent = $this->sPaginationComponent ?: ($this->sPaginationComponent = rq(Pagination::class)->_class());
93 92
         $sItem = $xJsCall->_class();
94 93
         return "jxn-bind=\"$sComponent\" jxn-item=\"$sItem\"";
95 94
     }
@@ -154,15 +153,14 @@  discard block
 block discarded – undo
154 153
      */
155 154
     private function setEventHandler(array $aHandler, ?EventAttr $xAttr = null): EventAttr|null
156 155
     {
157
-        if(!$this->eventIsValid($aHandler))
156
+        if (!$this->eventIsValid($aHandler))
158 157
         {
159 158
             return $xAttr;
160 159
         }
161 160
         // The array content is valid.
162 161
         [$sSelector, $sEvent, $xJsExpr] = $aHandler;
163 162
         return !$xAttr ?
164
-            $this->select($sSelector)->on($sEvent, $xJsExpr) :
165
-            $xAttr->select($sSelector)->on($sEvent, $xJsExpr);
163
+            $this->select($sSelector)->on($sEvent, $xJsExpr) : $xAttr->select($sSelector)->on($sEvent, $xJsExpr);
166 164
     }
167 165
 
168 166
     /**
@@ -207,8 +205,7 @@  discard block
 block discarded – undo
207 205
         };
208 206
         $sCode = trim($sCode);
209 207
 
210
-        return $sType !== 'ready' || $sCode === '' ? $sCode :
211
-            // Call the ready code with the jaxon.dom.ready function.
208
+        return $sType !== 'ready' || $sCode === '' ? $sCode : // Call the ready code with the jaxon.dom.ready function.
212 209
             "jaxon.dom.ready(() => $sCode)";
213 210
     }
214 211
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/View/ViewRenderer.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -97,18 +97,18 @@  discard block
 block discarded – undo
97 97
      */
98 98
     public function addNamespaces(Config $xAppConfig): void
99 99
     {
100
-        if(empty($aNamespaces = $xAppConfig->getOptionNames('views')))
100
+        if (empty($aNamespaces = $xAppConfig->getOptionNames('views')))
101 101
         {
102 102
             return;
103 103
         }
104 104
 
105 105
         $sPackage = $xAppConfig->getOption('package', '');
106
-        foreach($aNamespaces as $sNamespace => $sOption)
106
+        foreach ($aNamespaces as $sNamespace => $sOption)
107 107
         {
108 108
             // Save the namespace
109 109
             $aNamespace = $xAppConfig->getOption($sOption);
110 110
             $aNamespace['package'] = $sPackage;
111
-            if(!isset($aNamespace['renderer']))
111
+            if (!isset($aNamespace['renderer']))
112 112
             {
113 113
                 $aNamespace['renderer'] = 'jaxon'; // 'jaxon' is the default renderer.
114 114
             }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
             $aNamespaces = array_filter($this->aNamespaces, function($aOptions) use($sId) {
148 148
                 return $aOptions['renderer'] === $sId;
149 149
             });
150
-            foreach($aNamespaces as $sName => $aOptions)
150
+            foreach ($aNamespaces as $sName => $aOptions)
151 151
             {
152 152
                 $xRenderer->addNamespace($sName, $aOptions['directory'], $aOptions['extension']);
153 153
             }
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
      */
181 181
     public function getNamespaceRenderer(string $sNamespace): ?ViewInterface
182 182
     {
183
-        if(!isset($this->aNamespaces[$sNamespace]))
183
+        if (!isset($this->aNamespaces[$sNamespace]))
184 184
         {
185 185
             return null;
186 186
         }
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      */
206 206
     protected function store(): Store
207 207
     {
208
-        if(!$this->xStore)
208
+        if (!$this->xStore)
209 209
         {
210 210
             $this->xStore = new Store();
211 211
         }
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
      */
250 250
     public function shareValues(array $aValues): ViewRenderer
251 251
     {
252
-        foreach($aValues as $sName => $xValue)
252
+        foreach ($aValues as $sName => $xValue)
253 253
         {
254 254
             $this->share($sName, $xValue);
255 255
         }
@@ -273,14 +273,14 @@  discard block
 block discarded – undo
273 273
         $sNamespace = $this->sDefaultNamespace;
274 274
         // Get the namespace from the view name
275 275
         $nSeparatorPosition = strrpos($sViewName, '::');
276
-        if($nSeparatorPosition !== false)
276
+        if ($nSeparatorPosition !== false)
277 277
         {
278 278
             $sNamespace = substr($sViewName, 0, $nSeparatorPosition);
279 279
             $sViewName = substr($sViewName, $nSeparatorPosition + 2);
280 280
         }
281 281
 
282 282
         $xRenderer = $this->getNamespaceRenderer($sNamespace);
283
-        if(!$xRenderer)
283
+        if (!$xRenderer)
284 284
         {
285 285
             // Cannot render a view if there's no renderer corresponding to the namespace.
286 286
             return $this->xEmptyStore;
Please login to merge, or discard this patch.
jaxon-core/src/App/PageDatabagTrait.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,8 +37,7 @@
 block discarded – undo
37 37
     private function getPageNumber(int $pageNumber): int
38 38
     {
39 39
         // If no page number is provided, then get the value from the databag.
40
-        return $pageNumber > 0 ? $pageNumber :
41
-            (int)$this->bag($this->bagName())->get($this->bagAttr(), 1);
40
+        return $pageNumber > 0 ? $pageNumber : (int)$this->bag($this->bagName())->get($this->bagAttr(), 1);
42 41
     }
43 42
 
44 43
     /**
Please login to merge, or discard this patch.
jaxon-core/src/Request/Handler/Psr/PsrAjaxMiddleware.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
         // and the other classes will get this request from there.
65 65
         $this->di->val(ServerRequestInterface::class, $request);
66 66
 
67
-        if(!$this->xRequestHandler->canProcessRequest())
67
+        if (!$this->xRequestHandler->canProcessRequest())
68 68
         {
69 69
             // Unable to find a plugin to process the request
70 70
             return $handler->handle($request);
Please login to merge, or discard this patch.
jaxon-core/src/Request/Handler/Psr/PsrRequestHandler.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@
 block discarded – undo
72 72
         // and the other classes will get this request from there.
73 73
         $this->di->val(ServerRequestInterface::class, $request);
74 74
 
75
-        if(!$this->xRequestHandler->canProcessRequest())
75
+        if (!$this->xRequestHandler->canProcessRequest())
76 76
         {
77 77
             // Unable to find a plugin to process the request
78 78
             throw new RequestException($this->xTranslator->trans('errors.request.plugin'));
Please login to merge, or discard this patch.
jaxon-core/src/Request/Handler/CallbackManager.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      */
99 99
     public function popBootCallbacks(): array
100 100
     {
101
-        if(empty($this->aBootCallbacks))
101
+        if (empty($this->aBootCallbacks))
102 102
         {
103 103
             return [];
104 104
         }
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
     private function getExceptionCallbacks(Exception $xException): array
118 118
     {
119 119
         $aExceptionCallbacks = [];
120
-        foreach($this->aExceptionCallbacks as $sExClass => $aCallbacks)
120
+        foreach ($this->aExceptionCallbacks as $sExClass => $aCallbacks)
121 121
         {
122
-            if(is_a($xException, $sExClass))
122
+            if (is_a($xException, $sExClass))
123 123
             {
124 124
                 $aExceptionCallbacks = array_merge($aExceptionCallbacks, $aCallbacks);
125 125
             }
@@ -189,13 +189,13 @@  discard block
 block discarded – undo
189 189
      */
190 190
     public function error(callable $xCallable, string $sExClass = ''): CallbackManager
191 191
     {
192
-        if($sExClass === '' || $sExClass === Exception::class)
192
+        if ($sExClass === '' || $sExClass === Exception::class)
193 193
         {
194 194
             $this->aErrorCallbacks[] = $xCallable;
195 195
             return $this;
196 196
         }
197 197
         // Callback for a given exception class
198
-        if(isset($this->aExceptionCallbacks[$sExClass]))
198
+        if (isset($this->aExceptionCallbacks[$sExClass]))
199 199
         {
200 200
             $this->aExceptionCallbacks[$sExClass][] = $xCallable;
201 201
             return $this;
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
      */
237 237
     private function executeCallbacks(array $aCallbacks, array $aParameters): void
238 238
     {
239
-        foreach($aCallbacks as $xCallback)
239
+        foreach ($aCallbacks as $xCallback)
240 240
         {
241 241
             $this->executeCallback($xCallback, $aParameters);
242 242
         }
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
     public function onBefore(Target $xTarget, bool &$bEndRequest): void
267 267
     {
268 268
         // Call the user defined callback
269
-        foreach($this->aBeforeCallbacks as $xCallback)
269
+        foreach ($this->aBeforeCallbacks as $xCallback)
270 270
         {
271 271
             $this->executeCallback($xCallback, [$xTarget, &$bEndRequest]);
272
-            if($bEndRequest)
272
+            if ($bEndRequest)
273 273
             {
274 274
                 return;
275 275
             }
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
     {
317 317
         $aExceptionCallbacks = $this->getExceptionCallbacks($xException);
318 318
         $this->executeCallbacks($aExceptionCallbacks, [$xException]);
319
-        if(count($aExceptionCallbacks) > 0)
319
+        if (count($aExceptionCallbacks) > 0)
320 320
         {
321 321
             // Do not throw the exception if a custom handler is defined
322 322
             return;
Please login to merge, or discard this patch.
jaxon-core/src/Request/Handler/RequestHandler.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     public function canProcessRequest(): bool
62 62
     {
63 63
         // Return true if the request plugin was already found
64
-        if($this->xRequestPlugin !== null)
64
+        if ($this->xRequestPlugin !== null)
65 65
         {
66 66
             return true;
67 67
         }
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
         $xRequest = $this->di->getRequest();
71 71
 
72 72
         // Find a plugin to process the request
73
-        foreach($this->xPluginManager->getRequestHandlers() as $sClassName)
73
+        foreach ($this->xPluginManager->getRequestHandlers() as $sClassName)
74 74
         {
75
-            if($sClassName::canProcessRequest($xRequest))
75
+            if ($sClassName::canProcessRequest($xRequest))
76 76
             {
77 77
                 $this->xRequestPlugin = $this->di->g($sClassName);
78 78
                 $xTarget = $this->xRequestPlugin->setTarget($xRequest);
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     private function _processRequest(): void
93 93
     {
94 94
         // Process the request
95
-        if($this->xRequestPlugin !== null)
95
+        if ($this->xRequestPlugin !== null)
96 96
         {
97 97
             $this->xRequestPlugin->processRequest();
98 98
             // Process the databag
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     public function processRequest(): void
110 110
     {
111 111
         // Check if there is a plugin to process this request
112
-        if(!$this->canProcessRequest())
112
+        if (!$this->canProcessRequest())
113 113
         {
114 114
             return;
115 115
         }
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
         {
119 119
             $bEndRequest = false;
120 120
             // Handle before processing event
121
-            if($this->xRequestPlugin !== null)
121
+            if ($this->xRequestPlugin !== null)
122 122
             {
123 123
                 $this->xCallbackManager->onBefore($this->xRequestPlugin->getTarget(), $bEndRequest);
124 124
             }
125
-            if($bEndRequest)
125
+            if ($bEndRequest)
126 126
             {
127 127
                 return;
128 128
             }
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
             $this->_processRequest();
131 131
 
132 132
             // Handle after processing event
133
-            if($this->xRequestPlugin !== null)
133
+            if ($this->xRequestPlugin !== null)
134 134
             {
135 135
                 $this->xCallbackManager->onAfter($this->xRequestPlugin->getTarget(), $bEndRequest);
136 136
             }
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
         // An exception was thrown while processing the request.
139 139
         // The request missed the corresponding handler function,
140 140
         // or an error occurred while attempting to execute the handler.
141
-        catch(RequestException $e)
141
+        catch (RequestException $e)
142 142
         {
143 143
             $this->xResponseManager->error($e->getMessage());
144 144
             $this->xCallbackManager->onInvalid($e);
145 145
         }
146
-        catch(Exception $e)
146
+        catch (Exception $e)
147 147
         {
148 148
             $this->xResponseManager->error($e->getMessage());
149 149
             $this->xCallbackManager->onError($e);
Please login to merge, or discard this patch.