Passed
Push — main ( 7f530d...7aae9b )
by Thierry
05:54
created
jaxon-core/src/Di/Traits/ComponentTrait.php 2 patches
Switch Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -241,83 +241,83 @@
 block discarded – undo
241 241
                 $this->aComponentPublicMethods['node'],
242 242
             $xReflectionClass->isSubclassOf(FuncComponent::class) =>
243 243
                 $this->aComponentPublicMethods['func'],
244
-            default => [[], []],
245
-        };
244
+default => [[], []],
245
+};
246 246
 
247
-        return [$aMethods, ...$aBaseMethods];
248
-    }
247
+return [$aMethods, ...$aBaseMethods];
248
+}
249 249
 
250
-    /**
250
+/**
251 251
      * @param ReflectionClass $xReflectionClass
252 252
      * @param array $aMethods
253 253
      * @param array $aOptions
254 254
      *
255 255
      * @return Metadata|null
256 256
      */
257
-    private function getComponentMetadata(ReflectionClass $xReflectionClass,
258
-        array $aMethods, array $aOptions): Metadata|null
259
-    {
260
-        /** @var Config|null */
261
-        $xPackageConfig = $aOptions['config'] ?? null;
262
-        if($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false))
263
-        {
264
-            return null;
265
-        }
266
-        $sMetadataFormat = $xPackageConfig->getOption('metadata.format');
267
-        if(!in_array($sMetadataFormat, ['attributes', 'annotations']))
268
-        {
269
-            return null;
270
-        }
257
+private function getComponentMetadata(ReflectionClass $xReflectionClass,
258
+array $aMethods, array $aOptions): Metadata|null
259
+{
260
+/** @var Config|null */
261
+$xPackageConfig = $aOptions['config'] ?? null;
262
+if($xPackageConfig === null || (bool)($aOptions['excluded'] ?? false))
263
+{
264
+return null;
265
+}
266
+$sMetadataFormat = $xPackageConfig->getOption('metadata.format');
267
+if(!in_array($sMetadataFormat, ['attributes', 'annotations']))
268
+{
269
+return null;
270
+}
271 271
 
272
-        // Try to get the class metadata from the cache.
273
-        $di = $this->cn();
274
-        $xMetadata = null;
275
-        $xMetadataCache = null;
276
-        $xConfig = $di->config();
277
-        if($xConfig->getAppOption('metadata.cache.enabled', false))
278
-        {
279
-            if(!$di->h('jaxon_metadata_cache_dir'))
280
-            {
281
-                $sCacheDir = $xConfig->getAppOption('metadata.cache.dir');
282
-                $di->val('jaxon_metadata_cache_dir', $sCacheDir);
283
-            }
284
-            $xMetadataCache = $di->getMetadataCache();
285
-            $xMetadata = $xMetadataCache->read($xReflectionClass->getName());
286
-            if($xMetadata !== null)
287
-            {
288
-                return $xMetadata;
289
-            }
290
-        }
272
+// Try to get the class metadata from the cache.
273
+$di = $this->cn();
274
+$xMetadata = null;
275
+$xMetadataCache = null;
276
+$xConfig = $di->config();
277
+if($xConfig->getAppOption('metadata.cache.enabled', false))
278
+{
279
+if(!$di->h('jaxon_metadata_cache_dir'))
280
+{
281
+    $sCacheDir = $xConfig->getAppOption('metadata.cache.dir');
282
+    $di->val('jaxon_metadata_cache_dir', $sCacheDir);
283
+}
284
+$xMetadataCache = $di->getMetadataCache();
285
+$xMetadata = $xMetadataCache->read($xReflectionClass->getName());
286
+if($xMetadata !== null)
287
+{
288
+    return $xMetadata;
289
+}
290
+}
291 291
 
292
-        $aProperties = array_map(fn($xProperty) => $xProperty->getName(),
293
-            $xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC |
294
-                ReflectionProperty::IS_PROTECTED));
292
+$aProperties = array_map(fn($xProperty) => $xProperty->getName(),
293
+$xReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC |
294
+    ReflectionProperty::IS_PROTECTED));
295 295
 
