Passed
Push — main ( 4ddaea...7c5fe7 )
by Thierry
04:58
created
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-core/src/Di/Container.php 1 patch
Spacing   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -119,8 +119,7 @@  discard block
 block discarded – undo
119 119
     public function setLogger(LoggerInterface|Closure $xLogger)
120 120
     {
121 121
         is_a($xLogger, LoggerInterface::class) ?
122
-            $this->val(LoggerInterface::class, $xLogger) :
123
-            $this->set(LoggerInterface::class, $xLogger);
122
+            $this->val(LoggerInterface::class, $xLogger) : $this->set(LoggerInterface::class, $xLogger);
124 123
     }
125 124
 
126 125
     /**
@@ -199,7 +198,7 @@  discard block
 block discarded – undo
199 198
             return $this->xAppContainer != null && $this->xAppContainer->has($sClass) ?
200 199
                 $this->xAppContainer->get($sClass) : $this->xLibContainer->offsetGet($sClass);
201 200
         }
202
-        catch(Throwable $e)
201
+        catch (Throwable $e)
203 202
         {
204 203
             $xLogger = $this->g(LoggerInterface::class);
205 204
             $xTranslator = $this->g(Translator::class);
@@ -265,15 +264,15 @@  discard block
 block discarded – undo
265 264
     {
266 265
         $xType = $xParameter->getType();
267 266
         // Check the parameter class first.
268
-        if($xType instanceof ReflectionNamedType)
267
+        if ($xType instanceof ReflectionNamedType)
269 268
         {
270 269
             // Check the class + the name
271
-            if($this->has($xType->getName() . ' $' . $xParameter->getName()))
270
+            if ($this->has($xType->getName() . ' $' . $xParameter->getName()))
272 271
             {
273 272
                 return $this->get($xType->getName() . ' $' . $xParameter->getName());
274 273
             }
275 274
             // Check the class only
276
-            if($this->has($xType->getName()))
275
+            if ($this->has($xType->getName()))
277 276
             {
278 277
                 return $this->get($xType->getName());
279 278
             }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Code/CodeGenerator.php 1 patch
Spacing   +20 added lines, -22 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function addCodeGenerator(string $sClassName, int $nPriority): void
111 111
     {
112
-        while(isset($this->aCodeGenerators[$nPriority]))
112
+        while (isset($this->aCodeGenerators[$nPriority]))
113 113
         {
114 114
             $nPriority++;
115 115
         }
@@ -163,33 +163,33 @@  discard block
 block discarded – undo
163 163
      */
164 164
     private function generatePluginCodes(CodeGeneratorInterface $xGenerator): void
