Passed
Push — main ( 87fed9...27211a )
by Thierry
04:04
created
jaxon-attributes/src/register.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
 function register(): void
31 31
 {
32 32
     // Do nothing if running in cli.
33
-    if(php_sapi_name() !== 'cli')
33
+    if (php_sapi_name() !== 'cli')
34 34
     {
35 35
         _register();
36 36
     };
Please login to merge, or discard this patch.
jaxon-attributes/src/AttributeReader.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -258,8 +258,7 @@
 block discarded – undo
258 258
             }
259 259
 
260 260
             return $this->xMetadata;
261
-        }
262
-        catch(Exception|Error $e)
261
+        } catch(Exception|Error $e)
263 262
         {
264 263
             throw new SetupException($e->getMessage());
265 264
         }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -21 removed lines patch added patch discarded remove patch
@@ -69,19 +69,19 @@  discard block
 block discarded – undo
69 69
     private function readTypes(ReflectionClass $xClass)
70 70
     {
71 71
         $sClass = $xClass->getName();
72
-        if(isset($this->aTypes[$sClass]))
72
+        if (isset($this->aTypes[$sClass]))
73 73
         {
74 74
             return;
75 75
         }
76 76
 
77 77
         $this->aTypes[$sClass] = [];
78
-        $aProperties = $xClass->getProperties(ReflectionProperty::IS_PUBLIC |
78
+        $aProperties = $xClass->getProperties(ReflectionProperty::IS_PUBLIC|
79 79
             ReflectionProperty::IS_PROTECTED);
80
-        foreach($aProperties as $xReflectionProperty)
80
+        foreach ($aProperties as $xReflectionProperty)
81 81
         {
82 82
             $xType = $xReflectionProperty->getType();
83 83
             // Check that the property has a valid type defined
84
-            if(is_a($xType, ReflectionNamedType::class) &&
84
+            if (is_a($xType, ReflectionNamedType::class) &&
85 85
                 ($sType = $xType->getName()) !== '')
86 86
             {
87 87
                 $this->aTypes[$sClass][$xReflectionProperty->getName()] = $sType;
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     private function initAttribute(AbstractAttribute $xAttribute,
100 100
         ReflectionClass $xClass, ReflectionAttribute $xReflectionAttribute): void
101 101
     {
102
-        if(is_a($xAttribute, InjectAttribute::class))
102
+        if (is_a($xAttribute, InjectAttribute::class))
103 103
         {
104 104
             $this->readTypes($xClass);
105 105
             $xAttribute->setTarget($xReflectionAttribute->getTarget());
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
         $aClassAttributes = $xClass->getAttributes();
118 118
         $aAttributes = array_filter($aClassAttributes, fn($xAttribute) =>
119 119
             is_a($xAttribute->getName(), ExcludeAttribute::class, true));
120
-        foreach($aAttributes as $xReflectionAttribute)
120
+        foreach ($aAttributes as $xReflectionAttribute)
121 121
         {
122 122
             $xReflectionAttribute->newInstance()->saveValue($this->xMetadata);
123 123
         }
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
         $aClassAttributes = $xClass->getAttributes();
136 136
         $aAttributes = array_filter($aClassAttributes, fn($xAttribute) =>
137 137
             is_a($xAttribute->getName(), ExportAttribute::class, true));
138
-        foreach($aAttributes as $xReflectionAttribute)
138
+        foreach ($aAttributes as $xReflectionAttribute)
139 139
         {
140 140
             $xReflectionAttribute->newInstance()->saveValue($this->xMetadata);
141 141
         }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
             is_a($xAttribute->getName(), AbstractAttribute::class, true) &&
154 154
             !is_a($xAttribute->getName(), ExcludeAttribute::class, true) &&
155 155
             !is_a($xAttribute->getName(), ExportAttribute::class, true));
156
-        foreach($aAttributes as $xReflectionAttribute)
156
+        foreach ($aAttributes as $xReflectionAttribute)
157 157
         {
158 158
             $xAttribute = $xReflectionAttribute->newInstance();
159 159
             $this->initAttribute($xAttribute, $xClass, $xReflectionAttribute);
@@ -172,16 +172,15 @@  discard block
 block discarded – undo
172 172
     private function getPropertyAttrs(ReflectionClass $xClass, string $sProperty): void
173 173
     {
174 174
         // Only Inject attributes are allowed on properties
175
-        $aAttributes = !$xClass->hasProperty($sProperty) ? [] :
176
-            $xClass->getProperty($sProperty)->getAttributes();
175
+        $aAttributes = !$xClass->hasProperty($sProperty) ? [] : $xClass->getProperty($sProperty)->getAttributes();
177 176
         $aAttributes = array_filter($aAttributes, fn($xAttribute) =>
178 177
             is_a($xAttribute->getName(), InjectAttribute::class, true));
179
-        if(count($aAttributes) > 1)
178
+        if (count($aAttributes) > 1)
180 179
         {
181 180
             throw new SetupException('Only one Inject attribute is allowed on a property');
182 181
         }
183 182
 
184
-        foreach($aAttributes as $xReflectionAttribute)
183
+        foreach ($aAttributes as $xReflectionAttribute)
185 184
         {
186 185
             /** @var InjectAttribute */
187 186
             $xAttribute = $xReflectionAttribute->newInstance();
@@ -200,11 +199,10 @@  discard block
 block discarded – undo
200 199
      */
201 200
     private function getMethodAttrs(ReflectionClass $xClass, string $sMethod): void
202 201
     {
203
-        $aAttributes = !$xClass->hasMethod($sMethod) ? [] :
204
-            $xClass->getMethod($sMethod)->getAttributes();
202
+        $aAttributes = !$xClass->hasMethod($sMethod) ? [] : $xClass->getMethod($sMethod)->getAttributes();
205 203
         $aAttributes = array_filter($aAttributes, fn($xAttribute) =>
206 204
             is_a($xAttribute->getName(), AbstractAttribute::class, true));
207
-        foreach($aAttributes as $xReflectionAttribute)
205
+        foreach ($aAttributes as $xReflectionAttribute)
208 206
         {
209 207
             $xAttribute = $xReflectionAttribute->newInstance();
210 208
             $this->initAttribute($xAttribute, $xClass, $xReflectionAttribute);
@@ -238,7 +236,7 @@  discard block
 block discarded – undo
238 236
             $xClass = $xInput->getReflectionClass();
239 237
             // First check if the class is exluded.
240 238
             $this->getClassExcludeAttr($xClass);
241
-            if($this->xMetadata->isExcluded())
239
+            if ($this->xMetadata->isExcluded())
242 240
             {
243 241
                 return $this->xMetadata;
244 242
             }
@@ -247,25 +245,25 @@  discard block
 block discarded – undo
247 245
             $this->getBaseClassAttrs($xClass);
248 246
 
249 247
             $aClasses = [$xClass];
250
-            while(($xClass = $this->getParentClass($xClass)) !== null)
248
+            while (($xClass = $this->getParentClass($xClass)) !== null)
251 249
             {
252 250
                 $aClasses[] = $xClass;
253 251
             }
254 252
             $aClasses = array_reverse($aClasses);
255 253
 
256
-            foreach($aClasses as $xClass)
254
+            foreach ($aClasses as $xClass)
257 255
             {
258 256
                 // Processing class attributes
259 257
                 $this->getClassAttrs($xClass);
260 258
 
261 259
                 // Processing properties attributes
262
-                foreach($xInput->getProperties() as $sProperty)
260
+                foreach ($xInput->getProperties() as $sProperty)
263 261
                 {
264 262
                     $this->getPropertyAttrs($xClass, $sProperty);
265 263
                 }
266 264
 
267 265
                 // Processing methods attributes
268
-                foreach($xInput->getMethods() as $sMethod)
266
+                foreach ($xInput->getMethods() as $sMethod)
269 267
                 {
270 268
                     $this->getMethodAttrs($xClass, $sMethod);
271 269
                 }
@@ -273,7 +271,7 @@  discard block
 block discarded – undo
273 271
 
274 272
             return $this->xMetadata;
275 273
         }
276
-        catch(Exception|Error $e)
274
+        catch (Exception|Error $e)
277 275
         {
278 276
             throw new SetupException($e->getMessage());
279 277
         }
Please login to merge, or discard this patch.
jaxon-attributes/src/Attribute/Before.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 Before extends AbstractAttribute
23 23
 {
24 24
     /**
Please login to merge, or discard this patch.
jaxon-attributes/src/Attribute/Callback.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 Callback extends AbstractAttribute
23 23
 {
24 24
     /**
Please login to merge, or discard this patch.
jaxon-attributes/src/Attribute/Inject.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
 use function ltrim;
23 23
 
24
-#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_PROPERTY | Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
24
+#[Attribute(Attribute::TARGET_CLASS|Attribute::TARGET_PROPERTY|Attribute::TARGET_METHOD|Attribute::IS_REPEATABLE)]
25 25
 class Inject extends AbstractAttribute
26 26
 {
27 27
     /**
@@ -92,17 +92,17 @@  discard block
 block discarded – undo
92 92
      */
93 93
     public function validate(): void
94 94
     {
95
-        if($this->nTarget === Attribute::TARGET_CLASS)
95
+        if ($this->nTarget === Attribute::TARGET_CLASS)
96 96
         {
97
-            if(!$this->attr || !$this->type)
97
+            if (!$this->attr || !$this->type)
98 98
             {
99 99
                 throw new SetupException('When applied to a class, the Inject attribute requires two arguments.');
100 100
             }
101 101
             return;
102 102
         }
103
-        if($this->nTarget === Attribute::TARGET_METHOD)
103
+        if ($this->nTarget === Attribute::TARGET_METHOD)
104 104
         {
105
-            if(!$this->attr)
105
+            if (!$this->attr)
106 106
             {
107 107
                 throw new SetupException('When applied to a method, the Inject attribute requires the "attr" argument.');
108 108
             }
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
      */
116 116
     private function getFullClassName(): void
117 117
     {
118
-        if(!$this->type)
118
+        if (!$this->type)
119 119
         {
120 120
             // If no type is provided, take the attribute type.
121 121
             $this->type = $this->aTypes[$this->attr] ?? '';
122 122
             return;
123 123
         }
124
-        if($this->type[0] === '\\')
124
+        if ($this->type[0] === '\\')
125 125
         {
126 126
             $this->type = ltrim($this->type, '\\');
127 127
         }
Please login to merge, or discard this patch.
jaxon-attributes/src/Attribute/Exclude.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)]
21
+#[Attribute(Attribute::TARGET_CLASS|Attribute::TARGET_METHOD)]
22 22
 class Exclude extends AbstractAttribute
23 23
 {
24 24
     /**
Please login to merge, or discard this patch.
jaxon-attributes/src/Attribute/After.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 After extends AbstractAttribute
23 23
 {
24 24
     /**
Please login to merge, or discard this patch.
jaxon-core/tests/src/session.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@
 block discarded – undo
95 95
      */
96 96
     public function delete(string $sKey): void
97 97
     {
98
-        if(isset($_SESSION[$sKey]))
98
+        if (isset($_SESSION[$sKey]))
99 99
         {
100 100
             unset($_SESSION[$sKey]);
101 101
         }
Please login to merge, or discard this patch.
jaxon-core/tests/src/response/TestHk.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
 
68 68
     public function param($param)
69 69
     {
70
-        if($this->method === 'param' && $this->args[0] === $param)
70
+        if ($this->method === 'param' && $this->args[0] === $param)
71 71
         {
72 72
             $this->response->html('div-id', 'This is the method with params!');
73 73
         }
Please login to merge, or discard this patch.