296
-        $xMetadataReader = $di->getMetadataReader($sMetadataFormat);
297
-        $xInput = new InputData($xReflectionClass, $aMethods, $aProperties);
298
-        $xMetadata = $xMetadataReader->getAttributes($xInput);
296
+$xMetadataReader = $di->getMetadataReader($sMetadataFormat);
297
+$xInput = new InputData($xReflectionClass, $aMethods, $aProperties);
298
+$xMetadata = $xMetadataReader->getAttributes($xInput);
299 299
 
300
-        // Try to save the metadata in the cache
301
-        if($xMetadataCache !== null && $xMetadata !== null)
302
-        {
303
-            $xMetadataCache->save($xReflectionClass->getName(), $xMetadata);
304
-        }
300
+// Try to save the metadata in the cache
301
+if($xMetadataCache !== null && $xMetadata !== null)
302
+{
303
+$xMetadataCache->save($xReflectionClass->getName(), $xMetadata);
304
+}
305 305
 
306
-        return $xMetadata;
307
-    }
306
+return $xMetadata;
307
+}
308 308
 
309
-    /**
309
+/**
310 310
      * @param ReflectionClass $xReflectionClass
311 311
      * @param array $aOptions
312 312
      *
313 313
      * @return ComponentOptions
314 314
      */
315
-    public function getComponentOptions(ReflectionClass $xReflectionClass,
316
-        array $aOptions): ComponentOptions
317
-    {
318
-        $aMethods = $this->getPublicMethods($xReflectionClass);
319
-        $xMetadata = $this->getComponentMetadata($xReflectionClass, $aMethods[0], $aOptions);
315
+public function getComponentOptions(ReflectionClass $xReflectionClass,
316
+array $aOptions): ComponentOptions
317
+{
318
+$aMethods = $this->getPublicMethods($xReflectionClass);
319
+$xMetadata = $this->getComponentMetadata($xReflectionClass, $aMethods[0], $aOptions);
320 320
 
321
-        return new ComponentOptions($aMethods, $aOptions, $xMetadata);
322
-    }
321
+return new ComponentOptions($aMethods, $aOptions, $xMetadata);
322
+}
323 323
 }
Please login to merge, or discard this 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 && $xMetadata !== null)
301
+        if ($xMetadataCache !== null && $xMetadata !== null)
302 302
         {
303 303
             $xMetadataCache->save($xReflectionClass->getName(), $xMetadata);
304 304
         }
Please login to merge, or discard this patch.
jaxon-core/src/App/Metadata/Data/ExportData.php 2 patches
Switch Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -22,53 +22,53 @@
 block discarded – undo
22 22
 
23 23
 class ExportData extends AbstractData
24 24
 {
25
-    /**
25
+/**
26 26
      * @var array<string, array<string>>
27 27
      */
28
-    private array $aMethods = [];
28
+private array $aMethods = [];
29 29
 
30
-    /**
30
+/**
31 31
      * @return string
32 32
      */
33
-    public function getName(): string
34
-    {
35
-        return 'export';
36
-    }
33
+public function getName(): string
34
+{
35
+return 'export';
36
+}
37 37
 
38
-    /**
38
+/**
39 39
      * @return mixed
40 40
      */
41
-    public function getValue(): mixed
42
-    {
43
-        return $this->aMethods;
44
-    }
41
+public function getValue(): mixed
42
+{
43
+return $this->aMethods;
44
+}
45 45
 
46
-    /**
46
+/**
47 47
      * @param array $aMethods
48 48
      *
49 49
      * @return void
50 50
      */
51
-    public function setMethods(array $aMethods): void
51
+public function setMethods(array $aMethods): void
52
+{
53
+foreach(['base', 'only', 'except'] as $sKey)
54
+{
55
+foreach($aMethods[$sKey] ?? [] as $sMethod)
56
+{
57
+    if(!is_string($sMethod) || !$this->validateMethod($sMethod))
52 58
     {
53
-        foreach(['base', 'only', 'except'] as $sKey)
54
-        {
55
-            foreach($aMethods[$sKey] ?? [] as $sMethod)
56
-            {
57
-                if(!is_string($sMethod) || !$this->validateMethod($sMethod))
58
-                {
59
-                    throw new SetupException("'$sMethod' is not a valid method name.");
60
-                }
61
-            }
62
-        }
63
-        $this->aMethods = $aMethods;
59
+        throw new SetupException("'$sMethod' is not a valid method name.");
64 60
     }
61
+}
62
+}
63
+$this->aMethods = $aMethods;
64
+}
65 65
 
66
-    /**
66
+/**
67 67
      * @inheritDoc
68 68
      */
69
-    public function encode(string $sVarName): array
70
-    {
71
-        $sMethods = addslashes(json_encode($this->aMethods));
72
-        return ["{$sVarName}->setMethods(json_decode(\"$sMethods\", true));"];
73
-    }
69
+public function encode(string $sVarName): array
70
+{
71
+$sMethods = addslashes(json_encode($this->aMethods));
72
+return ["{$sVarName}->setMethods(json_decode(\"$sMethods\", true));"];
73
+}
74 74
 }
