Passed
Push — main ( 7f530d...7aae9b )
by Thierry
05:54
created
jaxon-core/src/Plugin/Request/CallableClass/CallableClassPlugin.php 1 patch
Spacing   +13 added lines, -14 removed lines patch added patch discarded remove patch
@@ -81,15 +81,15 @@  discard block
 block discarded – undo
81 81
      */
82 82
     public function checkOptions(string $sCallable, $xOptions): array
83 83
     {
84
-        if(!$this->xValidator->validateClass(trim($sCallable)))
84
+        if (!$this->xValidator->validateClass(trim($sCallable)))
85 85
         {
86 86
             throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration'));
87 87
         }
88
-        if(is_string($xOptions))
88
+        if (is_string($xOptions))
89 89
         {
90 90
             $xOptions = ['include' => $xOptions];
91 91
         }
92
-        elseif(!is_array($xOptions))
92
+        elseif (!is_array($xOptions))
93 93
         {
94 94
             throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration'));
95 95
         }
@@ -133,15 +133,15 @@  discard block
 block discarded – undo
133 133
      */
134 134
     private function addCallable(CallableObject $xCallableObject): void
135 135
     {
136
-        if($xCallableObject->excluded())
136
+        if ($xCallableObject->excluded())
137 137
         {
138 138
             return;
139 139
         }
140 140
 
141 141
         $aCallableObject = &$this->aCallableObjects;
142
-        foreach(explode('.', $xCallableObject->getJsName()) as $sName)
142
+        foreach (explode('.', $xCallableObject->getJsName()) as $sName)
143 143
         {
144
-            if(!isset($aCallableObject['children'][$sName]))
144
+            if (!isset($aCallableObject['children'][$sName]))
145 145
             {
146 146
                 $aCallableObject['children'][$sName] = [];
147 147
             }
@@ -176,11 +176,10 @@  discard block
 block discarded – undo
176 176
 
177 177
         $fMethodCallback = fn($aMethod) => $this->renderMethod($sIndent,
178 178
             ['sJsClass' => $sJsClass, 'aMethod' => $aMethod]);
179
-        $aMethods = !isset($aCallable['methods']) ? [] :
180
-            array_map($fMethodCallback, $aCallable['methods']);
179
+        $aMethods = !isset($aCallable['methods']) ? [] : array_map($fMethodCallback, $aCallable['methods']);
181 180
 
182 181
         $aChildren = [];
183
-        foreach($aCallable['children'] ?? [] as $sName => $aChild)
182
+        foreach ($aCallable['children'] ?? [] as $sName => $aChild)
184 183
         {
185 184
             $aChildren[] = $this->renderChild("$sName:", "$sJsClass.$sName",
186 185
                 $aChild, $nRepeat) . ',';
@@ -221,13 +220,13 @@  discard block
 block discarded – undo
221 220
         $this->xRegistry->registerAllComponents();
222 221
 
223 222
         $this->aCallableObjects = ['children' => []];
224
-        foreach($this->cdi->getCallableObjects() as $xCallableObject)
223
+        foreach ($this->cdi->getCallableObjects() as $xCallableObject)
225 224
         {
226 225
             $this->addCallable($xCallableObject);
227 226
         }
228 227
 
229 228
         $aScripts = [];
230
-        foreach($this->aCallableObjects['children'] as $sJsClass => $aCallable)
229
+        foreach ($this->aCallableObjects['children'] as $sJsClass => $aCallable)
231 230
         {
232 231
             $aScripts[] = $this->renderChild("{$this->sPrefix}$sJsClass =",
233 232
                 $sJsClass, $aCallable) . ';';
@@ -283,7 +282,7 @@  discard block
 block discarded – undo
283 282
         // Will be used to print a translated error message.
284 283
         $aErrorParams = ['class' => $sClassName, 'method' => $sMethodName];
285 284
 
286
-        if(!$this->xValidator->validateJsObject($sClassName) ||
285
+        if (!$this->xValidator->validateJsObject($sClassName) ||
287 286
             !$this->xValidator->validateMethod($sMethodName))
288 287
         {
289 288
             // Unable to find the requested object or method
@@ -297,7 +296,7 @@  discard block
 block discarded – undo
297 296
             /** @var CallableObject */
298 297
             $xCallableObject = $this->getCallable($sClassName);
299 298
 
300
-            if($xCallableObject->excluded($sMethodName))
299
+            if ($xCallableObject->excluded($sMethodName))
301 300
             {
302 301
                 // Unable to find the requested class or method
303 302
                 $this->throwException('', 'errors.objects.excluded', $aErrorParams);
@@ -306,7 +305,7 @@  discard block
 block discarded – undo
306 305
             $sError = 'errors.objects.call';
307 306
             $xCallableObject->call($this->xTarget);
308 307
         }
309
-        catch(ReflectionException|SetupException $e)
308
+        catch (ReflectionException|SetupException $e)
310 309
         {
311 310
             // Unable to execute the requested class or method
312 311
             $this->throwException($e->getMessage(), $sError, $aErrorParams);
Please login to merge, or discard this patch.
jaxon-core/templates/callables/method.js.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1 1
 <?php echo $this->aMethod['name'] ?>: function() { return jaxon.request({ type: 'class', name: '<?php
2 2
     echo $this->sJsClass ?>', method: '<?php echo $this->aMethod['name']
3
-    ?>' }, { parameters: arguments<?php foreach($this->aMethod['options'] as $sKey => $sValue):
3
+    ?>' }, { parameters: arguments<?php foreach ($this->aMethod['options'] as $sKey => $sValue):
4 4
         ?>, <?php echo $sKey ?>: <?php echo $sValue ?><?php endforeach ?> }); },
Please login to merge, or discard this patch.
jaxon-core/templates/callables/function.js.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1 1
 <?php echo $this->sJsName ?> = function() { return jaxon.request({ type: 'func', name: '<?php
2 2
     echo $this->sName ?>' }, { parameters: arguments<?php
3
-    foreach($this->aOptions as $sKey => $sValue): ?>, <?php
3
+    foreach ($this->aOptions as $sKey => $sValue): ?>, <?php
4 4
         echo $sKey ?>: <?php echo $sValue ?><?php endforeach ?> }); };
Please login to merge, or discard this patch.
jaxon-core/src/App/Databag/Databag.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@
 block discarded – undo
90 90
     public function new(string $sBag, string $sKey, $xValue): void
91 91
     {
92 92
         // Set the value only if it doesn't already exist.
93
-        if(!isset($this->aData[$sBag]) || !key_exists($sKey, $this->aData[$sBag]))
93
+        if (!isset($this->aData[$sBag]) || !key_exists($sKey, $this->aData[$sBag]))
94 94
         {
95 95
             $this->set($sBag, $sKey, $xValue);
96 96
         }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Response/Databag/DatabagPlugin.php 1 patch
Spacing   +4 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      */
35 35
     private function initDatabag(): void
36 36
     {
37
-        if($this->xDatabag !== null)
37
+        if ($this->xDatabag !== null)
38 38
         {
39 39
             return;
40 40
         }
@@ -44,8 +44,7 @@  discard block
 block discarded – undo
44 44
         $aBody = $xRequest->getParsedBody();
45 45
         $aParams = $xRequest->getQueryParams();
46 46
         $aData = is_array($aBody) ?
47
-            $this->readData($aBody['jxnbags'] ?? []) :
48
-            $this->readData($aParams['jxnbags'] ?? []);
47
+            $this->readData($aBody['jxnbags'] ?? []) : $this->readData($aParams['jxnbags'] ?? []);
49 48
         $this->xDatabag = new Databag($this, $aData);
50 49
     }
51 50
 
@@ -67,8 +66,7 @@  discard block
 block discarded – undo
67 66
         // Todo: clean input data.
68 67
         // Todo: verify the checksums.
69 68
         return is_string($xData) ?
70
-            (json_decode($xData, true) ?: []) :
71
-            (is_array($xData) ? $xData : []);
69
+            (json_decode($xData, true) ?: []) : (is_array($xData) ? $xData : []);
72 70
     }
73 71
 
74 72
     /**
@@ -86,7 +84,7 @@  discard block
 block discarded – undo
86 84
     public function writeCommand(): void
87 85
     {
88 86
         $this->initDatabag();
89
-        if($this->xDatabag->touched())
87
+        if ($this->xDatabag->touched())
90 88
         {
91 89
             // Todo: calculate the checksums.
92 90
             $this->addCommand('databag.set', ['values' => $this->xDatabag]);
Please login to merge, or discard this patch.
jaxon-attributes/src/Attribute/Databag.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 use Jaxon\App\Metadata\Metadata;
19 19
 use Attribute;
20 20
 
21
-#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
21
+#[Attribute(Attribute::TARGET_CLASS|Attribute::TARGET_METHOD|Attribute::IS_REPEATABLE)]
22 22
 class Databag extends AbstractAttribute
23 23
 {
24 24
     /**
Please login to merge, or discard this patch.
jaxon-annotations/src/Annotation/DatabagAnnotation.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
      */
51 51
     public function initAnnotation(array $properties)
52 52
     {
53
-        if(count($properties) !== 1 || !isset($properties['name']) || !is_string($properties['name']))
53
+        if (count($properties) !== 1 || !isset($properties['name']) || !is_string($properties['name']))
54 54
         {
55 55
             throw new AnnotationException('The @databag annotation requires a property "name" of type string');
56 56
         }
Please login to merge, or discard this patch.
jaxon-core/src/App/Metadata/Data/HookData.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
      */
56 56
     public function addCall(string $sMethod, array $aParams): void
57 57
     {
58
-        if(!$this->validateMethod($sMethod))
58
+        if (!$this->validateMethod($sMethod))
59 59
         {
60 60
             $sType = $this->getType();
61 61
             throw new SetupException("'$sMethod' is not a valid \"call\" value for $sType.");
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
     public function encode(string $sVarName): array
70 70
     {
71 71
         $aCalls = [];
72
-        foreach($this->aCalls as $sMethod => $aParams)
72
+        foreach ($this->aCalls as $sMethod => $aParams)
73 73
         {
74 74
             $sParams = addslashes(json_encode($aParams));
75 75
             $aCalls[] = "{$sVarName}->addCall('$sMethod', json_decode(\"$sParams\", true));";
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Request/CallableClass/CallableObject.php 1 patch
Spacing   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -73,8 +73,7 @@  discard block
 block discarded – undo
73 73
      */
74 74
     public function excluded(?string $sMethodName = null): bool
75 75
     {
76
-        return $sMethodName === null ? $this->xOptions->excluded() :
77
-            !$this->xOptions->isPublicMethod($sMethodName);
76
+        return $sMethodName === null ? $this->xOptions->excluded() : !$this->xOptions->isPublicMethod($sMethodName);
78 77
     }
79 78
 
80 79
     /**
@@ -160,11 +159,11 @@  discard block
 block discarded – undo
160 159
         $sMethod = $this->xTarget->getMethodName();
161 160
         // The hooks defined at method level are merged with those defined at class level.
162 161
         $aMethods = array_merge($aHookMethods['*'] ?? [], $aHookMethods[$sMethod] ?? []);
163
-        foreach($aMethods as $xKey => $xValue)
162
+        foreach ($aMethods as $xKey => $xValue)
164 163
         {
165 164
             $sHookName = $xValue;
166 165
             $aHookArgs = [];
167
-            if(is_string($xKey))
166
+            if (is_string($xKey))
168 167
             {
169 168
                 $sHookName = $xKey;
170 169
                 $aHookArgs = is_array($xValue) ? $xValue : [$xValue];
@@ -202,7 +201,7 @@  discard block
 block discarded – undo
202 201
             // Warning: dynamic properties will be deprecated in PHP8.2.
203 202
             $this->$sAttr = $xDiValue;
204 203
         };
205
-        foreach($aDiOptions as $sAttr => $sClass)
204
+        foreach ($aDiOptions as $sAttr => $sClass)
206 205
         {
207 206
             $this->setDiAttribute($xComponent, $sAttr, $this->di->get($sClass), $cSetter);
208 207
         }
Please login to merge, or discard this patch.