Passed
Push — master ( b80013...a46921 )
by butschster
06:18 queued 12s
created
src/Attributes/tests/Reader/Fixture/AnnotatedTrait.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,6 +15,6 @@
 block discarded – undo
15 15
 
16 16
 /** @ClassAnnotation(field="value") */
17 17
 #[ClassAnnotation(field: 'value')]
18
-trait AnnotatedTrait {
18
+trait AnnotatedTrait{
19 19
 
20 20
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,6 +15,7 @@
 block discarded – undo
15 15
 
16 16
 /** @ClassAnnotation(field="value") */
17 17
 #[ClassAnnotation(field: 'value')]
18
-trait AnnotatedTrait {
18
+trait AnnotatedTrait
19
+{
19 20
 
20 21
 }
Please login to merge, or discard this patch.
src/Attributes/tests/Reader/ReaderTestCase.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
     {
78 78
         parent::setUpBeforeClass();
79 79
 
80
-        require_once __DIR__ . '/Fixture/function.php';
81
-        require_once __DIR__ . '/Fixture/UndefinedMeta.php';
80
+        require_once __DIR__.'/Fixture/function.php';
81
+        require_once __DIR__.'/Fixture/UndefinedMeta.php';
82 82
     }
83 83
 
84 84
     /**
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      */
88 88
     protected function fixture(string $suffix): string
89 89
     {
90
-        return '\\Spiral\\Tests\\Attributes\\Reader\\Fixture\\' . \trim($suffix, '\\');
90
+        return '\\Spiral\\Tests\\Attributes\\Reader\\Fixture\\'.\trim($suffix, '\\');
91 91
     }
92 92
 
93 93
     public function testClassMetadataCount(): void
@@ -107,15 +107,15 @@  discard block
 block discarded – undo
107 107
             'field' => 'value'
108 108
         ]);
109 109
 
110
-        if ($this->classMetadataCount === 0) {
110
+        if ($this->classMetadataCount === 0){
111 111
             $this->expectNotToPerformAssertions();
112 112
         }
113 113
 
114
-        foreach ($this->getClassMetadata(AnnotatedClass::class) as $actual) {
114
+        foreach ($this->getClassMetadata(AnnotatedClass::class) as $actual){
115 115
             $this->assertEquals($expected, $actual);
116 116
         }
117 117
 
118
-        foreach ($this->getClassMetadata(ClassWithAnnotatedTrait::class) as $actual) {
118
+        foreach ($this->getClassMetadata(ClassWithAnnotatedTrait::class) as $actual){
119 119
             $this->assertEquals($expected, $actual);
120 120
         }
121 121
     }
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
             'field' => 'value'
134 134
         ]);
135 135
 
136
-        if ($this->constantMetadataCount === 0) {
136
+        if ($this->constantMetadataCount === 0){
137 137
             $this->expectNotToPerformAssertions();
138 138
         }
139 139
 
140
-        foreach ($this->getConstantMetadata(AnnotatedClass::class, 'CONSTANT') as $actual) {
140
+        foreach ($this->getConstantMetadata(AnnotatedClass::class, 'CONSTANT') as $actual){
141 141
             $this->assertEquals($expected, $actual);
142 142
         }
143 143
     }
@@ -155,11 +155,11 @@  discard block
 block discarded – undo
155 155
             'field' => 'value'
156 156
         ]);
157 157
 
158
-        if ($this->propertyMetadataCount === 0) {
158
+        if ($this->propertyMetadataCount === 0){
159 159
             $this->expectNotToPerformAssertions();
160 160
         }
161 161
 
162
-        foreach ($this->getPropertyMetadata(AnnotatedClass::class, 'property') as $actual) {
162
+        foreach ($this->getPropertyMetadata(AnnotatedClass::class, 'property') as $actual){
163 163
             $this->assertEquals($expected, $actual);
164 164
         }
165 165
     }
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
             'field' => 'value'
178 178
         ]);
179 179
 
180
-        if ($this->methodMetadataCount === 0) {
180
+        if ($this->methodMetadataCount === 0){
181 181
             $this->expectNotToPerformAssertions();
182 182
         }
183 183
 
184
-        foreach ($this->getMethodMetadata(AnnotatedClass::class, 'method') as $actual) {
184
+        foreach ($this->getMethodMetadata(AnnotatedClass::class, 'method') as $actual){
185 185
             $this->assertEquals($expected, $actual);
186 186
         }
187 187
     }
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
             'field' => 'value'
200 200
         ]);