Please login to merge, or discard this 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-annotations/tests/TestAnnotation/ComponentTest.php 2 patches
Switch Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -16,133 +16,133 @@
 block discarded – undo
16 16
 
17 17
 class ComponentTest extends TestCase
18 18
 {
19
-    use AnnotationTrait;
19
+use AnnotationTrait;
20 20
 
21
-    /**
21
+/**
22 22
      * @var string
23 23
      */
24
-    private $sCacheDir;
24
+private $sCacheDir;
25 25
 
26
-    /**
26
+/**
27 27
      * @throws SetupException
28 28
      */
29
-    public function setUp(): void
30
-    {
31
-        $this->sCacheDir = __DIR__ . '/../tmp';
32
-        @mkdir($this->sCacheDir);
29
+public function setUp(): void
30
+{
31
+$this->sCacheDir = __DIR__ . '/../tmp';
32
+@mkdir($this->sCacheDir);
33 33
 
34
-        jaxon()->di()->getPluginManager()->registerPlugins();
35
-        _register();
34
+jaxon()->di()->getPluginManager()->registerPlugins();
35
+_register();
36 36
 
37
-        jaxon()->di()->val('jaxon_annotations_cache_dir', $this->sCacheDir);
38
-    }
37
+jaxon()->di()->val('jaxon_annotations_cache_dir', $this->sCacheDir);
38
+}
39 39
 
40
-    /**
40
+/**
41 41
      * @throws SetupException
42 42
      */
43
-    public function tearDown(): void
44
-    {
45
-        jaxon()->reset();
46
-        parent::tearDown();
47
-
48
-        // Delete the temp dir and all its content
49
-        $aFiles = scandir($this->sCacheDir);
50
-        foreach ($aFiles as $sFile)
51
-        {
52
-            if($sFile !== '.' && $sFile !== '..')
53
-            {
54
-                @unlink($this->sCacheDir . DIRECTORY_SEPARATOR . $sFile);
55
-            }
56
-        }
57
-        @rmdir($this->sCacheDir);
58
-    }
59
-
60
-    /**
43
+public function tearDown(): void
44
+{
45
+jaxon()->reset();
46
+parent::tearDown();
47
+
48
+// Delete the temp dir and all its content
49
+$aFiles = scandir($this->sCacheDir);
50
+foreach ($aFiles as $sFile)
51
+{
52
+if($sFile !== '.' && $sFile !== '..')
53
+{
54
+    @unlink($this->sCacheDir . DIRECTORY_SEPARATOR . $sFile);
55
+}
56
+}
57
+@rmdir($this->sCacheDir);
58
+}
59
+
60
+/**
61 61
      * @throws SetupException
62 62
      */
63
-    public function testNodeComponentExportMethods()
64
-    {
65
-        $xMetadata = $this->getAttributes(NodeComponent::class,
66
-            ['item', 'html', 'render', 'clear', 'visible'], []);
67
-        $bExcluded = $xMetadata->isExcluded();
68
-        $aExcluded = $xMetadata->getExceptMethods();
69
-        $aBaseMethods = $xMetadata->getExportBaseMethods();
70
-        $aOnlyMethods = $xMetadata->getExportOnlyMethods();
71
-
72
-        $this->assertFalse($bExcluded);
73
-        $this->assertCount(0, $aExcluded);
74
-        $this->assertCount(0, $aBaseMethods);
75
-        $this->assertCount(0, $aOnlyMethods);
76
-    }
77
-
78
-    /**
63
+public function testNodeComponentExportMethods()
64
+{
65
+$xMetadata = $this->getAttributes(NodeComponent::class,
66
+['item', 'html', 'render', 'clear', 'visible'], []);
67
+$bExcluded = $xMetadata->isExcluded();
68
+$aExcluded = $xMetadata->getExceptMethods();
69
+$aBaseMethods = $xMetadata->getExportBaseMethods();
70
+$aOnlyMethods = $xMetadata->getExportOnlyMethods();
71
+
72
+$this->assertFalse($bExcluded);
73
+$this->assertCount(0, $aExcluded);
74
+$this->assertCount(0, $aBaseMethods);
75
+$this->assertCount(0, $aOnlyMethods);
76
+}
77
+
78
+/**
79 79
      * @throws SetupException
80 80
      */
81
-    public function testPageComponentExportMethods()
82
-    {
83
-        $xMetadata = $this->getAttributes(PageComponent::class,
84
-            ['item', 'html', 'render', 'clear', 'visible'], []);
85
-        $bExcluded = $xMetadata->isExcluded();
86
-        $aExcluded = $xMetadata->getExceptMethods();
87
-        $aBaseMethods = $xMetadata->getExportBaseMethods();
88
-        $aOnlyMethods = $xMetadata->getExportOnlyMethods();
89
-
90
-        $this->assertFalse($bExcluded);
91
-        $this->assertCount(0, $aExcluded);
92
-        $this->assertCount(0, $aBaseMethods);
93
-        $this->assertCount(0, $aOnlyMethods);
94
-    }
95
-
96
-    /**
81
+public function testPageComponentExportMethods()
82
+{
83
+$xMetadata = $this->getAttributes(PageComponent::class,
84
+['item', 'html', 'render', 'clear', 'visible'], []);
85
+$bExcluded = $xMetadata->isExcluded();
86
+$aExcluded = $xMetadata->getExceptMethods();
87
+$aBaseMethods = $xMetadata->getExportBaseMethods();
88
+$aOnlyMethods = $xMetadata->getExportOnlyMethods();
89
+
90
+$this->assertFalse($bExcluded);
91
+$this->assertCount(0, $aExcluded);
92
+$this->assertCount(0, $aBaseMethods);
93
+$this->assertCount(0, $aOnlyMethods);
94
+}
95
+
96
+/**
97 97
      * @throws SetupException
98 98
      */
99
-    public function testFuncComponentExportMethods()
100
-    {
101
-        $xMetadata = $this->getAttributes(FuncComponent::class,
102
-            ['paginator'], []);
103
-        $bExcluded = $xMetadata->isExcluded();
104
-        $aExcluded = $xMetadata->getExceptMethods();
105
-        $aBaseMethods = $xMetadata->getExportBaseMethods();
106
-        $aOnlyMethods = $xMetadata->getExportOnlyMethods();
107
-
108
-        $this->assertFalse($bExcluded);
109
-        $this->assertCount(0, $aExcluded);
110
-        $this->assertCount(0, $aBaseMethods);
111
-        $this->assertCount(0, $aOnlyMethods);
112
-    }
113
-
114
-    /**
99
+public function testFuncComponentExportMethods()
100
+{
101
+$xMetadata = $this->getAttributes(FuncComponent::class,
102
+['paginator'], []);
103
+$bExcluded = $xMetadata->isExcluded();
104
+$aExcluded = $xMetadata->getExceptMethods();
105
+$aBaseMethods = $xMetadata->getExportBaseMethods();
106
+$aOnlyMethods = $xMetadata->getExportOnlyMethods();
107
+
108
+$this->assertFalse($bExcluded);
109
+$this->assertCount(0, $aExcluded);
110
+$this->assertCount(0, $aBaseMethods);
111
+$this->assertCount(0, $aOnlyMethods);
112
+}
113
+
114
+/**
115 115
      * @throws SetupException
116 116
      */
117
-    public function testNodeComponentExportBaseMethods()
118
-    {
119
-        // The attribute exports the 'html' and 'render' methods,
120
-        // but only the 'render' method shall be exported.
121
-        $xClass = new ReflectionClass(NodeBaseComponent::class);
122
-        $aMethods = ['item', 'html', 'render', 'clear', 'visible'];
123
-        $xMetadata = $this->getAttributes($xClass, $aMethods, []);
124
-        $aBaseMethods = $xMetadata->getExportBaseMethods();
125
-
126
-        // The 'html' and 'render' methods are returned.
127
-        $this->assertCount(2, $aBaseMethods);
128
-
129
-        $xOptions = $this->getOptions($xClass);
130
-        $aPublicMethods = $xOptions->getPublicMethods();
131
-
132
-        // Only the 'render' method is returned.
133
-        $this->assertCount(1, $aPublicMethods);
134
-        $this->assertEquals('render', $aPublicMethods[0]);
135
-    }
136
-
137
-    // public function testContainerAttributeErrorTwoDi()
138
-    // {
139
-    //     $this->expectException(SetupException::class);
140
-    //     $this->getAttributes(PropertyAttribute::class, [], ['errorTwoDi']);
141
-    // }
142
-
143
-    // public function testContainerAttributeErrorDiClass()
144
-    // {
145
-    //     $this->expectException(SetupException::class);
146
-    //     $this->getAttributes(PropertyAttribute::class, ['errorDiClass']);
147
-    // }
117
+public function testNodeComponentExportBaseMethods()
118
+{
119
+// The attribute exports the 'html' and 'render' methods,
120
+// but only the 'render' method shall be exported.
121
+$xClass = new ReflectionClass(NodeBaseComponent::class);
122
+$aMethods = ['item', 'html', 'render', 'clear', 'visible'];
123
+$xMetadata = $this->getAttributes($xClass, $aMethods, []);
124
+$aBaseMethods = $xMetadata->getExportBaseMethods();
125
+
126
+// The 'html' and 'render' methods are returned.
127
+$this->assertCount(2, $aBaseMethods);
128
+
129
+$xOptions = $this->getOptions($xClass);
130
+$aPublicMethods = $xOptions->getPublicMethods();
131
+
132
+// Only the 'render' method is returned.
133
+$this->assertCount(1, $aPublicMethods);
134
+$this->assertEquals('render', $aPublicMethods[0]);
135
+}
136
+
137
+// public function testContainerAttributeErrorTwoDi()
138
+// {
139
+//     $this->expectException(SetupException::class);
140
+//     $this->getAttributes(PropertyAttribute::class, [], ['errorTwoDi']);
141
+// }
142
+
143
+// public function testContainerAttributeErrorDiClass()
144
+// {
145
+//     $this->expectException(SetupException::class);
146
+//     $this->getAttributes(PropertyAttribute::class, ['errorDiClass']);
147
+// }
148 148
 }
