Passed
Push — main ( 7c5fe7...238af9 )
by Thierry
16:11
created
jaxon-core/src/Plugin/Request/CallableClass/CallableClassPlugin.php 1 patch
Spacing   +15 added lines, -17 removed lines patch added patch discarded remove patch
@@ -82,15 +82,15 @@  discard block
 block discarded – undo
82 82
      */
83 83
     public function checkOptions(string $sCallable, $xOptions): array
84 84
     {
85
-        if(!$this->xValidator->validateClass(trim($sCallable)))
85
+        if (!$this->xValidator->validateClass(trim($sCallable)))
86 86
         {
87 87
             throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration'));
88 88
         }
89
-        if(is_string($xOptions))
89
+        if (is_string($xOptions))
90 90
         {
91 91
             $xOptions = ['include' => $xOptions];
92 92
         }
93
-        elseif(!is_array($xOptions))
93
+        elseif (!is_array($xOptions))
94 94
         {
95 95
             throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration'));
96 96
         }
@@ -134,15 +134,15 @@  discard block
 block discarded – undo
134 134
      */
135 135
     private function addCallable(CallableObject $xCallableObject): void
136 136
     {
137
-        if($xCallableObject->excluded())
137
+        if ($xCallableObject->excluded())
138 138
         {
139 139
             return;
140 140
         }
141 141
 
142 142
         $aCallableObject = &$this->aCallableObjects;
143
-        foreach(explode('.', $xCallableObject->getJsName()) as $sName)
143
+        foreach (explode('.', $xCallableObject->getJsName()) as $sName)
144 144
         {
145
-            if(!isset($aCallableObject['children'][$sName]))
145
+            if (!isset($aCallableObject['children'][$sName]))
146 146
             {
147 147
                 $aCallableObject['children'][$sName] = [];
148 148
             }
@@ -160,12 +160,11 @@  discard block
 block discarded – undo
160 160
     private function renderMethod(string $sIndent, array $aTemplateVars): string
161 161
     {
162 162
         $aOptions = [];
163
-        foreach($aTemplateVars['aMethod']['options'] as $sKey => $sValue)
163
+        foreach ($aTemplateVars['aMethod']['options'] as $sKey => $sValue)
164 164
         {
165 165
             $aOptions[] = "$sKey: $sValue";
166 166
         }
167
-        $aTemplateVars['sArguments'] = count($aOptions) === 0 ? 'args' :
168
-            'args, { ' . implode(',', $aOptions) . ' }';
167
+        $aTemplateVars['sArguments'] = count($aOptions) === 0 ? 'args' : 'args, { ' . implode(',', $aOptions) . ' }';
169 168
 
170 169
         return $sIndent . trim($this->xTemplateEngine
171 170
             ->render('jaxon::callables/method.js', $aTemplateVars));
@@ -185,11 +184,10 @@  discard block
 block discarded – undo
185 184
 
186 185
         $fMethodCallback = fn($aMethod) => $this->renderMethod($sIndent,
187 186
             ['sJsClass' => $sJsClass, 'aMethod' => $aMethod]);
188
-        $aMethods = !isset($aCallable['methods']) ? [] :
189
-            array_map($fMethodCallback, $aCallable['methods']);
187
+        $aMethods = !isset($aCallable['methods']) ? [] : array_map($fMethodCallback, $aCallable['methods']);
190 188
 
191 189
         $aChildren = [];
192
-        foreach($aCallable['children'] ?? [] as $sName => $aChild)
190
+        foreach ($aCallable['children'] ?? [] as $sName => $aChild)
193 191
         {
194 192
             $aChildren[] = $this->renderChild("$sName:", "$sJsClass.$sName",
195 193
                 $aChild, $nRepeat) . ',';
@@ -230,13 +228,13 @@  discard block
 block discarded – undo
230 228
         $this->xRegistry->registerAllComponents();
231 229
 
232 230
         $this->aCallableObjects = ['children' => []];
233
-        foreach($this->cdi->getCallableObjects() as $xCallableObject)
231
+        foreach ($this->cdi->getCallableObjects() as $xCallableObject)
234 232
         {
235 233
             $this->addCallable($xCallableObject);
236 234
         }
237 235
 
238 236
         $aScripts = [];
239
-        foreach($this->aCallableObjects['children'] as $sJsClass => $aCallable)
237
+        foreach ($this->aCallableObjects['children'] as $sJsClass => $aCallable)
240 238
         {
241 239
             $aScripts[] = $this->renderChild("{$this->sPrefix}$sJsClass =",
242 240
                 $sJsClass, $aCallable) . ';';
@@ -292,7 +290,7 @@  discard block
 block discarded – undo
292 290
         // Will be used to print a translated error message.
293 291
         $aErrorParams = ['class' => $sClassName, 'method' => $sMethodName];
294 292
 
295
-        if(!$this->xValidator->validateJsObject($sClassName) ||
293
+        if (!$this->xValidator->validateJsObject($sClassName) ||
296 294
             !$this->xValidator->validateMethod($sMethodName))
297 295
         {
298 296
             // Unable to find the requested object or method
@@ -306,7 +304,7 @@  discard block
 block discarded – undo
306 304
             /** @var CallableObject */
307 305
             $xCallableObject = $this->getCallable($sClassName);
308 306
 
309
-            if($xCallableObject->excluded($sMethodName))
307
+            if ($xCallableObject->excluded($sMethodName))
310 308
             {
311 309
                 // Unable to find the requested class or method
312 310
                 $this->throwException('', 'errors.objects.excluded', $aErrorParams);
@@ -315,7 +313,7 @@  discard block
 block discarded – undo
315 313
             $sError = 'errors.objects.call';
316 314
             $xCallableObject->call($this->xTarget);
317 315
         }
318
-        catch(ReflectionException|SetupException $e)
316
+        catch (ReflectionException|SetupException $e)
319 317
         {
320 318
             // Unable to execute the requested class or method
321 319
             $this->throwException($e->getMessage(), $sError, $aErrorParams);
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Request/CallableFunction/CallableFunctionPlugin.php 1 patch
Spacing   +13 added lines, -15 removed lines patch added patch discarded remove patch
@@ -86,15 +86,15 @@  discard block
 block discarded – undo
86 86
      */
87 87
     public function checkOptions(string $sCallable, $xOptions): array
88 88
     {
89
-        if(!$this->xValidator->validateFunction(trim($sCallable)))
89
+        if (!$this->xValidator->validateFunction(trim($sCallable)))
90 90
         {
91 91
             throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration'));
92 92
         }
93
-        if(is_string($xOptions))
93
+        if (is_string($xOptions))
94 94
         {
95 95
             $xOptions = ['include' => $xOptions];
96 96
         }
97
-        elseif(!is_array($xOptions))
97
+        elseif (!is_array($xOptions))
98 98
         {
99 99
             throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration'));
100 100
         }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
         $sPhpFunction = trim($sCallable);
116 116
         $sFunction = $sPhpFunction;
117 117
         // Check if an alias is defined
118
-        if(isset($aOptions['alias']))
118
+        if (isset($aOptions['alias']))
119 119
         {
120 120
             $sFunction = (string)$aOptions['alias'];
121 121
             unset($aOptions['alias']);
@@ -139,13 +139,13 @@  discard block
 block discarded – undo
139 139
     public function getCallable(string $sCallable): CallableFunction|null
140 140
     {
141 141
         $sFunction = trim($sCallable);
142
-        if(!isset($this->aFunctions[$sFunction]))
142
+        if (!isset($this->aFunctions[$sFunction]))
143 143
         {
144 144
             return null;
145 145
         }
146 146
         $xCallable = new CallableFunction($this->di, $sFunction,
147 147
             $this->sPrefix . $sFunction, $this->aFunctions[$sFunction]);
148
-        foreach($this->aOptions[$sFunction] as $sName => $sValue)
148
+        foreach ($this->aOptions[$sFunction] as $sName => $sValue)
149 149
         {
150 150
             $xCallable->configure($sName, $sValue);
151 151
         }
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
     private function getCallableScript(CallableFunction $xFunction): string
163 163
     {
164 164
         $aOptions = [];
165
-        foreach($xFunction->getOptions() as $sKey => $sValue)
165
+        foreach ($xFunction->getOptions() as $sKey => $sValue)
166 166
         {
167 167
             $aOptions[] = "$sKey: $sValue";
168 168
         }
@@ -170,8 +170,7 @@  discard block
 block discarded – undo
170 170
         return $this->xTemplateEngine->render('jaxon::callables/function.js', [
171 171
             'sName' => $xFunction->getName(),
172 172
             'sJsName' => $xFunction->getJsName(),
173
-            'sArguments' => count($aOptions) === 0 ? 'args' :
174
-                'args, { ' . implode(',', $aOptions) . ' }',
173
+            'sArguments' => count($aOptions) === 0 ? 'args' : 'args, { ' . implode(',', $aOptions) . ' }',
175 174
         ]);
176 175
     }
177 176
 
@@ -181,7 +180,7 @@  discard block
 block discarded – undo
181 180
     public function getScript(): string
182 181
     {
183 182
         $code = '';
184
-        foreach(array_keys($this->aFunctions) as $sFunction)
183
+        foreach (array_keys($this->aFunctions) as $sFunction)
185 184
         {
186 185
             $xFunction = $this->getCallable($sFunction);
187 186
             $code .= $this->getCallableScript($xFunction);
@@ -219,8 +218,7 @@  discard block
 block discarded – undo
219 218
     private function throwException(Exception $xException, string $sErrorMessage): void
220 219
     {
221 220
         $this->di->getLogger()->error($xException->getMessage());
222
-        throw new RequestException($sErrorMessage . (!$this->bDebug ? '' :
223
-            "\n" . $xException->getMessage()));
221
+        throw new RequestException($sErrorMessage . (!$this->bDebug ? '' : "\n" . $xException->getMessage()));
224 222
     }
225 223
 
226 224
     /**
@@ -232,7 +230,7 @@  discard block
 block discarded – undo
232 230
         $sRequestedFunction = $this->xTarget->getFunctionName();
233 231
 
234 232
         // Security check: make sure the requested function was registered.
235
-        if(!$this->xValidator->validateFunction($sRequestedFunction) ||
233
+        if (!$this->xValidator->validateFunction($sRequestedFunction) ||
236 234
             !isset($this->aFunctions[$sRequestedFunction]))
237 235
         {
238 236
             // Unable to find the requested function
@@ -245,7 +243,7 @@  discard block
 block discarded – undo
245 243
             /** @var CallableFunction */
246 244
             $xFunction = $this->getCallable($sRequestedFunction);
247 245
         }
248
-        catch(Exception $e)
246
+        catch (Exception $e)
249 247
         {
250 248
             // Unable to find the requested function
251 249
             $this->throwException($e, $this->xTranslator->trans('errors.functions.invalid',
@@ -255,7 +253,7 @@  discard block
 block discarded – undo
255 253
         {
256 254
             $xFunction->call($this->xTarget->args());
257 255
         }
258
-        catch(Exception $e)
256
+        catch (Exception $e)
259 257
         {
260 258
             // Unable to execute the requested function
261 259
             $this->throwException($e, $this->xTranslator->trans('errors.functions.call',
Please login to merge, or discard this patch.
jaxon-core/templates/plugins/config.js.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -10,20 +10,20 @@
 block discarded – undo
10 10
 jxn.config.defaultMethod = "<?php echo $this->sDefaultMethod ?>";
11 11
 jxn.config.responseType = "<?php echo $this->sResponseType ?>";
12 12
 
13
-<?php if($this->nResponseQueueSize > 0): ?>
13
+<?php if ($this->nResponseQueueSize > 0): ?>
14 14
 jxn.config.responseQueueSize = <?php echo $this->nResponseQueueSize ?>;
15 15
 <?php endif ?>
16 16
 
17
-<?php if(($this->bDebug)): ?>
17
+<?php if (($this->bDebug)): ?>
18 18
 jxn.debug.active = true;
19
-<?php if(($this->sDebugOutputID)): ?>
19
+<?php if (($this->sDebugOutputID)): ?>
20 20
 jxn.debug.outputID = "<?php echo $this->sDebugOutputID ?>";
21 21
 <?php endif ?>
22
-<?php if(($this->bVerboseDebug)): ?>
22
+<?php if (($this->bVerboseDebug)): ?>
23 23
 jxn.debug.verbose.active = true;
24 24
 <?php endif ?>
25 25
 <?php endif ?>
26 26
 
27
-<?php if(($this->sCsrfMetaName)): ?>
27
+<?php if (($this->sCsrfMetaName)): ?>
28 28
 jxn.setCsrf('<?php echo $this->sCsrfMetaName ?>');
29 29
 <?php endif ?>
Please login to merge, or discard this patch.