165 165
     {
166
-        if(!is_subclass_of($xGenerator, AbstractPlugin::class) ||
166
+        if (!is_subclass_of($xGenerator, AbstractPlugin::class) ||
167 167
             $this->xAssetManager->shallIncludeAssets($xGenerator))
168 168
         {
169 169
             // HTML tags for CSS
170
-            if(($sCss = trim($xGenerator->getCss(), " \n")) !== '')
170
+            if (($sCss = trim($xGenerator->getCss(), " \n")) !== '')
171 171
             {
172 172
                 $this->aCss[] = $sCss;
173 173
             }
174 174
             // HTML tags for js
175
-            if(($sJs = trim($xGenerator->getJs(), " \n")) !== '')
175
+            if (($sJs = trim($xGenerator->getJs(), " \n")) !== '')
176 176
             {
177 177
                 $this->aJs[] = $sJs;
178 178
             }
179 179
         }
180 180
 
181 181
         // Additional js codes
182
-        if(($xJsCode = $xGenerator->getJsCode()) !== null)
182
+        if (($xJsCode = $xGenerator->getJsCode()) !== null)
183 183
         {
184
-            if(($sJs = trim($xJsCode->sJs, " \n")) !== '')
184
+            if (($sJs = trim($xJsCode->sJs, " \n")) !== '')
185 185
             {
186 186
                 $this->aCodeJs[] = $sJs;
187 187
             }
188
-            if(($sJsBefore = trim($xJsCode->sJsBefore, " \n")) !== '')
188
+            if (($sJsBefore = trim($xJsCode->sJsBefore, " \n")) !== '')
189 189
             {
190 190
                 $this->aCodeJsBefore[] = $sJsBefore;
191 191
             }
192
-            if(($sJsAfter = trim($xJsCode->sJsAfter, " \n")) !== '')
192
+            if (($sJsAfter = trim($xJsCode->sJsAfter, " \n")) !== '')
193 193
             {
194 194
                 $this->aCodeJsAfter[] = $sJsAfter;
195 195
             }
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      */
206 206
     private function generateCodes(): void
207 207
     {
208
-        if($this->bGenerated)
208
+        if ($this->bGenerated)
209 209
         {
210 210
             return;
211 211
         }
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
         // Sort the code generators by ascending priority
217 217
         ksort($this->aCodeGenerators);
218 218
 
219
-        foreach($this->aCodeGenerators as $sClassName)
219
+        foreach ($this->aCodeGenerators as $sClassName)
220 220
         {
221 221
             $this->generatePluginCodes($this->getCodeGenerator($sClassName));
222 222
         }
@@ -262,11 +262,11 @@  discard block
 block discarded – undo
262 262
     public function getJsScript(): string
263 263
     {
264 264
         $aJsScripts = [];
265
-        foreach($this->aCodeGenerators as $sClassName)
265
+        foreach ($this->aCodeGenerators as $sClassName)
266 266
         {
267 267
             $xGenerator = $this->getCodeGenerator($sClassName);
268 268
             // Javascript code
269
-            if(($sJsScript = trim($xGenerator->getScript(), " \n")) !== '')
269
+            if (($sJsScript = trim($xGenerator->getScript(), " \n")) !== '')
270 270
             {
271 271
                 $aJsScripts[] = $sJsScript;
272 272
             }
@@ -283,38 +283,36 @@  discard block
 block discarded – undo
283 283
     private function renderCodes(bool $bIncludeJs, bool $bIncludeCss): array
284 284
     {
285 285
         $aCodes = [];
286
-        if($bIncludeCss)
286
+        if ($bIncludeCss)
287 287
         {
288 288
             $aCodes[] = $this->getCss();
289 289
         }
290
-        if($bIncludeJs)
290
+        if ($bIncludeJs)
291 291
         {
292 292
             $aCodes[] = $this->getJs();
293 293
         }
294 294
 
295
-        $sUrl = !$this->xAssetManager->shallCreateJsFiles() ? '' :
296
-            $this->xAssetManager->createJsFiles($this);
295
+        $sUrl = !$this->xAssetManager->shallCreateJsFiles() ? '' : $this->xAssetManager->createJsFiles($this);
297 296
         // Wrap the js code into the corresponding HTML tag.
298 297
         $aCodes[] = $sUrl !== '' ?
299
-            $this->render('include.js', ['sUrl' => $sUrl]) :
300
-            $this->render('wrapper.js', ['sScript' => $this->getJsScript()]);
298
+            $this->render('include.js', ['sUrl' => $sUrl]) : $this->render('wrapper.js', ['sScript' => $this->getJsScript()]);
301 299
 
302 300
         // Wrap the js codes into HTML tags.
303
-        if(count($this->aCodeJsBefore) > 0)
301
+        if (count($this->aCodeJsBefore) > 0)
304 302
         {
305 303
             $sScript = implode("\n\n", $this->aCodeJsBefore);
306 304
             $aCodes[] = $this->render('wrapper.js', ['sScript' => $sScript]);
307 305
         }
308
-        if(count($this->aCodeJs) > 0)
306
+        if (count($this->aCodeJs) > 0)
309 307
         {
310 308
             $sScript = implode("\n\n", $this->aCodeJs);
311 309
             $aCodes[] = $this->render('wrapper.js', ['sScript' => $sScript]);
312 310
         }
313
-        if(count($this->aCodeJsFiles) > 0)
311
+        if (count($this->aCodeJsFiles) > 0)
314 312
         {
315 313
             $aCodes[] = $this->render('includes.js', ['aUrls' => $this->aCodeJsFiles]);
316 314
         }
317
-        if(count($this->aCodeJsAfter) > 0)
315
+        if (count($this->aCodeJsAfter) > 0)
318 316
         {
319 317
             $sScript = implode("\n\n", $this->aCodeJsAfter);
320 318
             $aCodes[] = $this->render('wrapper.js', ['sScript' => $sScript]);
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.