Passed
Push — main ( d93426...8fe145 )
by Thierry
05:54
created
jaxon-core/templates/callables/objects.js.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
   rc: (name, method, parameters, options = {}) => jaxon.request({ type: 'class', name, method }, { parameters, ...options}),
3 3
   rf: (name, parameters, options = {}) => jaxon.request({ type: 'func', name }, { parameters, ...options}),
4 4
 <?php
5
-foreach($this->aCallableParams as $sName => $nIndex):
5
+foreach ($this->aCallableParams as $sName => $nIndex):
6 6
   echo "  c$nIndex: '$sName',\n";
7 7
 endforeach
8 8
 ?>
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Request/CallableClass/CallableClassPlugin.php 1 patch
Spacing   +16 added lines, -18 removed lines patch added patch discarded remove patch
@@ -87,15 +87,15 @@  discard block
 block discarded – undo
87 87
      */
88 88
     public function checkOptions(string $sCallable, $xOptions): array
89 89
     {
90
-        if(!$this->xValidator->validateClass(trim($sCallable)))
90
+        if (!$this->xValidator->validateClass(trim($sCallable)))
91 91
         {
92 92
             throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration'));
93 93
         }
94
-        if(is_string($xOptions))
94
+        if (is_string($xOptions))
95 95
         {
96 96
             $xOptions = ['include' => $xOptions];
97 97
         }
98
-        elseif(!is_array($xOptions))
98
+        elseif (!is_array($xOptions))
99 99
         {
100 100
             throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration'));
101 101
         }
@@ -140,16 +140,16 @@  discard block
 block discarded – undo
140 140
     private function addCallable(CallableObject $xCallableObject): void
141 141
     {
142 142
         $aCallableMethods = $xCallableObject->getCallableMethods();
143
-        if($xCallableObject->excluded() || count($aCallableMethods) === 0)
143
+        if ($xCallableObject->excluded() || count($aCallableMethods) === 0)
144 144
         {
145 145
             return;
146 146
         }
147 147
 
148 148
         $aCallableObject = &$this->aCallableObjects;
149 149
         $sJsName = $xCallableObject->getJsName();
150
-        foreach(explode('.', $sJsName) as $sName)
150
+        foreach (explode('.', $sJsName) as $sName)
151 151
         {
152
-            if(!isset($aCallableObject['children'][$sName]))
152
+            if (!isset($aCallableObject['children'][$sName]))
153 153
             {
154 154
                 $aCallableObject['children'][$sName] = [];
155 155
             }
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
         $aCallableObject['param'] = $sJsParam;
163 163
 
164 164
         // Add the js param to the list, if it is not already in.
165
-        if(isset($this->aCallableParams[$sJsParam]))
165
+        if (isset($this->aCallableParams[$sJsParam]))
166 166
         {
167 167
             $aCallableObject['index'] = $this->aCallableParams[$sJsParam];
168 168
             return;
@@ -182,12 +182,11 @@  discard block
 block discarded – undo
182 182
     private function renderMethod(string $sIndent, array $aTemplateVars): string
183 183
     {
184 184
         $aOptions = [];
185
-        foreach($aTemplateVars['aMethod']['options'] as $sKey => $sValue)
185
+        foreach ($aTemplateVars['aMethod']['options'] as $sKey => $sValue)
186 186
         {
187 187
             $aOptions[] = "$sKey: $sValue";
188 188
         }
189
-        $aTemplateVars['sArguments'] = count($aOptions) === 0 ? 'args' :
190
-            'args, { ' . implode(', ', $aOptions) . ' }';
189
+        $aTemplateVars['sArguments'] = count($aOptions) === 0 ? 'args' : 'args, { ' . implode(', ', $aOptions) . ' }';
191 190
 
192 191
         return $sIndent . trim($this->xTemplateEngine
193 192
             ->render('jaxon::callables/method.js', $aTemplateVars));
@@ -209,11 +208,10 @@  discard block
 block discarded – undo
209 208
             'aMethod' => $aMethod,
210 209
             'nIndex' => $aCallable['index'] ?? 0,
211 210
         ]);
212
-        $aMethods = !isset($aCallable['methods']) ? [] :
213
-            array_map($fMethodCallback, $aCallable['methods']);
211
+        $aMethods = !isset($aCallable['methods']) ? [] : array_map($fMethodCallback, $aCallable['methods']);
214 212
 
215 213
         $aChildren = [];
216
-        foreach($aCallable['children'] ?? [] as $sName => $aChild)
214
+        foreach ($aCallable['children'] ?? [] as $sName => $aChild)
217 215
         {
218 216
             $aChildren[] = $this->renderChild("$sName:", "$sJsClass.$sName",
219 217
                 $aChild, $nIndent) . ',';
@@ -255,7 +253,7 @@  discard block
 block discarded – undo
255 253
 
256 254
         $this->aCallableParams = [];
257 255
         $this->aCallableObjects = ['children' => []];
258
-        foreach($this->cdi->getCallableObjects() as $xCallableObject)
256
+        foreach ($this->cdi->getCallableObjects() as $xCallableObject)
259 257
         {
260 258
             $this->addCallable($xCallableObject);
261 259
         }
@@ -265,7 +263,7 @@  discard block
 block discarded – undo
265 263
                 'aCallableParams' => $this->aCallableParams,
266 264
             ])
267 265
         ];
268
-        foreach($this->aCallableObjects['children'] as $sJsClass => $aCallable)
266
+        foreach ($this->aCallableObjects['children'] as $sJsClass => $aCallable)
269 267
         {
270 268
             $aScripts[] = $this->renderChild("{$this->sPrefix}$sJsClass =",
271 269
                 $sJsClass, $aCallable) . ';';
@@ -321,7 +319,7 @@  discard block
 block discarded – undo
321 319
         // Will be used to print a translated error message.
322 320
         $aErrorParams = ['class' => $sClassName, 'method' => $sMethodName];
323 321
 
324
-        if(!$this->xValidator->validateJsObject($sClassName) ||
322
+        if (!$this->xValidator->validateJsObject($sClassName) ||
325 323
             !$this->xValidator->validateMethod($sMethodName))
326 324
         {
327 325
             // Unable to find the requested object or method
@@ -335,7 +333,7 @@  discard block
 block discarded – undo
335 333
             /** @var CallableObject */
336 334
             $xCallableObject = $this->getCallable($sClassName);
337 335
 
338
-            if($xCallableObject->excluded($sMethodName))
336
+            if ($xCallableObject->excluded($sMethodName))
339 337
             {
340 338
                 // Unable to find the requested class or method
341 339
                 $this->throwException('', 'errors.objects.excluded', $aErrorParams);
@@ -344,7 +342,7 @@  discard block
 block discarded – undo
344 342
             $sError = 'errors.objects.call';
345 343
             $xCallableObject->call($this->xTarget);
346 344
         }
347
-        catch(ReflectionException|SetupException $e)
345
+        catch (ReflectionException|SetupException $e)
348 346
         {
349 347
             // Unable to execute the requested class or method
350 348
             $this->throwException($e->getMessage(), $sError, $aErrorParams);
Please login to merge, or discard this patch.