Passed
Push — main ( 6c6690...0dcad8 )
by Thierry
03:45
created
jaxon-core/src/Plugin/Request/CallableClass/ComponentRegistry.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
     public function __construct(protected ComponentContainer $cdi)
111 111
     {
112 112
         // Set the composer autoloader
113
-        if(file_exists(($sAutoloadFile = __DIR__ . '/../../../../../../autoload.php')) ||
113
+        if (file_exists(($sAutoloadFile = __DIR__ . '/../../../../../../autoload.php')) ||
114 114
             file_exists(($sAutoloadFile = __DIR__ . '/../../../../../vendor/autoload.php')) ||
115 115
             file_exists(($sAutoloadFile = __DIR__ . '/../../../../vendor/autoload.php')))
116 116
         {
@@ -179,15 +179,15 @@  discard block
 block discarded – undo
179 179
      */
180 180
     private function makeClassOptions(string $sClassName, array $aClassOptions, array $aDirectoryOptions): array
181 181
     {
182
-        foreach($this->aDefaultClassOptions as $sOption => $xValue)
182
+        foreach ($this->aDefaultClassOptions as $sOption => $xValue)
183 183
         {
184
-            if(!isset($aClassOptions[$sOption]))
184
+            if (!isset($aClassOptions[$sOption]))
185 185
             {
186 186
                 $aClassOptions[$sOption] = $xValue;
187 187
             }
188 188
         }
189 189
         $aClassOptions['excluded'] = (bool)($aClassOptions['excluded'] ?? false); // Convert to bool.
190
-        if(is_string($aClassOptions['protected']))
190
+        if (is_string($aClassOptions['protected']))
191 191
         {
192 192
             $aClassOptions['protected'] = [$aClassOptions['protected']]; // Convert to array.
193 193
         }
@@ -198,30 +198,30 @@  discard block
 block discarded – undo
198 198
             $aDirectoryOptions['classes']['*'] ?? [], // Options for all classes
199 199
             $aDirectoryOptions['classes'][$sClassName] ?? [], // Options for this specific class
200 200
         ];
201
-        foreach($aOptionGroups as $aOptionGroup)
201
+        foreach ($aOptionGroups as $aOptionGroup)
202 202
         {
203
-            if(isset($aOptionGroup['separator']))
203
+            if (isset($aOptionGroup['separator']))
204 204
             {
205 205
                 $aClassOptions['separator'] = (string)$aOptionGroup['separator'];
206 206
             }
207
-            if(isset($aOptionGroup['excluded']))
207
+            if (isset($aOptionGroup['excluded']))
208 208
             {
209 209
                 $aClassOptions['excluded'] = (bool)$aOptionGroup['excluded'];
210 210
             }
211
-            if(isset($aOptionGroup['protected']))
211
+            if (isset($aOptionGroup['protected']))
212 212
             {
213
-                if(is_string($aOptionGroup['protected']))
213
+                if (is_string($aOptionGroup['protected']))
214 214
                 {
215 215
                     $aOptionGroup['protected'] = [$aOptionGroup['protected']]; // Convert to array.
216 216
                 }
217 217
                 $aClassOptions['protected'] = array_merge($aClassOptions['protected'], $aOptionGroup['protected']);
218 218
             }
219
-            if(isset($aOptionGroup['functions']))
219
+            if (isset($aOptionGroup['functions']))
220 220
             {
221 221
                 $aClassOptions['functions'] = array_merge($aClassOptions['functions'], $aOptionGroup['functions']);
222 222
             }
223 223
         }
224
-        if(isset($aDirectoryOptions['config']) && !isset($aClassOptions['config']))
224
+        if (isset($aDirectoryOptions['config']) && !isset($aClassOptions['config']))
225 225
         {
226 226
             $aClassOptions['config'] = $aDirectoryOptions['config'];
227 227
         }
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     {
244 244
         $aOptions = $this->makeClassOptions($sClassName, $aClassOptions, $aDirectoryOptions);
245 245
         $this->cdi->saveComponent($sClassName, $aOptions);
246
-        if($this->bUpdateHash)
246
+        if ($this->bUpdateHash)
247 247
         {
248 248
             $this->sHash .= $sClassName . $aOptions['timestamp'];
249 249
         }
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
     {
262 262
         // For classes, the underscore is used as separator.
263 263
         $aClassOptions['separator'] = '_';
264
-        if($this->xPackageConfig !== null)
264
+        if ($this->xPackageConfig !== null)
265 265
         {
266 266
             $aClassOptions['config'] = $this->xPackageConfig;
267 267
         }
@@ -278,10 +278,10 @@  discard block
 block discarded – undo
278 278
     public function getNamespaceComponentOptions(string $sClassName): ?array
279 279
     {
280 280
         // Find the corresponding namespace
281
-        foreach($this->aNamespaceOptions as $sNamespace => $aDirectoryOptions)
281
+        foreach ($this->aNamespaceOptions as $sNamespace => $aDirectoryOptions)
282 282
         {
283 283
             // Check if the namespace matches the class.
284
-            if(strncmp($sClassName, $sNamespace . '\\', strlen($sNamespace) + 1) === 0)
284
+            if (strncmp($sClassName, $sNamespace . '\\', strlen($sNamespace) + 1) === 0)
285 285
             {
286 286
                 // Save the class options
287 287
                 $aClassOptions = ['namespace' => $sNamespace];
@@ -304,11 +304,11 @@  discard block
 block discarded – undo
304 304
         // For directories without namespace, the underscore is used as separator.
305 305
         $aOptions['separator'] = '_';
306 306
         // Set the autoload option default value
307
-        if(!isset($aOptions['autoload']))
307
+        if (!isset($aOptions['autoload']))
308 308
         {
309 309
             $aOptions['autoload'] = true;
310 310
         }
311
-        if($this->xPackageConfig !== null)
311
+        if ($this->xPackageConfig !== null)
312 312
         {
313 313
             $aOptions['config'] = $this->xPackageConfig;
314 314
         }
@@ -342,16 +342,16 @@  discard block
 block discarded – undo
342 342
         // For namespaces, the dot is used as separator.
343 343
         $aOptions['separator'] = '.';
344 344
         // Set the autoload option default value
345
-        if(!isset($aOptions['autoload']))
345
+        if (!isset($aOptions['autoload']))
346 346
         {
347 347
             $aOptions['autoload'] = true;
348 348
         }
349
-        if($this->xPackageConfig !== null)
349
+        if ($this->xPackageConfig !== null)
350 350
         {
351 351
             $aOptions['config'] = $this->xPackageConfig;
352 352
         }
353 353
         // Register the dir with PSR4 autoloading
354
-        if(($aOptions['autoload']) && $this->xAutoloader != null)
354
+        if (($aOptions['autoload']) && $this->xAutoloader != null)
355 355
         {
356 356
             $this->xAutoloader->setPsr4($sNamespace . '\\', $aOptions['directory']);
357 357
         }
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
     public function registerComponentsInNamespaces(): void
368 368
     {
369 369
         // This is to be done only once.
370
-        if($this->bNamespacesParsed)
370
+        if ($this->bNamespacesParsed)
371 371
         {
372 372
             return;
373 373
         }
@@ -375,17 +375,17 @@  discard block
 block discarded – undo
375 375
 
376 376
         // Browse directories with namespaces and read all the files.
377 377
         $sDS = DIRECTORY_SEPARATOR;
378
-        foreach($this->aNamespaceOptions as $sNamespace => $aDirectoryOptions)
378
+        foreach ($this->aNamespaceOptions as $sNamespace => $aDirectoryOptions)
379 379
         {
380 380
             $this->addNamespace($sNamespace, ['separator' => '.']);
381 381
 
382 382
             // Iterate on dir content
383 383
             $sDirectory = $aDirectoryOptions['directory'];
384 384
             $itFile = new SortedFileIterator($sDirectory);
385
-            foreach($itFile as $xFile)
385
+            foreach ($itFile as $xFile)
386 386
             {
387 387
                 // skip everything except PHP files
388
-                if(!$xFile->isFile() || $xFile->getExtension() !== 'php')
388
+                if (!$xFile->isFile() || $xFile->getExtension() !== 'php')
389 389
                 {
390 390
                     continue;
391 391
                 }
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
                 $sClassPath = $sNamespace;
395 395
                 $sRelativePath = substr($xFile->getPath(), strlen($sDirectory));
396 396
                 $sRelativePath = trim(str_replace($sDS, '\\', $sRelativePath), '\\');
397
-                if($sRelativePath !== '')
397
+                if ($sRelativePath !== '')
398 398
                 {
399 399
                     $sClassPath .= '\\' . $sRelativePath;
400 400
                 }
@@ -420,21 +420,21 @@  discard block
 block discarded – undo
420 420
     public function registerComponentsInDirectories(): void
421 421
     {
422 422
         // This is to be done only once.
423
-        if($this->bDirectoriesParsed)
423
+        if ($this->bDirectoriesParsed)
424 424
         {
425 425
             return;
426 426
         }
427 427
         $this->bDirectoriesParsed = true;
428 428
 
429 429
         // Browse directories without namespaces and read all the files.
430
-        foreach($this->aDirectoryOptions as $sDirectory => $aDirectoryOptions)
430
+        foreach ($this->aDirectoryOptions as $sDirectory => $aDirectoryOptions)
431 431
         {
432 432
             $itFile = new SortedFileIterator($sDirectory);
433 433
             // Iterate on dir content
434
-            foreach($itFile as $xFile)
434
+            foreach ($itFile as $xFile)
435 435
             {
436 436
                 // Skip everything except PHP files
437
-                if(!$xFile->isFile() || $xFile->getExtension() !== 'php')
437
+                if (!$xFile->isFile() || $xFile->getExtension() !== 'php')
438 438
                 {
439 439
                     continue;
440 440
                 }
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
                     'separator' => '.',
445 445
                     'timestamp' => $xFile->getMTime(),
446 446
                 ];
447
-                if(($aDirectoryOptions['autoload']) && $this->xAutoloader !== null)
447
+                if (($aDirectoryOptions['autoload']) && $this->xAutoloader !== null)
448 448
                 {
449 449
                     // Set classmap autoloading. Must be done before registering the class.
450 450
                     $this->xAutoloader->addClassMap([$sClassName => $xFile->getPathname()]);
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 2 patches
Switch Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -13,94 +13,94 @@
 block discarded – undo
13 13
 
14 14
 class DatabagPlugin extends AbstractResponsePlugin
15 15
 {
16
-    /**
16
+/**
17 17
      * @const The plugin name
18 18
      */
19
-    public const NAME = 'bags';
19
+public const NAME = 'bags';
20 20
 
21
-    /**
21
+/**
22 22
      * @var Databag
23 23
      */
24
-    protected $xDatabag = null;
24
+protected $xDatabag = null;
25 25
 
26
-    /**
26
+/**
27 27
      * The constructor
28 28
      */
29
-    public function __construct(protected Container $di)
30
-    {}
29
+public function __construct(protected Container $di)
30
+{}
31 31
 
32
-    /**
32
+/**
33 33
      * @return void
34 34
      */
35
-    private function initDatabag(): void
36
-    {
37
-        if($this->xDatabag !== null)
38
-        {
39
-            return;
40
-        }
35
+private function initDatabag(): void
36
+{
37
+if($this->xDatabag !== null)
38
+{
39
+return;
40
+}
41 41
 
42
-        // Get the databag contents from the HTTP request parameters.
43
-        $xRequest = $this->di->getRequest();
44
-        $aBody = $xRequest->getParsedBody();
45
-        $aParams = $xRequest->getQueryParams();
46
-        $aData = is_array($aBody) ?
47
-            $this->readData($aBody['jxnbags'] ?? []) :
48
-            $this->readData($aParams['jxnbags'] ?? []);
49
-        $this->xDatabag = new Databag($this, $aData);
50
-    }
42
+// Get the databag contents from the HTTP request parameters.
43
+$xRequest = $this->di->getRequest();
44
+$aBody = $xRequest->getParsedBody();
45
+$aParams = $xRequest->getQueryParams();
46
+$aData = is_array($aBody) ?
47
+$this->readData($aBody['jxnbags'] ?? []) :
48
+$this->readData($aParams['jxnbags'] ?? []);
49
+$this->xDatabag = new Databag($this, $aData);
50
+}
51 51
 
52
-    /**
52
+/**
53 53
      * @inheritDoc
54 54
      */
55
-    public function getName(): string
56
-    {
57
-        return self::NAME;
58
-    }
55
+public function getName(): string
56
+{
57
+return self::NAME;
58
+}
59 59
 
60
-    /**
60
+/**
61 61
      * @param mixed $xData
62 62
      *
63 63
      * @return array
64 64
      */
65
-    private function readData($xData): array
66
-    {
67
-        // Todo: clean input data.
68
-        // Todo: verify the checksums.
69
-        return is_string($xData) ?
70
-            (json_decode($xData, true) ?: []) :
71
-            (is_array($xData) ? $xData : []);
72
-    }
65
+private function readData($xData): array
66
+{
67
+// Todo: clean input data.
68
+// Todo: verify the checksums.
69
+return is_string($xData) ?
70
+(json_decode($xData, true) ?: []) :
71
+(is_array($xData) ? $xData : []);
72
+}
73 73
 
74
-    /**
74
+/**
75 75
      * @inheritDoc
76 76
      */
77
-    public function getHash(): string
78
-    {
79
-        // Use the version number as hash
80
-        return '4.0.0';
81
-    }
77
+public function getHash(): string
78
+{
79
+// Use the version number as hash
80
+return '4.0.0';
81
+}
82 82
 
83
-    /**
83
+/**
84 84
      * @return void
85 85
      */
86
-    public function writeCommand(): void
87
-    {
88
-        $this->initDatabag();
89
-        if($this->xDatabag->touched())
90
-        {
91
-            // Todo: calculate the checksums.
92
-            $this->addCommand('databag.set', ['values' => $this->xDatabag]);
93
-        }
94
-    }
86
+public function writeCommand(): void
87
+{
88
+$this->initDatabag();
89
+if($this->xDatabag->touched())
90
+{
91
+// Todo: calculate the checksums.
92
+$this->addCommand('databag.set', ['values' => $this->xDatabag]);
93
+}
94
+}
95 95
 
96
-    /**
96
+/**
97 97
      * @param string $sName
98 98
      *
99 99
      * @return DatabagContext
100 100
      */
101
-    public function bag(string $sName): DatabagContext
102
-    {
103
-        $this->initDatabag();
104
-        return new DatabagContext($this->xDatabag, $sName);
105
-    }
101
+public function bag(string $sName): DatabagContext
102
+{
103
+$this->initDatabag();
104
+return new DatabagContext($this->xDatabag, $sName);
105
+}
106 106
 }
Please login to merge, or discard this 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 2 patches
Switch Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -28,40 +28,40 @@
 block discarded – undo
28 28
  */
29 29
 class DatabagAnnotation extends AbstractAnnotation
30 30
 {
31
-    /**
31
+/**
32 32
      * The data bag name
33 33
      *
34 34
      * @var string
35 35
      */
36
-    protected $sName = '';
36
+protected $sName = '';
37 37
 
38
-    /**
38
+/**
39 39
      * @inheritDoc
40 40
      */
41
-    public static function parseAnnotation($value)
42
-    {
43
-        $aParams = preg_split('/[\s]+/', $value, 2);
44
-        return count($aParams) === 1 ? ['name' => $aParams[0]] : ['name' => $aParams[0], 'extra' => $aParams[1]];
45
-    }
41
+public static function parseAnnotation($value)
42
+{
43
+$aParams = preg_split('/[\s]+/', $value, 2);
44
+return count($aParams) === 1 ? ['name' => $aParams[0]] : ['name' => $aParams[0], 'extra' => $aParams[1]];
45
+}
46 46
 
47
-    /**
47
+/**
48 48
      * @inheritDoc
49 49
      * @throws AnnotationException
50 50
      */
51
-    public function initAnnotation(array $properties)
52
-    {
53
-        if(count($properties) !== 1 || !isset($properties['name']) || !is_string($properties['name']))
54
-        {
55
-            throw new AnnotationException('The @databag annotation requires a property "name" of type string');
56
-        }
57
-        $this->sName = $properties['name'];
58
-    }
51
+public function initAnnotation(array $properties)
52
+{
53
+if(count($properties) !== 1 || !isset($properties['name']) || !is_string($properties['name']))
54
+{
55
+throw new AnnotationException('The @databag annotation requires a property "name" of type string');
56
+}
57
+$this->sName = $properties['name'];
58
+}
59 59
 
60
-    /**
60
+/**
61 61
      * @inheritDoc
62 62
      */
63
-    public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void
64
-    {
65
-        $xMetadata->databag($sMethod)->addValue($this->sName);
66
-    }
63
+public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void
64
+{
65
+$xMetadata->databag($sMethod)->addValue($this->sName);
66
+}
67 67
 }
Please login to merge, or discard this 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.