201 201
 
202
-        if ($this->methodParameterMetadataCount === 0) {
202
+        if ($this->methodParameterMetadataCount === 0){
203 203
             $this->expectNotToPerformAssertions();
204 204
         }
205 205
 
206
-        foreach ($this->getMethodParameterMetadata(AnnotatedClass::class, 'method', 'parameter') as $actual) {
206
+        foreach ($this->getMethodParameterMetadata(AnnotatedClass::class, 'method', 'parameter') as $actual){
207 207
             $this->assertEquals($expected, $actual);
208 208
         }
209 209
     }
@@ -221,11 +221,11 @@  discard block
 block discarded – undo
221 221
             'field' => 'value'
222 222
         ]);
223 223
 
224
-        if ($this->functionMetadataCount === 0) {
224
+        if ($this->functionMetadataCount === 0){
225 225
             $this->expectNotToPerformAssertions();
226 226
         }
227 227
 
228
-        foreach ($this->getFunctionMetadata($this->fixture('annotated_function')) as $actual) {
228
+        foreach ($this->getFunctionMetadata($this->fixture('annotated_function')) as $actual){
229 229
             $this->assertEquals($expected, $actual);
230 230
         }
231 231
     }
@@ -243,12 +243,12 @@  discard block
 block discarded – undo
243 243
             'field' => 'value'
244 244
         ]);
245 245
 
246
-        if ($this->functionParameterMetadataCount === 0) {
246
+        if ($this->functionParameterMetadataCount === 0){
247 247
             $this->expectNotToPerformAssertions();
248 248
         }
249 249
 
250 250
         $function = $this->fixture('annotated_function');
251
-        foreach ($this->getFunctionParameterMetadata($function, 'parameter') as $actual) {
251
+        foreach ($this->getFunctionParameterMetadata($function, 'parameter') as $actual){
252 252
             $this->assertEquals($expected, $actual);
253 253
         }
254 254
     }
Please login to merge, or discard this patch.
Braces   +30 added lines, -15 removed lines patch added patch discarded remove patch
@@ -107,15 +107,18 @@  discard block
 block discarded – undo
107 107
             'field' => 'value'
108 108
         ]);
109 109
 
110
-        if ($this->classMetadataCount === 0) {
110
+        if ($this->classMetadataCount === 0)
111
+        {
111 112
             $this->expectNotToPerformAssertions();
112 113
         }
113 114
 
114
-        foreach ($this->getClassMetadata(AnnotatedClass::class) as $actual) {
115
+        foreach ($this->getClassMetadata(AnnotatedClass::class) as $actual)
116
+        {
115 117
             $this->assertEquals($expected, $actual);
116 118
         }
117 119
 
118
-        foreach ($this->getClassMetadata(ClassWithAnnotatedTrait::class) as $actual) {
120
+        foreach ($this->getClassMetadata(ClassWithAnnotatedTrait::class) as $actual)
121
+        {
119 122
             $this->assertEquals($expected, $actual);
120 123
         }
121 124
     }
@@ -133,11 +136,13 @@  discard block
 block discarded – undo
133 136
             'field' => 'value'
134 137
         ]);
135 138
 
136
-        if ($this->constantMetadataCount === 0) {
139
+        if ($this->constantMetadataCount === 0)
140
+        {
137 141
             $this->expectNotToPerformAssertions();
138 142
         }
139 143
 
140
-        foreach ($this->getConstantMetadata(AnnotatedClass::class, 'CONSTANT') as $actual) {
144
+        foreach ($this->getConstantMetadata(AnnotatedClass::class, 'CONSTANT') as $actual)
145
+        {
141 146
             $this->assertEquals($expected, $actual);
142 147
         }
143 148
     }
@@ -155,11 +160,13 @@  discard block
 block discarded – undo
155 160
             'field' => 'value'
156 161
         ]);
157 162
 
158
-        if ($this->propertyMetadataCount === 0) {
163
+        if ($this->propertyMetadataCount === 0)
164
+        {
159 165
             $this->expectNotToPerformAssertions();
160 166
         }
161 167
 
162
-        foreach ($this->getPropertyMetadata(AnnotatedClass::class, 'property') as $actual) {
168
+        foreach ($this->getPropertyMetadata(AnnotatedClass::class, 'property') as $actual)
169
+        {
163 170
             $this->assertEquals($expected, $actual);
164 171
         }
165 172
     }
@@ -177,11 +184,13 @@  discard block
 block discarded – undo
177 184
             'field' => 'value'
178 185
         ]);