Please login to merge, or discard this 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-annotations/tests/Attr/Ajax/Traits/Annotated.php 1 patch
Switch Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -6,18 +6,18 @@
 block discarded – undo
6 6
 
7 7
 trait Annotated
8 8
 {
9
-    /**
9
+/**
10 10
      * @var \Jaxon\Annotations\Tests\Service\ColorService
11 11
      */
12
-    protected $colorService;
12
+protected $colorService;
13 13
 
14
-    /**
14
+/**
15 15
      * @var TextService
16 16
      */
17
-    protected $textService;
17
+protected $textService;
18 18
 
19
-    /**
19
+/**
20 20
      * @var FontService
21 21
      */
22
-    protected $fontService;
22
+protected $fontService;
23 23
 }
Please login to merge, or discard this patch.
jaxon-annotations/tests/Attr/Ajax/ClassAnnotated.php 1 patch
Switch Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,18 +21,18 @@
 block discarded – undo
21 21
  */
22 22
 class ClassAnnotated extends FuncComponent
23 23
 {
24
-    /**
24
+/**
25 25
      * @var \Jaxon\Annotations\Tests\Service\ColorService
26 26
      */
27
-    protected $colorService;
27
+protected $colorService;
28 28
 
29
-    /**
29
+/**
30 30
      * @var TextService
31 31
      */
32
-    protected $textService;
32
+protected $textService;
33 33
 
34
-    /**
34
+/**
35 35
      * @var FontService
36 36
      */
37
-    protected $fontService;
37
+protected $fontService;
38 38
 }
