Passed
Push — main ( ca0571...5ee2f7 )
by Thierry
03:43
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   +18 added lines, -20 removed lines patch added patch discarded remove patch
@@ -68,19 +68,19 @@  discard block
 block discarded – undo
68 68
     private function readTypes(ReflectionClass $xClass)
69 69
     {
70 70
         $sClass = $xClass->getName();
71
-        if(isset($this->aTypes[$sClass]))
71
+        if (isset($this->aTypes[$sClass]))
72 72
         {
73 73
             return;
74 74
         }
75 75
 
76 76
         $this->aTypes[$sClass] = [];
77
-        $aProperties = $xClass->getProperties(ReflectionProperty::IS_PUBLIC |
77
+        $aProperties = $xClass->getProperties(ReflectionProperty::IS_PUBLIC|
78 78
             ReflectionProperty::IS_PROTECTED);
79
-        foreach($aProperties as $xReflectionProperty)
79
+        foreach ($aProperties as $xReflectionProperty)
80 80
         {
81 81
             $xType = $xReflectionProperty->getType();
82 82
             // Check that the property has a valid type defined
83
-            if(is_a($xType, ReflectionNamedType::class) &&
83
+            if (is_a($xType, ReflectionNamedType::class) &&
84 84
                 ($sType = $xType->getName()) !== '')
85 85
             {
86 86
                 $this->aTypes[$sClass][$xReflectionProperty->getName()] = $sType;
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     private function initAttribute(AbstractAttribute $xAttribute,
99 99
         ReflectionClass $xClass, ReflectionAttribute $xReflectionAttribute): void
100 100
     {
101
-        if(is_a($xAttribute, InjectAttribute::class))
101
+        if (is_a($xAttribute, InjectAttribute::class))
102 102
         {
103 103
             $this->readTypes($xClass);
104 104
             $xAttribute->setTarget($xReflectionAttribute->getTarget());
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
         $aClassAttributes = $xClass->getAttributes();
117 117
         $aAttributes = array_filter($aClassAttributes, fn($xAttribute) =>
118 118
             is_a($xAttribute->getName(), ExcludeAttribute::class, true));
119
-        foreach($aAttributes as $xReflectionAttribute)
119
+        foreach ($aAttributes as $xReflectionAttribute)
120 120
         {
121 121
             $xReflectionAttribute->newInstance()->saveValue($this->xMetadata);
122 122
         }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
         $aAttributes = array_filter($aClassAttributes, fn($xAttribute) =>
134 134
             is_a($xAttribute->getName(), AbstractAttribute::class, true) &&
135 135
             !is_a($xAttribute->getName(), ExcludeAttribute::class, true));
136
-        foreach($aAttributes as $xReflectionAttribute)
136
+        foreach ($aAttributes as $xReflectionAttribute)
137 137
         {
138 138
             $xAttribute = $xReflectionAttribute->newInstance();
139 139
             $this->initAttribute($xAttribute, $xClass, $xReflectionAttribute);
@@ -152,16 +152,15 @@  discard block
 block discarded – undo
152 152
     private function getPropertyAttrs(ReflectionClass $xClass, string $sProperty): void
153 153
     {
154 154
         // Only Inject attributes are allowed on properties
155
-        $aAttributes = !$xClass->hasProperty($sProperty) ? [] :
156
-            $xClass->getProperty($sProperty)->getAttributes();
155
+        $aAttributes = !$xClass->hasProperty($sProperty) ? [] : $xClass->getProperty($sProperty)->getAttributes();
157 156
         $aAttributes = array_filter($aAttributes, fn($xAttribute) =>
158 157
             is_a($xAttribute->getName(), InjectAttribute::class, true));
159
-        if(count($aAttributes) > 1)
158
+        if (count($aAttributes) > 1)
160 159
         {
161 160
             throw new SetupException('Only one Inject attribute is allowed on a property');
162 161
         }
163 162
 
164
-        foreach($aAttributes as $xReflectionAttribute)
163
+        foreach ($aAttributes as $xReflectionAttribute)
165 164
         {
166 165
             /** @var InjectAttribute */
167 166
             $xAttribute = $xReflectionAttribute->newInstance();
@@ -180,11 +179,10 @@  discard block
 block discarded – undo
180 179
      */
181 180
     private function getMethodAttrs(ReflectionClass $xClass, string $sMethod): void
182 181
     {
183
-        $aAttributes = !$xClass->hasMethod($sMethod) ? [] :
184
-            $xClass->getMethod($sMethod)->getAttributes();
182
+        $aAttributes = !$xClass->hasMethod($sMethod) ? [] : $xClass->getMethod($sMethod)->getAttributes();
185 183
         $aAttributes = array_filter($aAttributes, fn($xAttribute) =>
186 184
             is_a($xAttribute->getName(), AbstractAttribute::class, true));
187
-        foreach($aAttributes as $xReflectionAttribute)
185
+        foreach ($aAttributes as $xReflectionAttribute)
188 186
         {
189 187
             $xAttribute = $xReflectionAttribute->newInstance();
190 188
             $this->initAttribute($xAttribute, $xClass, $xReflectionAttribute);
@@ -219,31 +217,31 @@  discard block
 block discarded – undo
219 217
             $xClass = $xInput->getReflectionClass();
220 218
             // First check if the class is exluded.
221 219
             $this->getClassExcludeAttr($xClass);
222
-            if($this->xMetadata->isExcluded())
220
+            if ($this->xMetadata->isExcluded())
223 221
             {
224 222
                 return $this->xMetadata;
225 223
             }
226 224
 
227 225
             $aClasses = [$xClass];
228
-            while(($xClass = $this->getParentClass($xClass)) !== null)
226
+            while (($xClass = $this->getParentClass($xClass)) !== null)
229 227
             {
230 228
                 $aClasses[] = $xClass;
231 229
             }
232 230
             $aClasses = array_reverse($aClasses);
233 231
 
234
-            foreach($aClasses as $xClass)
232
+            foreach ($aClasses as $xClass)
235 233
             {
236 234
                 // Processing class attributes
237 235
                 $this->getClassAttrs($xClass);
238 236
 
239 237
                 // Processing properties attributes
240
-                foreach($xInput->getProperties() as $sProperty)
238
+                foreach ($xInput->getProperties() as $sProperty)
241 239
                 {
242 240
                     $this->getPropertyAttrs($xClass, $sProperty);
243 241
                 }
244 242
 
245 243
                 // Processing methods attributes
246
-                foreach($xInput->getMethods() as $sMethod)
244
+                foreach ($xInput->getMethods() as $sMethod)
247 245
                 {
248 246
                     $this->getMethodAttrs($xClass, $sMethod);
249 247
                 }
@@ -251,7 +249,7 @@  discard block
 block discarded – undo
251 249
 
252 250
             return $this->xMetadata;
253 251
         }
254
-        catch(Exception|Error $e)
252
+        catch (Exception|Error $e)
255 253
         {
256 254
             throw new SetupException($e->getMessage());
257 255
         }
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.