179 186
 
180
-        if ($this->methodMetadataCount === 0) {
187
+        if ($this->methodMetadataCount === 0)
188
+        {
181 189
             $this->expectNotToPerformAssertions();
182 190
         }
183 191
 
184
-        foreach ($this->getMethodMetadata(AnnotatedClass::class, 'method') as $actual) {
192
+        foreach ($this->getMethodMetadata(AnnotatedClass::class, 'method') as $actual)
193
+        {
185 194
             $this->assertEquals($expected, $actual);
186 195
         }
187 196
     }
@@ -199,11 +208,13 @@  discard block
 block discarded – undo
199 208
             'field' => 'value'
200 209
         ]);
201 210
 
202
-        if ($this->methodParameterMetadataCount === 0) {
211
+        if ($this->methodParameterMetadataCount === 0)
212
+        {
203 213
             $this->expectNotToPerformAssertions();
204 214
         }
205 215
 
206
-        foreach ($this->getMethodParameterMetadata(AnnotatedClass::class, 'method', 'parameter') as $actual) {
216
+        foreach ($this->getMethodParameterMetadata(AnnotatedClass::class, 'method', 'parameter') as $actual)
217
+        {
207 218
             $this->assertEquals($expected, $actual);
208 219
         }
209 220
     }
@@ -221,11 +232,13 @@  discard block
 block discarded – undo
221 232
             'field' => 'value'
222 233
         ]);
223 234
 
224
-        if ($this->functionMetadataCount === 0) {
235
+        if ($this->functionMetadataCount === 0)
236
+        {
225 237
             $this->expectNotToPerformAssertions();
226 238
         }
227 239
 
228
-        foreach ($this->getFunctionMetadata($this->fixture('annotated_function')) as $actual) {
240
+        foreach ($this->getFunctionMetadata($this->fixture('annotated_function')) as $actual)
241
+        {
229 242
             $this->assertEquals($expected, $actual);
230 243
         }
231 244
     }
@@ -243,12 +256,14 @@  discard block
 block discarded – undo
243 256
             'field' => 'value'
244 257
         ]);
245 258
 