Please login to merge, or discard this patch.
jaxon-annotations/tests/Attr/Ajax/DocBlockClassExcluded.php 1 patch
Switch Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -9,26 +9,26 @@
 block discarded – undo
9 9
  */
10 10
 class DocBlockClassExcluded extends FuncComponent
11 11
 {
12
-    /**
12
+/**
13 13
      * @exclude
14 14
      */
15
-    public function doNot()
16
-    {
17
-    }
15
+public function doNot()
16
+{
17
+}
18 18
 
19
-    /**
19
+/**
20 20
      * @databag user.name
21 21
      * @databag page.number
22 22
      */
23
-    public function withBags()
24
-    {
25
-    }
23
+public function withBags()
24
+{
25
+}
26 26
 
27
-    /**
27
+/**
28 28
      * @before funcBefore
29 29
      * @after funcAfter
30 30
      */
31
-    public function cbSingle()
32
-    {
33
-    }
31
+public function cbSingle()
32
+{
33
+}
34 34
 }
Please login to merge, or discard this patch.
jaxon-annotations/tests/Attr/Ajax/ExtendAnnotated.php 1 patch
Switch Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -7,176 +7,176 @@
 block discarded – undo
7 7
 
8 8
 class ExtendAnnotated extends FuncComponent
9 9
 {
10
-    /**
10
+/**
11 11
      * @exclude
12 12
      */
13
-    public function doNot()
14
-    {
15
-    }
13
+public function doNot()
14
+{
15
+}
16 16
 
17
-    /**
17
+/**
18 18
      * @exclude(true)
19 19
      */
20
-    public function doNotBool()
21
-    {
22
-    }
20
+public function doNotBool()
21
+{
22
+}
23 23
 
24
-    /**
24
+/**
25 25
      * @exclude('Me')
26 26
      */
27
-    public function doNotError()
28
-    {
29
-    }
27
+public function doNotError()
28
+{
29
+}
30 30
 
31
-    /**
31
+/**
32 32
      * @databag('name' => 'user.name')
33 33
      * @databag('name' => 'page.number')
34 34
      */
35
-    public function withBags()
36
-    {
37
-    }
35
+public function withBags()
36
+{
37
+}
38 38
 
39
-    /**
39
+/**
40 40
      * @databag('mane' => 'user.name')
41 41
      * @databag('mane' => 'page.number')
42 42
      */
43
-    public function withBagsError()
44
-    {
45
-    }
43
+public function withBagsError()
44
+{
45
+}
46 46
 
47
-    /**
47
+/**
48 48
      * @upload('field' => 'user-files')
49 49
      */
50
-    public function saveFiles()
51
-    {
52
-    }
50
+public function saveFiles()
51
+{
52
+}
53 53
 
54
-    /**
54
+/**
55 55
      * @upload('name' => 'user-files')
56 56
      */
57
-    public function saveFilesWrongName()
58
-    {
59
-    }
57
+public function saveFilesWrongName()
58
+{
59
+}
60 60
 
61
-    /**
61
+/**
62 62
      * @upload('field' => 'user-file1')
63 63
      * @upload('field' => 'user-file2')
64 64
      */
65
-    public function saveFilesMultiple()
66
-    {
67
-    }
65
+public function saveFilesMultiple()
66
+{
67
+}
68 68
 
69
-    /**
69
+/**
70 70
      * @before('call' => 'funcBefore')
71 71
      * @after('call' => 'funcAfter')
72 72
      */
73
-    public function cbSingle()
74
-    {
75
-    }
73
+public function cbSingle()
74
+{
75
+}
76 76
 
77
-    /**
77
+/**
78 78
      * @before('call' => 'funcBefore1')
79 79
      * @before('call' => 'funcBefore2')
80 80
      * @after('call' => 'funcAfter1')
81 81
      * @after('call' => 'funcAfter2')
82 82
      * @after('call' => 'funcAfter3')
83 83
      */
84
-    public function cbMultiple()
85
-    {
86
-    }
84
+public function cbMultiple()
85
+{
86
+}
87 87
 
88
-    /**
88
+/**
89 89
      * @before('call' => 'funcBefore1', 'with' => ['param1'])
90 90
      * @before('call' => 'funcBefore2', 'with' => ['param1', 'param2'])
91 91
      * @after('call' => 'funcAfter1', 'with' => ['param1', 'param2'])
92 92
      */
93
-    public function cbParams()
94
-    {
95
-    }
93
+public function cbParams()
94
+{
95
+}
96 96
 
97
-    /**
97
+/**
98 98
      * @di('attr' => 'colorService', 'class' => 'ColorService')
99 99
      * @di('attr' => 'fontService', 'class' => 'FontService')
100 100
      */
101
-    public function di1()
102
-    {
103
-    }
101
+public function di1()
102
+{
103
+}
104 104
 
105
-    /**
105
+/**
106 106
      * @di('attr' => 'colorService', 'class' => 'ColorService')
107 107
      * @di('attr' => 'textService', 'class' => '\Jaxon\Annotations\Tests\Service\TextService')
108 108
      */
109
-    public function di2()
110
-    {
111
-    }
109
+public function di2()
110
+{
111
+}
112 112
 
113
-    /**
113
+/**
114 114
      * @before('name' => 'funcBefore', 'with' => ['param1'])
115 115
      */
116
-    public function cbBeforeNoCall()
117
-    {
118
-    }
116
+public function cbBeforeNoCall()
117
+{
118
+}
119 119
 
120
-    /**
120
+/**
121 121
      * @before('call' => 'funcBefore', 'params' => ['param1'])
122 122
      */
123
-    public function cbBeforeUnknownAttr()
124
-    {
125
-    }
123
+public function cbBeforeUnknownAttr()
124
+{
125
+}
126 126
 
127
-    /**
127
+/**
128 128
      * @before('call' => 'funcBefore', 'with' => 'param1')
129 129
      */
130
-    public function cbBeforeWrongAttrType()
131
-    {
132
-    }
130
+public function cbBeforeWrongAttrType()
131
+{
132
+}
133 133
 
134
-    /**
134
+/**
135 135
      * @after('name' => 'funcAfter', 'with' => ['param1'])
136 136
      */
137
-    public function cbAfterNoCall()
138
-    {
139
-    }
137
+public function cbAfterNoCall()
138
+{
139
+}
140 140
 
141
-    /**
141
+/**
142 142
      * @after('call' => 'funcAfter', 'params' => ['param1'])
143 143
      */
144
-    public function cbAfterUnknownAttr()
145
-    {
146
-    }
144
+public function cbAfterUnknownAttr()
145
+{
146
+}
147 147
 
148
-    /**
148
+/**
149 149
      * @after('call' => 'funcAfter', 'with' => true)
150 150
      */
151
-    public function cbAfterWrongAttrType()
152
-    {
153
-    }
151
+public function cbAfterWrongAttrType()
152
+{
153
+}
154 154
 
155
-    /**
155
+/**
156 156
      * @di('attr' => 'attr', 'params' => '')
157 157
      */
158
-    public function diUnknownAttr()
159
-    {
160
-    }
158
+public function diUnknownAttr()
159
+{
160
+}
161 161
 
162
-    /**
162
+/**
163 163
      * @di('attr' => [], 'class' => 'ClassName')
164 164
      */
165
-    public function diWrongAttrType()
166
-    {
167
-    }
165
+public function diWrongAttrType()
166
+{
167
+}
168 168
 
169
-    /**
169
+/**
170 170
      * @di('attr' => 'attr', 'class' => true)
171 171
      */
172
-    public function diWrongClassType()
173
-    {
174
-    }
172
+public function diWrongClassType()
173
+{
174
+}
175 175
 
176
-    /**
176
+/**
177 177
      * @di('attr' => 'attr', 'class' => 'ClassName', 'name' => 'di')
178 178
      */
179
-    public function diWrongVarCount()
180
-    {
181
-    }
179
+public function diWrongVarCount()
180
+{
181
+}
182 182
 }
Please login to merge, or discard this patch.