Passed
Push — main ( 273db0...683317 )
by Thierry
03:54
created
jaxon-core/src/App/Metadata/Data/ExportData.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -50,11 +50,11 @@
 block discarded – undo
50 50
      */
51 51
     public function setMethods(array $aMethods): void
52 52
     {
53
-        foreach(['base', 'only', 'except'] as $sKey)
53
+        foreach (['base', 'only', 'except'] as $sKey)
54 54
         {
55
-            foreach($aMethods[$sKey] ?? [] as $sMethod)
55
+            foreach ($aMethods[$sKey] ?? [] as $sMethod)
56 56
             {
57
-                if(!is_string($sMethod) || !$this->validateMethod($sMethod))
57
+                if (!is_string($sMethod) || !$this->validateMethod($sMethod))
58 58
                 {
59 59
                     throw new SetupException("'$sMethod' is not a valid method name.");
60 60
                 }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Request/CallableClass/ComponentOptions.php 1 patch
Spacing   +22 added lines, -25 removed lines patch added patch discarded remove patch
@@ -106,18 +106,18 @@  discard block
 block discarded – undo
106 106
         $sSeparator = $aOptions['separator'] ?? '.';
107 107
         $this->sSeparator = $sSeparator === '_' ? '_' : '.';
108 108
         $this->addProtectedMethods($aOptions['protected'] ?? []);
109
-        foreach($aOptions['functions'] ?? [] as $sNames => $aFunctionOptions)
109
+        foreach ($aOptions['functions'] ?? [] as $sNames => $aFunctionOptions)
110 110
         {
111 111
             // Names are in a comma-separated list.
112 112
             $aFunctionNames = explode(',', $sNames);
113
-            foreach($aFunctionNames as $sFunctionName)
113
+            foreach ($aFunctionNames as $sFunctionName)
114 114
             {
115 115
                 $this->addFunctionOptions($sFunctionName, $aFunctionOptions);
116 116
             }
117 117
         }
118 118
 
119 119
         // Options from the attributes or annotations.
120
-        if($xMetadata !== null)
120
+        if ($xMetadata !== null)
121 121
         {
122 122
             $this->readMetadataOptions($xMetadata);
123 123
         }
@@ -133,8 +133,7 @@  discard block
 block discarded – undo
133 133
     private function addProtectedMethods(array|string $xMethods): void
134 134
     {
135 135
         $this->aExportMethods['except'] = array_merge($this->aExportMethods['except'],
136
-            !is_array($xMethods) ? [trim((string)$xMethods)] :
137
-            array_map(fn($sMethod) => trim((string)$sMethod), $xMethods));
136
+            !is_array($xMethods) ? [trim((string)$xMethods)] : array_map(fn($sMethod) => trim((string)$sMethod), $xMethods));
138 137
     }
139 138
 
140 139
     /**
@@ -149,7 +148,7 @@  discard block
 block discarded – undo
149 148
         $aExportMethods['except'] = array_unique(array_merge(
150 149
             $aExportMethods['except'] ?? [], $this->aExportMethods['except']));
151 150
         $this->aExportMethods = $aExportMethods;
152
-        foreach($xMetadata->getProperties() as $sFunctionName => $aFunctionOptions)
151
+        foreach ($xMetadata->getProperties() as $sFunctionName => $aFunctionOptions)
153 152
         {
154 153
             $this->addFunctionOptions($sFunctionName, $aFunctionOptions);
155 154
         }
@@ -162,7 +161,7 @@  discard block
 block discarded – undo
162 161
      */
163 162
     private function filterPublicMethods(array $aMethods): array
164 163
     {
165
-        if($this->bExcluded || in_array('*', $this->aExportMethods['except']))
164
+        if ($this->bExcluded || in_array('*', $this->aExportMethods['except']))
166 165
         {
167 166
             return [];
168 167
         }
@@ -170,12 +169,12 @@  discard block
 block discarded – undo
170 169
         $aBaseMethods = $aMethods[1];
171 170
         $aNoMethods = $aMethods[2];
172 171
         $aMethods = $aMethods[0];
173
-        if(isset($this->aExportMethods['only']))
172
+        if (isset($this->aExportMethods['only']))
174 173
         {
175 174
             $aMethods = array_intersect($aMethods, $this->aExportMethods['only']);
176 175
         }
177 176
         $aMethods = array_diff($aMethods, $this->aExportMethods['except']);
178
-        if(count($aBaseMethods) > 0 && isset($this->aExportMethods['base']))
177
+        if (count($aBaseMethods) > 0 && isset($this->aExportMethods['base']))
179 178
         {
180 179
             $aBaseMethods = array_diff($aBaseMethods, $this->aExportMethods['base']);
181 180
         }
@@ -261,19 +260,19 @@  discard block
 block discarded – undo
261 260
      */
262 261
     private function setHookMethods(array &$aHookMethods, $xValue): void
263 262
     {
264
-        foreach($xValue as $sCalledMethod => $xMethodToCall)
263
+        foreach ($xValue as $sCalledMethod => $xMethodToCall)
265 264
         {
266
-            if(!isset($aHookMethods[$sCalledMethod]))
265
+            if (!isset($aHookMethods[$sCalledMethod]))
267 266
             {
268 267
                 $aHookMethods[$sCalledMethod] = [];
269 268
             }
270
-            if(is_array($xMethodToCall))
269
+            if (is_array($xMethodToCall))
271 270
             {
272 271
                 $aHookMethods[$sCalledMethod] =
273 272
                     array_merge($aHookMethods[$sCalledMethod], $xMethodToCall);
274 273
                 continue;
275 274
             }
276
-            if(is_string($xMethodToCall))
275
+            if (is_string($xMethodToCall))
277 276
             {
278 277
                 $aHookMethods[$sCalledMethod][] = $xMethodToCall;
279 278
             }
@@ -298,7 +297,7 @@  discard block
 block discarded – undo
298 297
      */
299 298
     private function addOption(string $sName, $xValue): void
300 299
     {
301
-        switch($sName)
300
+        switch ($sName)
302 301
         {
303 302
         // Set the methods to call before processing the request
304 303
         case '__before':
@@ -326,11 +325,11 @@  discard block
 block discarded – undo
326 325
      */
327 326
     private function _addJsArrayOption(string $sFunctionName, string $sOptionName, $xOptionValue): void
328 327
     {
329
-        if(is_string($xOptionValue))
328
+        if (is_string($xOptionValue))
330 329
         {
331 330
             $xOptionValue = [$xOptionValue];
332 331
         }
333
-        if(!is_array($xOptionValue))
332
+        if (!is_array($xOptionValue))
334 333
         {
335 334
             return; // Do not save.
336 335
         }
@@ -360,10 +359,10 @@  discard block
 block discarded – undo
360 359
      */
361 360
     private function addJsOption(string $sFunctionName, string $sOptionName, $xOptionValue): void
362 361
     {
363
-        switch($sOptionName)
362
+        switch ($sOptionName)
364 363
         {
365 364
         case 'excluded':
366
-            if((bool)$xOptionValue)
365
+            if ((bool)$xOptionValue)
367 366
             {
368 367
                 $this->addProtectedMethods($sFunctionName);
369 368
             }
@@ -387,12 +386,11 @@  discard block
 block discarded – undo
387 386
      */
388 387
     private function addFunctionOptions(string $sFunctionName, array $aFunctionOptions): void
389 388
     {
390
-        foreach($aFunctionOptions as $sOptionName => $xOptionValue)
389
+        foreach ($aFunctionOptions as $sOptionName => $xOptionValue)
391 390
         {
392 391
             substr($sOptionName, 0, 2) === '__' ?
393 392
                 // Options for PHP classes. They start with "__".
394
-                $this->addOption($sOptionName, [$sFunctionName => $xOptionValue]) :
395
-                // Options for javascript code.
393
+                $this->addOption($sOptionName, [$sFunctionName => $xOptionValue]) : // Options for javascript code.
396 394
                 $this->addJsOption($sFunctionName, $sOptionName, $xOptionValue);
397 395
         }
398 396
     }
@@ -408,16 +406,15 @@  discard block
 block discarded – undo
408 406
         $aOptions = array_merge($this->aJsOptions['*'] ?? []); // Clone the array
409 407
         // Then add the method options.
410 408
         $aMethodOptions = $this->aJsOptions[$sMethodName] ?? [];
411
-        foreach($aMethodOptions as $sOptionName => $xOptionValue)
409
+        foreach ($aMethodOptions as $sOptionName => $xOptionValue)
412 410
         {
413 411
             // For databags and callbacks, merge the values in a single array.
414 412
             // For all the other options, keep the last value.
415 413
             $aOptions[$sOptionName] = !in_array($sOptionName, ['bags', 'callback']) ?
416
-                $xOptionValue :
417
-                array_unique(array_merge($aOptions[$sOptionName] ?? [], $xOptionValue));
414
+                $xOptionValue : array_unique(array_merge($aOptions[$sOptionName] ?? [], $xOptionValue));
418 415
         }
419 416
         // Since callbacks are js object names, they need a special formatting.
420
-        if(isset($aOptions['callback']))
417
+        if (isset($aOptions['callback']))
421 418
         {
422 419
             $aOptions['callback'] = str_replace('"', '', json_encode($aOptions['callback']));
423 420
         }
Please login to merge, or discard this patch.
jaxon-attributes/src/Attribute/Inject.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 
22 22
 use function ltrim;
23 23
 
24
-#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_PROPERTY |
25
-    Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
24
+#[Attribute(Attribute::TARGET_CLASS|Attribute::TARGET_PROPERTY|
25
+    Attribute::TARGET_METHOD|Attribute::IS_REPEATABLE)]
26 26
 class Inject extends AbstractAttribute
27 27
 {
28 28
     /**
@@ -78,17 +78,17 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function validate(): void
80 80
     {
81
-        if($this->nTarget === Attribute::TARGET_CLASS)
81
+        if ($this->nTarget === Attribute::TARGET_CLASS)
82 82
         {
83
-            if(!$this->attr || !$this->type)
83
+            if (!$this->attr || !$this->type)
84 84
             {
85 85
                 throw new SetupException('When applied to a class, the Inject attribute requires two arguments.');
86 86
             }
87 87
             return;
88 88
         }
89
-        if($this->nTarget === Attribute::TARGET_METHOD)
89
+        if ($this->nTarget === Attribute::TARGET_METHOD)
90 90
         {
91
-            if(!$this->attr)
91
+            if (!$this->attr)
92 92
             {
93 93
                 throw new SetupException('When applied to a method, the Inject attribute requires the "attr" argument.');
94 94
             }
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
      */
101 101
     private function getFullClassName(): void
102 102
     {
103
-        if(!$this->type)
103
+        if (!$this->type)
104 104
         {
105 105
             // If no type is provided, take the attribute type.
106 106
             $this->type = $this->aTypes[$this->attr] ?? '';
107 107
             return;
108 108
         }
109
-        if($this->type[0] === '\\')
109
+        if ($this->type[0] === '\\')
110 110
         {
111 111
             $this->type = ltrim($this->type, '\\');
112 112
         }
Please login to merge, or discard this patch.
jaxon-attributes/src/AttributeReader.php 1 patch
Spacing   +19 added lines, -21 removed lines patch added patch discarded remove patch
@@ -82,19 +82,19 @@  discard block
 block discarded – undo
82 82
     private function readTypes(ReflectionClass $xClass)
83 83
     {
84 84
         $sClass = $xClass->getName();
85
-        if(isset($this->aTypes[$sClass]))
85
+        if (isset($this->aTypes[$sClass]))
86 86
         {
87 87
             return;
88 88
         }
89 89
 
90 90
         $this->aTypes[$sClass] = [];
91
-        $aProperties = $xClass->getProperties(ReflectionProperty::IS_PUBLIC |
91
+        $aProperties = $xClass->getProperties(ReflectionProperty::IS_PUBLIC|
92 92
             ReflectionProperty::IS_PROTECTED);
93
-        foreach($aProperties as $xReflectionProperty)
93
+        foreach ($aProperties as $xReflectionProperty)
94 94
         {
95 95
             $xType = $xReflectionProperty->getType();
96 96
             // Check that the property has a valid type defined
97
-            if(is_a($xType, ReflectionNamedType::class) &&
97
+            if (is_a($xType, ReflectionNamedType::class) &&
98 98
                 ($sType = $xType->getName()) !== '')
99 99
             {
100 100
                 $this->aTypes[$sClass][$xReflectionProperty->getName()] = $sType;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
     private function initAttribute(AbstractAttribute $xAttribute,
113 113
         ReflectionClass $xClass, ReflectionAttribute $xReflectionAttribute): void
114 114
     {
115
-        if(is_a($xAttribute, InjectAttribute::class))
115
+        if (is_a($xAttribute, InjectAttribute::class))
116 116
         {
117 117
             $this->readTypes($xClass);
118 118
             $xAttribute->setTarget($xReflectionAttribute->getTarget());
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         $aAttributes = $xClass->getAttributes();
161 161
         $aAttributes = array_filter($aAttributes, fn($xReflectionAttribute) =>
162 162
             $this->isBaseClassAttribute($xReflectionAttribute));
163
-        foreach($aAttributes as $xReflectionAttribute)
163
+        foreach ($aAttributes as $xReflectionAttribute)
164 164
         {
165 165
             $xReflectionAttribute->newInstance()->saveValue($this->xMetadata);
166 166
         }
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
         $aAttributes = array_filter($aAttributes, fn($xReflectionAttribute) =>
178 178
             $this->isJaxonAttribute($xReflectionAttribute) &&
179 179
             !$this->isBaseClassAttribute($xReflectionAttribute));
180
-        foreach($aAttributes as $xReflectionAttribute)
180
+        foreach ($aAttributes as $xReflectionAttribute)
181 181
         {
182 182
             $xAttribute = $xReflectionAttribute->newInstance();
183 183
             $this->initAttribute($xAttribute, $xClass, $xReflectionAttribute);
@@ -195,17 +195,16 @@  discard block
 block discarded – undo
195 195
      */
196 196
     private function readPropertyAttributes(ReflectionClass $xClass, string $sProperty): void
197 197
     {
198
-        $aAttributes = !$xClass->hasProperty($sProperty) ? [] :
199
-            $xClass->getProperty($sProperty)->getAttributes();
198
+        $aAttributes = !$xClass->hasProperty($sProperty) ? [] : $xClass->getProperty($sProperty)->getAttributes();
200 199
         $aAttributes = array_filter($aAttributes, fn($xReflectionAttribute) =>
201 200
             $this->isPropertyAttribute($xReflectionAttribute));
202 201
         // Only Inject attributes are allowed on properties
203
-        if(count($aAttributes) > 1)
202
+        if (count($aAttributes) > 1)
204 203
         {
205 204
             throw new SetupException('Only one Inject attribute is allowed on a property');
206 205
         }
207 206
 
208
-        foreach($aAttributes as $xReflectionAttribute)
207
+        foreach ($aAttributes as $xReflectionAttribute)
209 208
         {
210 209
             /** @var InjectAttribute */
211 210
             $xAttribute = $xReflectionAttribute->newInstance();
@@ -224,11 +223,10 @@  discard block
 block discarded – undo
224 223
      */
225 224
     private function readMethodAttributes(ReflectionClass $xClass, string $sMethod): void
226 225
     {
227
-        $aAttributes = !$xClass->hasMethod($sMethod) ? [] :
228
-            $xClass->getMethod($sMethod)->getAttributes();
226
+        $aAttributes = !$xClass->hasMethod($sMethod) ? [] : $xClass->getMethod($sMethod)->getAttributes();
229 227
         $aAttributes = array_filter($aAttributes, fn($xReflectionAttribute) =>
230 228
             $this->isJaxonAttribute($xReflectionAttribute));
231
-        foreach($aAttributes as $xReflectionAttribute)
229
+        foreach ($aAttributes as $xReflectionAttribute)
232 230
         {
233 231
             $xAttribute = $xReflectionAttribute->newInstance();
234 232
             $this->initAttribute($xAttribute, $xClass, $xReflectionAttribute);
@@ -263,33 +261,33 @@  discard block
 block discarded – undo
263 261
             $this->readBaseClassAttributes($xClass);
264 262
 
265 263
             $aClasses = [$xClass];
266
-            while(($xClass = $this->getParentClass($xClass)) !== null)
264
+            while (($xClass = $this->getParentClass($xClass)) !== null)
267 265
             {
268 266
                 $aClasses[] = $xClass;
269 267
             }
270 268
             $aClasses = array_reverse($aClasses);
271 269
 
272
-            foreach($aClasses as $xClass)
270
+            foreach ($aClasses as $xClass)
273 271
             {
274 272
                 // Processing class attributes
275 273
                 $this->readClassAttributes($xClass);
276 274
                 // Processing properties attributes
277
-                foreach($xInput->getProperties() as $sProperty)
275
+                foreach ($xInput->getProperties() as $sProperty)
278 276
                 {
279 277
                     $this->readPropertyAttributes($xClass, $sProperty);
280 278
                 }
281 279
             }
282 280
 
283 281
             // The methods attributes are not taken for excluded classes.
284
-            if($this->xMetadata->isExcluded())
282
+            if ($this->xMetadata->isExcluded())
285 283
             {
286 284
                 return $this->xMetadata;
287 285
             }
288 286
 
289
-            foreach($aClasses as $xClass)
287
+            foreach ($aClasses as $xClass)
290 288
             {
291 289
                 // Processing methods attributes
292
-                foreach($xInput->getMethods() as $sMethod)
290
+                foreach ($xInput->getMethods() as $sMethod)
293 291
                 {
294 292
                     $this->readMethodAttributes($xClass, $sMethod);
295 293
                 }
@@ -297,7 +295,7 @@  discard block
 block discarded – undo
297 295
 
298 296
             return $this->xMetadata;
299 297
         }
300
-        catch(Exception|Error $e)
298
+        catch (Exception|Error $e)
301 299
         {
302 300
             throw new SetupException($e->getMessage());
303 301
         }
Please login to merge, or discard this patch.
jaxon-annotations/src/AnnotationReader.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -116,21 +116,21 @@  discard block
 block discarded – undo
116 116
             fn($xAnnotation) => is_a($xAnnotation, AbstractAnnotation::class)
117 117
         );
118 118
         // First check if the class is excluded.
119
-        foreach($aAnnotations as $xAnnotation)
119
+        foreach ($aAnnotations as $xAnnotation)
120 120
         {
121
-            if(is_a($xAnnotation, ExcludeAnnotation::class))
121
+            if (is_a($xAnnotation, ExcludeAnnotation::class))
122 122
             {
123 123
                 $xAnnotation->saveValue($this->xMetadata);
124 124
             }
125 125
         }
126
-        if($this->xMetadata->isExcluded())
126
+        if ($this->xMetadata->isExcluded())
127 127
         {
128 128
             return;
129 129
         }
130 130
 
131
-        foreach($aAnnotations as $xAnnotation)
131
+        foreach ($aAnnotations as $xAnnotation)
132 132
         {
133
-            if(!is_a($xAnnotation, ExcludeAnnotation::class))
133
+            if (!is_a($xAnnotation, ExcludeAnnotation::class))
134 134
             {
135 135
                 $xAnnotation->saveValue($this->xMetadata);
136 136
             }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
             $this->xManager->getPropertyAnnotations($sClass, $sProperty),
153 153
             function($xAnnotation) use($sProperty) {
154 154
                 // Save the property type
155
-                if(is_a($xAnnotation, VarAnnotation::class))
155
+                if (is_a($xAnnotation, VarAnnotation::class))
156 156
                 {
157 157
                     $this->aPropTypes[$sProperty] = $xAnnotation->type;
158 158
                 }
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
                 return is_a($xAnnotation, ContainerAnnotation::class);
161 161
             }
162 162
         );
163
-        if(count($aAnnotations) > 1)
163
+        if (count($aAnnotations) > 1)
164 164
         {
165 165
             throw new AnnotationException('Only one @di annotation is allowed on a property');
166 166
         }
167 167
 
168
-        foreach($aAnnotations as $xAnnotation)
168
+        foreach ($aAnnotations as $xAnnotation)
169 169
         {
170 170
             $xAnnotation->setAttr($sProperty);
171 171
             $xAnnotation->saveValue($this->xMetadata);
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
             $this->xManager->getMethodAnnotations($sClass, $sMethod),
188 188
             fn($xAnnotation) => is_a($xAnnotation, AbstractAnnotation::class)
189 189
         );
190
-        foreach($aAnnotations as $xAnnotation)
190
+        foreach ($aAnnotations as $xAnnotation)
191 191
         {
192 192
             $xAnnotation->saveValue($this->xMetadata, $sMethod);
193 193
         }
@@ -214,13 +214,13 @@  discard block
 block discarded – undo
214 214
             $this->sCurrMemberType = AnnotationManager::MEMBER_PROPERTY;
215 215
 
216 216
             // Properties annotations
217
-            foreach($xInput->getProperties() as $sProperty)
217
+            foreach ($xInput->getProperties() as $sProperty)
218 218
             {
219 219
                 $this->readPropertyAnnotations($sClass, $sProperty);
220 220
             }
221 221
 
222 222
             // The methods annotations are not taken for excluded classes.
223
-            if($this->xMetadata->isExcluded())
223
+            if ($this->xMetadata->isExcluded())
224 224
             {
225 225
                 return $this->xMetadata;
226 226
             }
@@ -228,14 +228,14 @@  discard block
 block discarded – undo
228 228
             // Processing methods annotations
229 229
             $this->sCurrMemberType = AnnotationManager::MEMBER_METHOD;
230 230
 
231
-            foreach($xInput->getMethods() as $sMethod)
231
+            foreach ($xInput->getMethods() as $sMethod)
232 232
             {
233 233
                 $this->readMethodAnnotations($sClass, $sMethod);
234 234
             }
235 235
 
236 236
             return $this->xMetadata;
237 237
         }
238
-        catch(AnnotationException $e)
238
+        catch (AnnotationException $e)
239 239
         {
240 240
             throw new SetupException($e->getMessage());
241 241
         }
Please login to merge, or discard this patch.
jaxon-annotations/tests/TestAnnotation/ComponentTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
         $aFiles = scandir($this->sCacheDir);
46 46
         foreach ($aFiles as $sFile)
47 47
         {
48
-            if($sFile !== '.' && $sFile !== '..')
48
+            if ($sFile !== '.' && $sFile !== '..')
49 49
             {
50 50
                 @unlink($this->sCacheDir . DIRECTORY_SEPARATOR . $sFile);
51 51
             }
Please login to merge, or discard this patch.
jaxon-core/src/Di/Traits/ComponentTrait.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -151,15 +151,15 @@  discard block
 block discarded – undo
151 151
         $xRegistry->updateHash(false); // Disable hash calculation.
152 152
 
153 153
         $sComponentId = str_replace('\\', '.', $sClassName);
154
-        if(!isset($this->aComponents[$sComponentId]))
154
+        if (!isset($this->aComponents[$sComponentId]))
155 155
         {
156 156
             $aOptions = $xRegistry->getNamespaceComponentOptions($sClassName);
157
-            if($aOptions !== null)
157
+            if ($aOptions !== null)
158 158
             {
159 159
                 $this->saveComponent($sClassName, $aOptions);
160 160
             }
161 161
         }
162
-        if(isset($this->aComponents[$sComponentId]))
162
+        if (isset($this->aComponents[$sComponentId]))
163 163
         {
164 164
             return; // The component is found.
165 165
         }
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
         // The component was not found in a registered namespace. We need to parse all
168 168
         // the directories to be able to find a component registered without a namespace.
169 169
         $sComponentId = str_replace('\\', '_', $sClassName);
170
-        if(!isset($this->aComponents[$sComponentId]))
170
+        if (!isset($this->aComponents[$sComponentId]))
171 171
         {
172 172
             $xRegistry->registerComponentsInDirectories();
173 173
         }
174
-        if(isset($this->aComponents[$sComponentId]))
174
+        if (isset($this->aComponents[$sComponentId]))
175 175
         {
176 176
             return; // The component is found.
177 177
         }
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
     public function getCallableObjects(): array
190 190
     {
191 191
         $aCallableObjects = [];
192
-        foreach($this->aComponents as $sComponentId => $_)
192
+        foreach ($this->aComponents as $sComponentId => $_)
193 193
         {
194 194
             $aCallableObjects[$sComponentId] = $this->makeCallableObject($sComponentId);
195 195
         }
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
     private function setComponentPublicMethods(string $sKey, string $sClass,
207 207
         array $aNeverExported): void
208 208
     {
209
-        if(isset($this->aComponentPublicMethods[$sKey]))
209
+        if (isset($this->aComponentPublicMethods[$sKey]))
210 210
         {
211 211
             return;
212 212
         }
@@ -259,12 +259,12 @@  discard block
 block discarded – undo
259 259
     {
260 260
         /** @var Config|null */
261 261
         $xPackageConfig = $aOptions['config'] ?? null;
262
-        if($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false))
262
+        if ($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false))
263 263
         {
264 264
             return null;
265 265
         }
266 266
         $sMetadataFormat = $xPackageConfig->getOption('metadata.format');
267
-        if(!in_array($sMetadataFormat, ['attributes', 'annotations']))
267
+        if (!in_array($sMetadataFormat, ['attributes', 'annotations']))
268 268
         {
269 269
             return null;
270 270
         }
@@ -274,23 +274,23 @@  discard block
 block discarded – undo
274 274
         $xMetadata = null;
275 275
         $xMetadataCache = null;
276 276
         $xConfig = $di->config();
277
-        if($xConfig->getAppOption('metadata.cache.enabled', false))
277
+        if ($xConfig->getAppOption('metadata.cache.enabled', false))
278 278
         {
279
-            if(!$di->h('jaxon_metadata_cache_dir'))
279
+            if (!$di->h('jaxon_metadata_cache_dir'))
280 280
             {
281 281
                 $sCacheDir = $xConfig->getAppOption('metadata.cache.dir');
282 282
                 $di->val('jaxon_metadata_cache_dir', $sCacheDir);
283 283
             }
284 284
             $xMetadataCache = $di->getMetadataCache();
285 285
             $xMetadata = $xMetadataCache->read($xReflectionClass->getName());
286
-            if($xMetadata !== null)
286
+            if ($xMetadata !== null)
287 287
             {
288 288
                 return $xMetadata;
289 289
             }
290 290
         }
291 291
 
292 292
         $aProperties = array_map(fn($xProperty) => $xProperty->getName(),
293
-            $xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC |
293
+            $xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC|
294 294
                 ReflectionProperty::IS_PROTECTED));
295 295
 
296 296
         $xMetadataReader = $di->getMetadataReader($sMetadataFormat);
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
         $xMetadata = $xMetadataReader->getAttributes($xInput);
299 299
 
300 300
         // Try to save the metadata in the cache
301
-        if($xMetadataCache !== null)
301
+        if ($xMetadataCache !== null)
302 302
         {
303 303
             $xMetadataCache->save($xReflectionClass->getName(), $xMetadata);
304 304
         }
Please login to merge, or discard this patch.
jaxon-upload/src/Manager/UploadManager.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -121,13 +121,13 @@  discard block
 block discarded – undo
121 121
         try
122 122
         {
123 123
             $xFilesystem->createDirectory($sUploadDir);
124
-            if(!$xFilesystem->directoryExists($sUploadDir))
124
+            if (!$xFilesystem->directoryExists($sUploadDir))
125 125
             {
126 126
                 throw new RequestException($this->xTranslator->trans('errors.upload.access'));
127 127
             }
128 128
             return $sUploadDir;
129 129
         }
130
-        catch(FilesystemException $e)
130
+        catch (FilesystemException $e)
131 131
         {
132 132
             $this->xLogger->error('Filesystem error.', ['message' => $e->getMessage()]);
133 133
             throw new RequestException($this->xTranslator->trans('errors.upload.access'));
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
     {
163 163
         // Check the uploaded file validity
164 164
         $nErrorCode = $xHttpFile->getError();
165
-        if($nErrorCode !== UPLOAD_ERR_OK)
165
+        if ($nErrorCode !== UPLOAD_ERR_OK)
166 166
         {
167 167
             $this->xLogger->error('File upload error.', [
168 168
                 'code' => $nErrorCode,
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
         // Filename without the extension. Needs to be sanitized.
178 178
         $sName = pathinfo($xHttpFile->getClientFilename(), PATHINFO_FILENAME);
179
-        if($this->cNameSanitizer !== null)
179
+        if ($this->cNameSanitizer !== null)
180 180
         {
181 181
             $sName = (string)call_user_func($this->cNameSanitizer,
182 182
                 $sName, $sField, $this->sUploadFieldId);
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
         // Set the user file data
186 186
         $xFile = File::fromHttpFile($this->xFileStorage->filesystem($sField), $xHttpFile, $sUploadDir, $sName);
187 187
         // Verify file validity (format, size)
188
-        if(!$this->xValidator->validateUploadedFile($sField, $xFile))
188
+        if (!$this->xValidator->validateUploadedFile($sField, $xFile))
189 189
         {
190 190
             throw new RequestException($this->xValidator->getErrorMessage());
191 191
         }
@@ -209,16 +209,16 @@  discard block
 block discarded – undo
209 209
 
210 210
         $aUserFiles = [];
211 211
         $aAllFiles = []; // A flat list of all uploaded files
212
-        foreach($aTempFiles as $sField => $aFiles)
212
+        foreach ($aTempFiles as $sField => $aFiles)
213 213
         {
214 214
             $aUserFiles[$sField] = [];
215 215
             // Get the path to the upload dir
216 216
             $sUploadDir = $this->getUploadDir($sField);
217
-            if(!is_array($aFiles))
217
+            if (!is_array($aFiles))
218 218
             {
219 219
                 $aFiles = [$aFiles];
220 220
             }
221
-            foreach($aFiles as $xHttpFile)
221
+            foreach ($aFiles as $xHttpFile)
222 222
             {
223 223
                 $aFile = $this->makeUploadedFile($xHttpFile, $sUploadDir, $sField);
224 224
                 $aUserFiles[$sField][] = $aFile['user'];
@@ -229,14 +229,14 @@  discard block
 block discarded – undo
229 229
         // Copy the uploaded files from the temp dir to the user dir
230 230
         try
231 231
         {
232
-            foreach($aAllFiles as $aFiles)
232
+            foreach ($aAllFiles as $aFiles)
233 233
             {
234 234
                 $sPath = $aFiles['user']->path();
235 235
                 $xContent = $aFiles['temp']->getStream();
236 236
                 $aFiles['user']->filesystem()->write($sPath, $xContent);
237 237
             }
238 238
         }
239
-        catch(FilesystemException $e)
239
+        catch (FilesystemException $e)
240 240
         {
241 241
             $this->xLogger->error('Filesystem error.', ['message' => $e->getMessage()]);
242 242
             throw new RequestException($this->xTranslator->trans('errors.upload.access'));
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.