246
-        if ($this->functionParameterMetadataCount === 0) {
259
+        if ($this->functionParameterMetadataCount === 0)
260
+        {
247 261
             $this->expectNotToPerformAssertions();
248 262
         }
249 263
 
250 264
         $function = $this->fixture('annotated_function');
251
-        foreach ($this->getFunctionParameterMetadata($function, 'parameter') as $actual) {
265
+        foreach ($this->getFunctionParameterMetadata($function, 'parameter') as $actual)
266
+        {
252 267
             $this->assertEquals($expected, $actual);
253 268
         }
254 269
     }
Please login to merge, or discard this patch.
src/Attributes/src/Internal/DoctrineAnnotationReader.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
         yield from $this->filter($name, $result);
52 52
 
53
-        foreach ($class->getTraits() as $trait) {
53
+        foreach ($class->getTraits() as $trait){
54 54
             yield from $this->getClassMetadata($trait, $name);
55 55
         }
56 56
     }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      */
61 61
     public function getFunctionMetadata(\ReflectionFunctionAbstract $function, string $name = null): iterable
62 62
     {
63
-        if ($function instanceof \ReflectionMethod) {
63
+        if ($function instanceof \ReflectionMethod){
64 64
             $result = $this->wrapDoctrineExceptions(function () use ($function) {
65 65
                 return $this->reader->getMethodAnnotations($function);
66 66
             });
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
 
107 107
     private function wrapDoctrineExceptions(\Closure $then): iterable
108 108
     {
109
-        try {
109
+        try{
110 110
             return $then();
111
-        } catch (AnnotationException $e) {
112
-            switch (true) {
111
+        }catch (AnnotationException $e){
112
+            switch (true){
113 113
                 case \str_starts_with($e->getMessage(), '[Syntax Error]'):
114 114
                 case \str_starts_with($e->getMessage(), '[Type Error]'):
115 115
                     $class = SyntaxAttributeException::class;
@@ -131,14 +131,14 @@  discard block
 block discarded – undo
131 131
     private function bootAnnotations(): void
132 132
     {
133 133
         // doctrine/annotations ^1.0 compatibility.
134
-        if (\method_exists(AnnotationRegistry::class, 'registerLoader')) {
134
+        if (\method_exists(AnnotationRegistry::class, 'registerLoader')){
135 135
             AnnotationRegistry::registerLoader('\\class_exists');
136 136
         }
137 137
     }
138 138
 
139 139
     private function checkAvailability(): void
140 140
     {
141
-        if ($this->isAvailable()) {
141
+        if ($this->isAvailable()){
142 142
             return;
143 143
         }
144 144
 
Please login to merge, or discard this patch.
Braces   +21 added lines, -10 removed lines patch added patch discarded remove patch
@@ -44,13 +44,15 @@  discard block
 block discarded – undo
44 44
      */
45 45
     public function getClassMetadata(\ReflectionClass $class, string $name = null): iterable
46 46
     {
47
-        $result = $this->wrapDoctrineExceptions(function () use ($class) {
47
+        $result = $this->wrapDoctrineExceptions(function () use ($class)
48
+        {
48 49
             return $this->reader->getClassAnnotations($class);
49 50
         });
50 51
 
51 52
         yield from $this->filter($name, $result);
52 53
 
53
-        foreach ($class->getTraits() as $trait) {
54
+        foreach ($class->getTraits() as $trait)
55
+        {
54 56
             yield from $this->getClassMetadata($trait, $name);
55 57
         }
56 58
     }
@@ -60,8 +62,10 @@  discard block
 block discarded – undo
60 62
      */
61 63
     public function getFunctionMetadata(\ReflectionFunctionAbstract $function, string $name = null): iterable
62 64
     {
63
-        if ($function instanceof \ReflectionMethod) {
64
-            $result = $this->wrapDoctrineExceptions(function () use ($function) {
65
+        if ($function instanceof \ReflectionMethod)
66
+        {
67
+            $result = $this->wrapDoctrineExceptions(function () use ($function)
68
+            {
65 69
                 return $this->reader->getMethodAnnotations($function);
66 70
             });
67 71
 
@@ -76,7 +80,8 @@  discard block
 block discarded – undo
76 80
      */
77 81
     public function getPropertyMetadata(\ReflectionProperty $property, string $name = null): iterable
78 82
     {
79
-        $result = $this->wrapDoctrineExceptions(function () use ($property) {
83
+        $result = $this->wrapDoctrineExceptions(function () use ($property)
84
+        {
80 85
             return $this->reader->getPropertyAnnotations($property);
81 86
         });
82 87
 
@@ -106,10 +111,14 @@  discard block
 block discarded – undo
106 111
 
107 112
     private function wrapDoctrineExceptions(\Closure $then): iterable
108 113
     {
109
-        try {
114
+        try
115
+        {
110 116
             return $then();
111
-        } catch (AnnotationException $e) {
112
-            switch (true) {
117
+        }
118
+        catch (AnnotationException $e)
119
+        {
120
+            switch (true)
121
+            {
113 122
                 case \str_starts_with($e->getMessage(), '[Syntax Error]'):
114 123
                 case \str_starts_with($e->getMessage(), '[Type Error]'):
115 124
                     $class = SyntaxAttributeException::class;
@@ -131,14 +140,16 @@  discard block
 block discarded – undo
131 140
     private function bootAnnotations(): void
132 141
     {
133 142
         // doctrine/annotations ^1.0 compatibility.
134
-        if (\method_exists(AnnotationRegistry::class, 'registerLoader')) {
143
+        if (\method_exists(AnnotationRegistry::class, 'registerLoader'))
144
+        {
135 145
             AnnotationRegistry::registerLoader('\\class_exists');
136 146
         }
137 147
     }
138 148
 
139 149
     private function checkAvailability(): void
140 150
     {
141
-        if ($this->isAvailable()) {
151
+        if ($this->isAvailable())
152
+        {
142 153
             return;
143 154
         }
144 155
 
Please login to merge, or discard this patch.
src/Attributes/src/Internal/AttributeReader.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
     {
49 49
         $attributes = $this->getClassAttributes($class, $name);
50 50
 
51
-        foreach ($attributes as $attribute => $arguments) {
51
+        foreach ($attributes as $attribute => $arguments){
52 52
             yield $this->instantiator->instantiate($attribute, $arguments, $class);
53 53
         }
54 54
 
55
-        foreach ($class->getTraits() as $trait) {
55
+        foreach ($class->getTraits() as $trait){
56 56
             yield from $this->getClassMetadata($trait, $name);
57 57
         }
58 58
     }
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     {
66 66
         $attributes = $this->getFunctionAttributes($function, $name);
67 67
 
68
-        foreach ($attributes as $attribute => $arguments) {
68
+        foreach ($attributes as $attribute => $arguments){
69 69
             yield $this->instantiator->instantiate($attribute, $arguments, $function);
70 70
         }
71 71
     }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
     {
79 79
         $attributes = $this->getPropertyAttributes($property, $name);
80 80
 
81
-        foreach ($attributes as $attribute => $arguments) {
81
+        foreach ($attributes as $attribute => $arguments){
82 82
             yield $this->instantiator->instantiate($attribute, $arguments, $property);
83 83
         }
84 84
     }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
     {
92 92
         $attributes = $this->getConstantAttributes($constant, $name);
93 93
 
94
-        foreach ($attributes as $attribute => $arguments) {
94
+        foreach ($attributes as $attribute => $arguments){
95 95
             yield $this->instantiator->instantiate($attribute, $arguments, $constant);
96 96
         }
97 97
     }
@@ -104,14 +104,14 @@  discard block
 block discarded – undo
104 104
     {
105 105
         $attributes = $this->getParameterAttributes($parameter, $name);
106 106
 
107
-        foreach ($attributes as $attribute => $arguments) {
107
+        foreach ($attributes as $attribute => $arguments){
108 108
             yield $this->instantiator->instantiate($attribute, $arguments, $parameter);
109 109
         }
110 110
     }
111 111
 
112 112
     protected function assertClassExists(string $class, \Reflector $context): void
113 113
     {
114
-        if (!\class_exists($class)) {
114
+        if (!\class_exists($class)){
115 115
             $message = \vsprintf('The metadata class "%s" in %s was not found', [
116 116
                 $class,
117 117
                 $this->renderer->render($context),
Please login to merge, or discard this patch.
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -48,11 +48,13 @@  discard block
 block discarded – undo
48 48
     {
49 49
         $attributes = $this->getClassAttributes($class, $name);
50 50
 
51
-        foreach ($attributes as $attribute => $arguments) {
51
+        foreach ($attributes as $attribute => $arguments)
52
+        {
52 53
             yield $this->instantiator->instantiate($attribute, $arguments, $class);
53 54
         }
54 55
 
55
-        foreach ($class->getTraits() as $trait) {
56
+        foreach ($class->getTraits() as $trait)
57
+        {
56 58
             yield from $this->getClassMetadata($trait, $name);
57 59
         }
58 60
     }
@@ -65,7 +67,8 @@  discard block
 block discarded – undo
65 67
     {
66 68
         $attributes = $this->getFunctionAttributes($function, $name);
67 69
 
68
-        foreach ($attributes as $attribute => $arguments) {
70
+        foreach ($attributes as $attribute => $arguments)
71
+        {
69 72
             yield $this->instantiator->instantiate($attribute, $arguments, $function);
70 73
         }
71 74
     }
@@ -78,7 +81,8 @@  discard block
 block discarded – undo
78 81
     {
79 82
         $attributes = $this->getPropertyAttributes($property, $name);
80 83
 
81
-        foreach ($attributes as $attribute => $arguments) {
84
+        foreach ($attributes as $attribute => $arguments)
85
+        {
82 86
             yield $this->instantiator->instantiate($attribute, $arguments, $property);
83 87
         }
84 88
     }
@@ -91,7 +95,8 @@  discard block
 block discarded – undo
91 95
     {
92 96
         $attributes = $this->getConstantAttributes($constant, $name);
93 97
 
94
-        foreach ($attributes as $attribute => $arguments) {
98
+        foreach ($attributes as $attribute => $arguments)
99
+        {
95 100
             yield $this->instantiator->instantiate($attribute, $arguments, $constant);
96 101
         }
97 102
     }
@@ -104,14 +109,16 @@  discard block
 block discarded – undo
104 109
     {
105 110
         $attributes = $this->getParameterAttributes($parameter, $name);
106 111
 
107
-        foreach ($attributes as $attribute => $arguments) {
112
+        foreach ($attributes as $attribute => $arguments)
113
+        {
108 114
             yield $this->instantiator->instantiate($attribute, $arguments, $parameter);
109 115
         }
110 116
     }
111 117
 
112 118
     protected function assertClassExists(string $class, \Reflector $context): void
113 119
     {
114
-        if (!\class_exists($class)) {
120
+        if (!\class_exists($class))
121
+        {
115 122
             $message = \vsprintf('The metadata class "%s" in %s was not found', [
116 123
                 $class,
117 124
                 $this->renderer->render($context),
Please login to merge, or discard this patch.