Passed
Pull Request — master (#656)
by Abdul Malik
09:21
created
src/Attributes/src/Internal/Instantiator/NamedArgumentsInstantiator.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -41,17 +41,17 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public function instantiate(ReflectionClass $attr, array $arguments, Reflector $context = null): object
43 43
     {
44
-        if ($this->isNamedArgumentsSupported()) {
45
-            try {
44
+        if ($this->isNamedArgumentsSupported()){
45
+            try{
46 46
                 return $attr->newInstanceArgs($arguments);
47
-            } catch (Throwable $e) {
47
+            }catch (Throwable $e){
48 48
                 throw Exception::withLocation($e, $attr->getFileName(), $attr->getStartLine());
49 49
             }
50 50
         }
51 51
 
52 52
         $constructor = $this->getConstructor($attr);
53 53
 
54
-        if ($constructor === null) {
54
+        if ($constructor === null){
55 55
             return $attr->newInstanceWithoutConstructor();
56 56
         }
57 57
 
@@ -72,16 +72,16 @@  discard block
 block discarded – undo
72 72
     {
73 73
         $passed = [];
74 74
 
75
-        try {
76
-            foreach ($constructor->getParameters() as $parameter) {
75
+        try{
76
+            foreach ($constructor->getParameters() as $parameter){
77 77
                 $passed[] = $this->resolveParameter($ctx, $parameter, $arguments);
78 78
             }
79 79
 
80
-            if (\count($arguments)) {
80
+            if (\count($arguments)){
81 81
                 $message = \sprintf(self::ERROR_UNKNOWN_ARGUMENT, \array_key_first($arguments));
82 82
                 throw new BadMethodCallException($message);
83 83
             }
84
-        } catch (Throwable $e) {
84
+        }catch (Throwable $e){
85 85
             throw Exception::withLocation($e, $constructor->getFileName(), $constructor->getStartLine());
86 86
         }
87 87
 
@@ -94,19 +94,19 @@  discard block
 block discarded – undo
94 94
      */
95 95
     private function resolveParameter(ReflectionClass $ctx, ReflectionParameter $param, array &$arguments)
96 96
     {
97
-        switch (true) {
97
+        switch (true){
98 98
             case \array_key_exists($param->getName(), $arguments):
99
-                try {
99
+                try{
100 100
                     return $arguments[$param->getName()];
101
-                } finally {
101
+                }finally{
102 102
                     unset($arguments[$param->getName()]);
103 103
                 }
104 104
                 // no actual falling through
105 105
 
106 106
             case \array_key_exists($param->getPosition(), $arguments):
107
-                try {
107
+                try{
108 108
                     return $arguments[$param->getPosition()];
109
-                } finally {
109
+                }finally{
110 110
                     unset($arguments[$param->getPosition()]);
111 111
                 }
112 112
                 // no actual falling through
Please login to merge, or discard this patch.
Braces   +30 added lines, -13 removed lines patch added patch discarded remove patch
@@ -41,17 +41,22 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public function instantiate(ReflectionClass $attr, array $arguments, Reflector $context = null): object
43 43
     {
44
-        if ($this->isNamedArgumentsSupported()) {
45
-            try {
44
+        if ($this->isNamedArgumentsSupported())
45
+        {
46
+            try
47
+            {
46 48
                 return $attr->newInstanceArgs($arguments);
47
-            } catch (Throwable $e) {
49
+            }
50
+            catch (Throwable $e)
51
+            {
48 52
                 throw Exception::withLocation($e, $attr->getFileName(), $attr->getStartLine());
49 53
             }
50 54
         }
51 55
 
52 56
         $constructor = $this->getConstructor($attr);
53 57
 
54
-        if ($constructor === null) {
58
+        if ($constructor === null)
59
+        {
55 60
             return $attr->newInstanceWithoutConstructor();
56 61
         }
57 62
 
@@ -72,16 +77,21 @@  discard block
 block discarded – undo
72 77
     {
73 78
         $passed = [];
74 79
 
75
-        try {
76
-            foreach ($constructor->getParameters() as $parameter) {
80
+        try
81
+        {
82
+            foreach ($constructor->getParameters() as $parameter)
83
+            {
77 84
                 $passed[] = $this->resolveParameter($ctx, $parameter, $arguments);
78 85
             }
79 86
 
80
-            if (\count($arguments)) {
87
+            if (\count($arguments))
88
+            {
81 89
                 $message = \sprintf(self::ERROR_UNKNOWN_ARGUMENT, \array_key_first($arguments));
82 90
                 throw new BadMethodCallException($message);
83 91
             }
84
-        } catch (Throwable $e) {
92
+        }
93
+        catch (Throwable $e)
94
+        {
85 95
             throw Exception::withLocation($e, $constructor->getFileName(), $constructor->getStartLine());
86 96
         }
87 97
 
@@ -94,19 +104,26 @@  discard block
 block discarded – undo
94 104
      */
95 105
     private function resolveParameter(ReflectionClass $ctx, ReflectionParameter $param, array &$arguments)
96 106
     {
97
-        switch (true) {
107
+        switch (true)
108
+        {
98 109
             case \array_key_exists($param->getName(), $arguments):
99
-                try {
110
+                try
111
+                {
100 112
                     return $arguments[$param->getName()];
101
-                } finally {
113
+                }
114
+                finally
115
+                {
102 116
                     unset($arguments[$param->getName()]);
103 117
                 }
104 118
                 // no actual falling through
105 119
 
106 120
             case \array_key_exists($param->getPosition(), $arguments):
107
-                try {
121
+                try
122
+                {
108 123
                     return $arguments[$param->getPosition()];
109
-                } finally {
124
+                }
125
+                finally
126
+                {
110 127
                     unset($arguments[$param->getPosition()]);
111 128
                 }
112 129
                 // no actual falling through
Please login to merge, or discard this patch.
src/Attributes/src/Internal/Instantiator/Facade.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
      */
43 43
     public function instantiate(ReflectionClass $attr, array $arguments, Reflector $context = null): object
44 44
     {
45
-        if ($this->isNamedArguments($attr)) {
45
+        if ($this->isNamedArguments($attr)){
46 46
             return $this->named->instantiate($attr, $arguments, $context);
47 47
         }
48 48
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,8 @@
 block discarded – undo
42 42
      */
43 43
     public function instantiate(ReflectionClass $attr, array $arguments, Reflector $context = null): object
44 44
     {
45
-        if ($this->isNamedArguments($attr)) {
45
+        if ($this->isNamedArguments($attr))
46
+        {
46 47
             return $this->named->instantiate($attr, $arguments, $context);
47 48
         }
48 49
 
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
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
     {
53 53
         $attributes = $this->getClassAttributes($class, $name);
54 54
 
55
-        foreach ($attributes as $attribute => $arguments) {
55
+        foreach ($attributes as $attribute => $arguments){
56 56
             yield $this->instantiator->instantiate($attribute, $arguments, $class);
57 57
         }
58 58
 
59
-        foreach ($class->getTraits() as $trait) {
59
+        foreach ($class->getTraits() as $trait){
60 60
             yield from $this->getClassMetadata($trait, $name);
61 61
         }
62 62
     }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
     {
70 70
         $attributes = $this->getFunctionAttributes($function, $name);
71 71
 
72
-        foreach ($attributes as $attribute => $arguments) {
72
+        foreach ($attributes as $attribute => $arguments){
73 73
             yield $this->instantiator->instantiate($attribute, $arguments, $function);
74 74
         }
75 75
     }
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     {
83 83
         $attributes = $this->getPropertyAttributes($property, $name);
84 84
 
85
-        foreach ($attributes as $attribute => $arguments) {
85
+        foreach ($attributes as $attribute => $arguments){
86 86
             yield $this->instantiator->instantiate($attribute, $arguments, $property);
87 87
         }
88 88
     }
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     {
96 96
         $attributes = $this->getConstantAttributes($constant, $name);
97 97
 
98
-        foreach ($attributes as $attribute => $arguments) {
98
+        foreach ($attributes as $attribute => $arguments){
99 99
             yield $this->instantiator->instantiate($attribute, $arguments, $constant);
100 100
         }
101 101
     }
@@ -108,14 +108,14 @@  discard block
 block discarded – undo
108 108
     {
109 109
         $attributes = $this->getParameterAttributes($parameter, $name);
110 110
 
111
-        foreach ($attributes as $attribute => $arguments) {
111
+        foreach ($attributes as $attribute => $arguments){
112 112
             yield $this->instantiator->instantiate($attribute, $arguments, $parameter);
113 113
         }
114 114
     }
115 115
 
116 116
     protected function assertClassExists(string $class, Reflector $context): void
117 117
     {
118
-        if (!\class_exists($class)) {
118
+        if (!\class_exists($class)){
119 119
             $message = \vsprintf('The metadata class "%s" in %s was not found', [
120 120
                 $class,
121 121
                 $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
@@ -52,11 +52,13 @@  discard block
 block discarded – undo
52 52
     {
53 53
         $attributes = $this->getClassAttributes($class, $name);
54 54
 
55
-        foreach ($attributes as $attribute => $arguments) {
55
+        foreach ($attributes as $attribute => $arguments)
56
+        {
56 57
             yield $this->instantiator->instantiate($attribute, $arguments, $class);
57 58
         }
58 59
 
59
-        foreach ($class->getTraits() as $trait) {
60
+        foreach ($class->getTraits() as $trait)
61
+        {
60 62
             yield from $this->getClassMetadata($trait, $name);
61 63
         }
62 64
     }
@@ -69,7 +71,8 @@  discard block
 block discarded – undo
69 71
     {
70 72
         $attributes = $this->getFunctionAttributes($function, $name);
71 73
 
72
-        foreach ($attributes as $attribute => $arguments) {
74
+        foreach ($attributes as $attribute => $arguments)
75
+        {
73 76
             yield $this->instantiator->instantiate($attribute, $arguments, $function);
74 77
         }
75 78
     }
@@ -82,7 +85,8 @@  discard block
 block discarded – undo
82 85
     {
83 86
         $attributes = $this->getPropertyAttributes($property, $name);
84 87
 
85
-        foreach ($attributes as $attribute => $arguments) {
88
+        foreach ($attributes as $attribute => $arguments)
89
+        {
86 90
             yield $this->instantiator->instantiate($attribute, $arguments, $property);
87 91
         }
88 92
     }
@@ -95,7 +99,8 @@  discard block
 block discarded – undo
95 99
     {
96 100
         $attributes = $this->getConstantAttributes($constant, $name);
97 101
 
98
-        foreach ($attributes as $attribute => $arguments) {
102
+        foreach ($attributes as $attribute => $arguments)
103
+        {
99 104
             yield $this->instantiator->instantiate($attribute, $arguments, $constant);
100 105
         }
101 106
     }
@@ -108,14 +113,16 @@  discard block
 block discarded – undo
108 113
     {
109 114
         $attributes = $this->getParameterAttributes($parameter, $name);
110 115
 
111
-        foreach ($attributes as $attribute => $arguments) {
116
+        foreach ($attributes as $attribute => $arguments)
117
+        {
112 118
             yield $this->instantiator->instantiate($attribute, $arguments, $parameter);
113 119
         }
114 120
     }
115 121
 
116 122
     protected function assertClassExists(string $class, Reflector $context): void
117 123
     {
118
-        if (!\class_exists($class)) {
124
+        if (!\class_exists($class))
125
+        {
119 126
             $message = \vsprintf('The metadata class "%s" in %s was not found', [
120 127
                 $class,
121 128
                 $this->renderer->render($context),
Please login to merge, or discard this patch.
src/Attributes/src/Internal/FallbackAttributeReader.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     {
100 100
         // 1) Can not parse internal classes
101 101
         // 2) Anonymous classes don't support attributes (PHP semantic)
102
-        if ($class->isInternal() || $class->isAnonymous()) {
102
+        if ($class->isInternal() || $class->isAnonymous()){
103 103
             return [];
104 104
         }
105 105
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
     protected function getFunctionAttributes(ReflectionFunctionAbstract $function, ?string $name): iterable
115 115
     {
116 116
         // Can not parse internal functions
117
-        if ($function->isInternal()) {
117
+        if ($function->isInternal()){
118 118
             return [];
119 119
         }
120 120
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
         $class = $property->getDeclaringClass();
133 133
 
134 134
         // Can not parse property of internal class
135
-        if ($class->isInternal()) {
135
+        if ($class->isInternal()){
136 136
             return [];
137 137
         }
138 138
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
         $class = $const->getDeclaringClass();
150 150
 
151 151
         // Can not parse internal classes
152
-        if ($class->isInternal()) {
152
+        if ($class->isInternal()){
153 153
             return [];
154 154
         }
155 155
 
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
         $function = $param->getDeclaringFunction();
167 167
 
168 168
         // Can not parse parameter of internal function
169
-        if ($function->isInternal()) {
169
+        if ($function->isInternal()){
170 170
             return [];
171 171
         }
172 172
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
      */
184 184
     private function parseAttributes(string $file, int $context): array
185 185
     {
186
-        if (!isset($this->attributes[$file])) {
186
+        if (!isset($this->attributes[$file])){
187 187
             $found = $this->parser->parse($file);
188 188
 
189 189
             $this->attributes[$file] = [
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
      */
206 206
     private function format(iterable $attributes, ?string $name, Reflector $context): iterable
207 207
     {
208
-        foreach ($attributes as $prototype) {
209
-            if ($prototype->name !== $name && $name !== null && !\is_subclass_of($prototype->name, $name)) {
208
+        foreach ($attributes as $prototype){
209
+            if ($prototype->name !== $name && $name !== null && !\is_subclass_of($prototype->name, $name)){
210 210
                 continue;
211 211
             }
212 212
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
          */
242 242
         $line = $function->getEndLine();
243 243
 
244
-        if ($result = $attributes[$line] ?? null) {
244
+        if ($result = $attributes[$line] ?? null){
245 245
             return $result;
246 246
         }
247 247
 
@@ -266,9 +266,9 @@  discard block
 block discarded – undo
266 266
          *  $ast->getEndLine(); // 2 (last significant character of a function)
267 267
          * </code>
268 268
          */
269
-        if ($function->isClosure()) {
270
-            while ($line-- > $function->getStartLine()) {
271
-                if ($result = $attributes[$line] ?? null) {
269
+        if ($function->isClosure()){
270
+            while ($line-- > $function->getStartLine()){
271
+                if ($result = $attributes[$line] ?? null){
272 272
                     return $result;
273 273
                 }
274 274
             }
Please login to merge, or discard this patch.
Braces   +24 added lines, -12 removed lines patch added patch discarded remove patch
@@ -99,7 +99,8 @@  discard block
 block discarded – undo
99 99
     {
100 100
         // 1) Can not parse internal classes
101 101
         // 2) Anonymous classes don't support attributes (PHP semantic)
102
-        if ($class->isInternal() || $class->isAnonymous()) {
102
+        if ($class->isInternal() || $class->isAnonymous())
103
+        {
103 104
             return [];
104 105
         }
105 106
 
@@ -114,7 +115,8 @@  discard block
 block discarded – undo
114 115
     protected function getFunctionAttributes(ReflectionFunctionAbstract $function, ?string $name): iterable
115 116
     {
116 117
         // Can not parse internal functions
117
-        if ($function->isInternal()) {
118
+        if ($function->isInternal())
119
+        {
118 120
             return [];
119 121
         }
120 122
 
@@ -132,7 +134,8 @@  discard block
 block discarded – undo
132 134
         $class = $property->getDeclaringClass();
133 135
 
134 136
         // Can not parse property of internal class
135
-        if ($class->isInternal()) {
137
+        if ($class->isInternal())
138
+        {
136 139
             return [];
137 140
         }
138 141
 
@@ -149,7 +152,8 @@  discard block
 block discarded – undo
149 152
         $class = $const->getDeclaringClass();
150 153
 
151 154
         // Can not parse internal classes
152
-        if ($class->isInternal()) {
155
+        if ($class->isInternal())
156
+        {
153 157
             return [];
154 158
         }
155 159
 
@@ -166,7 +170,8 @@  discard block
 block discarded – undo
166 170
         $function = $param->getDeclaringFunction();
167 171
 
168 172
         // Can not parse parameter of internal function
169
-        if ($function->isInternal()) {
173
+        if ($function->isInternal())
174
+        {
170 175
             return [];
171 176
         }
172 177
 
@@ -183,7 +188,8 @@  discard block
 block discarded – undo
183 188
      */
184 189
     private function parseAttributes(string $file, int $context): array
185 190
     {
186
-        if (!isset($this->attributes[$file])) {
191
+        if (!isset($this->attributes[$file]))
192
+        {
187 193
             $found = $this->parser->parse($file);
188 194
 
189 195
             $this->attributes[$file] = [
@@ -205,8 +211,10 @@  discard block
 block discarded – undo
205 211
      */
206 212
     private function format(iterable $attributes, ?string $name, Reflector $context): iterable
207 213
     {
208
-        foreach ($attributes as $prototype) {
209
-            if ($prototype->name !== $name && $name !== null && !\is_subclass_of($prototype->name, $name)) {
214
+        foreach ($attributes as $prototype)
215
+        {
216
+            if ($prototype->name !== $name && $name !== null && !\is_subclass_of($prototype->name, $name))
217
+            {
210 218
                 continue;
211 219
             }
212 220
 
@@ -241,7 +249,8 @@  discard block
 block discarded – undo
241 249
          */
242 250
         $line = $function->getEndLine();
243 251
 
244
-        if ($result = $attributes[$line] ?? null) {
252
+        if ($result = $attributes[$line] ?? null)
253
+        {
245 254
             return $result;
246 255
         }
247 256
 
@@ -266,9 +275,12 @@  discard block
 block discarded – undo
266 275
          *  $ast->getEndLine(); // 2 (last significant character of a function)
267 276
          * </code>
268 277
          */
269
-        if ($function->isClosure()) {
270
-            while ($line-- > $function->getStartLine()) {
271
-                if ($result = $attributes[$line] ?? null) {
278
+        if ($function->isClosure())
279
+        {
280
+            while ($line-- > $function->getStartLine())
281
+            {
282
+                if ($result = $attributes[$line] ?? null)
283
+                {
272 284
                     return $result;
273 285
                 }
274 286
             }
Please login to merge, or discard this patch.
src/Attributes/src/Internal/NativeAttributeReader.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
     private function checkAvailability(): void
88 88
     {
89
-        if (!self::isAvailable()) {
89
+        if (!self::isAvailable()){
90 90
             throw new InitializationException('Requires the PHP >= 8.0');
91 91
         }
92 92
     }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      */
99 99
     private function format(Reflector $context, iterable $attributes): iterable
100 100
     {
101
-        foreach ($attributes as $attribute) {
101
+        foreach ($attributes as $attribute){
102 102
             $this->assertClassExists($attribute->getName(), $context);
103 103
 
104 104
             yield new ReflectionClass($attribute->getName()) => $attribute->getArguments();
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -86,7 +86,8 @@  discard block
 block discarded – undo
86 86
 
87 87
     private function checkAvailability(): void
88 88
     {
89
-        if (!self::isAvailable()) {
89
+        if (!self::isAvailable())
90
+        {
90 91
             throw new InitializationException('Requires the PHP >= 8.0');
91 92
         }
92 93
     }
@@ -98,7 +99,8 @@  discard block
 block discarded – undo
98 99
      */
99 100
     private function format(Reflector $context, iterable $attributes): iterable
100 101
     {
101
-        foreach ($attributes as $attribute) {
102
+        foreach ($attributes as $attribute)
103
+        {
102 104
             $this->assertClassExists($attribute->getName(), $context);
103 105
 
104 106
             yield new ReflectionClass($attribute->getName()) => $attribute->getArguments();
Please login to merge, or discard this patch.
src/Attributes/src/Internal/CachedReader.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@
 block discarded – undo
130 130
      */
131 131
     protected function iterableToArray(iterable $attributes): array
132 132
     {
133
-        if ($attributes instanceof Traversable) {
133
+        if ($attributes instanceof Traversable){
134 134
             return \iterator_to_array($attributes, false);
135 135
         }
136 136
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -130,7 +130,8 @@
 block discarded – undo
130 130
      */
131 131
     protected function iterableToArray(iterable $attributes): array
132 132
     {
133
-        if ($attributes instanceof Traversable) {
133
+        if ($attributes instanceof Traversable)
134
+        {
134 135
             return \iterator_to_array($attributes, false);
135 136
         }
136 137
 
Please login to merge, or discard this patch.
Attributes/src/Internal/FallbackAttributeReader/AttributeFinderVisitor.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -140,23 +140,23 @@  discard block
 block discarded – undo
140 140
     {
141 141
         $this->updateContext($node);
142 142
 
143
-        if ($node instanceof ClassLike) {
144
-            foreach ($this->parse($node->attrGroups) as $prototype) {
143
+        if ($node instanceof ClassLike){
144
+            foreach ($this->parse($node->attrGroups) as $prototype){
145 145
                 $this->classes[$node->namespacedName->toString()][] = $prototype;
146 146
             }
147 147
 
148 148
             return null;
149 149
         }
150 150
 
151
-        if ($node instanceof FunctionLike) {
151
+        if ($node instanceof FunctionLike){
152 152
             $line = $node->getEndLine();
153 153
 
154
-            foreach ($this->parse($node->getAttrGroups()) as $prototype) {
154
+            foreach ($this->parse($node->getAttrGroups()) as $prototype){
155 155
                 $this->functions[$line][] = $prototype;
156 156
             }
157 157
 
158
-            foreach ($node->getParams() as $param) {
159
-                foreach ($this->parse($param->attrGroups) as $prototype) {
158
+            foreach ($node->getParams() as $param){
159
+                foreach ($this->parse($param->attrGroups) as $prototype){
160 160
                     assert(\is_string($param->var->name), 'Function parameter name should be an identifier');
161 161
 
162 162
                     $this->parameters[$line][$param->var->name][] = $prototype;
@@ -166,11 +166,11 @@  discard block
 block discarded – undo
166 166
             return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
167 167
         }
168 168
 
169
-        if ($node instanceof ClassConst) {
169
+        if ($node instanceof ClassConst){
170 170
             $class = $this->fqn();
171 171
 
172
-            foreach ($this->parse($node->attrGroups) as $prototype) {
173
-                foreach ($node->consts as $const) {
172
+            foreach ($this->parse($node->attrGroups) as $prototype){
173
+                foreach ($node->consts as $const){
174 174
                     $this->constants[$class][$this->name($const->name)][] = $prototype;
175 175
                 }
176 176
             }
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
             return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
179 179
         }
180 180
 
181
-        if ($node instanceof Property) {
181
+        if ($node instanceof Property){
182 182
             $class = $this->fqn();
183 183
 
184
-            foreach ($this->parse($node->attrGroups) as $prototype) {
185
-                foreach ($node->props as $property) {
184
+            foreach ($this->parse($node->attrGroups) as $prototype){
185
+                foreach ($node->props as $property){
186 186
                     $this->properties[$class][$this->name($property->name)][] = $prototype;
187 187
                 }
188 188
             }
@@ -195,27 +195,27 @@  discard block
 block discarded – undo
195 195
 
196 196
     public function leaveNode(Node $node): void
197 197
     {
198
-        if ($node instanceof Namespace_) {
198
+        if ($node instanceof Namespace_){
199 199
             $this->context[AttributeParser::CTX_NAMESPACE] = '';
200 200
 
201 201
             return;
202 202
         }
203 203
 
204
-        if ($node instanceof ClassLike) {
204
+        if ($node instanceof ClassLike){
205 205
             $this->context[AttributeParser::CTX_CLASS] = '';
206 206
             $this->context[AttributeParser::CTX_TRAIT] = '';
207 207
 
208 208
             return;
209 209
         }
210 210
 
211
-        if ($node instanceof FunctionLike) {
211
+        if ($node instanceof FunctionLike){
212 212
             $this->context[AttributeParser::CTX_FUNCTION] = '';
213 213
         }
214 214
     }
215 215
 
216 216
     private function updateContext(Node $node): void
217 217
     {
218
-        switch (true) {
218
+        switch (true){
219 219
             case $node instanceof Namespace_:
220 220
                 $this->context[AttributeParser::CTX_NAMESPACE] = $this->name($node->name);
221 221
                 break;
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
      */
241 241
     private function name($name): string
242 242
     {
243
-        if ($name === null) {
243
+        if ($name === null){
244 244
             return '';
245 245
         }
246 246
 
@@ -262,6 +262,6 @@  discard block
 block discarded – undo
262 262
         $namespace = $this->context[AttributeParser::CTX_NAMESPACE] ?? '';
263 263
         $class = $this->context[AttributeParser::CTX_CLASS] ?? '';
264 264
 
265
-        return \trim($namespace . '\\' . $class, '\\');
265
+        return \trim($namespace.'\\'.$class, '\\');
266 266
     }
267 267
 }
Please login to merge, or discard this patch.
Braces   +34 added lines, -17 removed lines patch added patch discarded remove patch
@@ -140,23 +140,29 @@  discard block
 block discarded – undo
140 140
     {
141 141
         $this->updateContext($node);
142 142
 
143
-        if ($node instanceof ClassLike) {
144
-            foreach ($this->parse($node->attrGroups) as $prototype) {
143
+        if ($node instanceof ClassLike)
144
+        {
145
+            foreach ($this->parse($node->attrGroups) as $prototype)
146
+            {
145 147
                 $this->classes[$node->namespacedName->toString()][] = $prototype;
146 148
             }
147 149
 
148 150
             return null;
149 151
         }
150 152
 
151
-        if ($node instanceof FunctionLike) {
153
+        if ($node instanceof FunctionLike)
154
+        {
152 155
             $line = $node->getEndLine();
153 156
 
154
-            foreach ($this->parse($node->getAttrGroups()) as $prototype) {
157
+            foreach ($this->parse($node->getAttrGroups()) as $prototype)
158
+            {
155 159
                 $this->functions[$line][] = $prototype;
156 160
             }
157 161
 
158
-            foreach ($node->getParams() as $param) {
159
-                foreach ($this->parse($param->attrGroups) as $prototype) {
162
+            foreach ($node->getParams() as $param)
163
+            {
164
+                foreach ($this->parse($param->attrGroups) as $prototype)
165
+                {
160 166
                     assert(\is_string($param->var->name), 'Function parameter name should be an identifier');
161 167
 
162 168
                     $this->parameters[$line][$param->var->name][] = $prototype;
@@ -166,11 +172,14 @@  discard block
 block discarded – undo
166 172
             return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
167 173
         }
168 174
 
169
-        if ($node instanceof ClassConst) {
175
+        if ($node instanceof ClassConst)
176
+        {
170 177
             $class = $this->fqn();
171 178
 
172
-            foreach ($this->parse($node->attrGroups) as $prototype) {
173
-                foreach ($node->consts as $const) {
179
+            foreach ($this->parse($node->attrGroups) as $prototype)
180
+            {
181
+                foreach ($node->consts as $const)
182
+                {
174 183
                     $this->constants[$class][$this->name($const->name)][] = $prototype;
175 184
                 }
176 185
             }
@@ -178,11 +187,14 @@  discard block
 block discarded – undo
178 187
             return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
179 188
         }
180 189
 
181
-        if ($node instanceof Property) {
190
+        if ($node instanceof Property)
191
+        {
182 192
             $class = $this->fqn();
183 193
 
184
-            foreach ($this->parse($node->attrGroups) as $prototype) {
185
-                foreach ($node->props as $property) {
194
+            foreach ($this->parse($node->attrGroups) as $prototype)
195
+            {
196
+                foreach ($node->props as $property)
197
+                {
186 198
                     $this->properties[$class][$this->name($property->name)][] = $prototype;
187 199
                 }
188 200
             }
@@ -195,27 +207,31 @@  discard block
 block discarded – undo
195 207
 
196 208
     public function leaveNode(Node $node): void
197 209
     {
198
-        if ($node instanceof Namespace_) {
210
+        if ($node instanceof Namespace_)
211
+        {
199 212
             $this->context[AttributeParser::CTX_NAMESPACE] = '';
200 213
 
201 214
             return;
202 215
         }
203 216
 
204
-        if ($node instanceof ClassLike) {
217
+        if ($node instanceof ClassLike)
218
+        {
205 219
             $this->context[AttributeParser::CTX_CLASS] = '';
206 220
             $this->context[AttributeParser::CTX_TRAIT] = '';
207 221
 
208 222
             return;
209 223
         }
210 224
 
211
-        if ($node instanceof FunctionLike) {
225
+        if ($node instanceof FunctionLike)
226
+        {
212 227
             $this->context[AttributeParser::CTX_FUNCTION] = '';
213 228
         }
214 229
     }
215 230
 
216 231
     private function updateContext(Node $node): void
217 232
     {
218
-        switch (true) {
233
+        switch (true)
234
+        {
219 235
             case $node instanceof Namespace_:
220 236
                 $this->context[AttributeParser::CTX_NAMESPACE] = $this->name($node->name);
221 237
                 break;
@@ -240,7 +256,8 @@  discard block
 block discarded – undo
240 256
      */
241 257
     private function name($name): string
242 258
     {
243
-        if ($name === null) {
259
+        if ($name === null)
260
+        {
244 261
             return '';
245 262
         }
246 263
 
Please login to merge, or discard this patch.
src/Attributes/src/Internal/FallbackAttributeReader/AttributeParser.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
     {
111 111
         $eval = new ConstExprEvaluator($this->evaluator($file, $context));
112 112
 
113
-        foreach ($groups as $group) {
114
-            foreach ($group->attrs as $attr) {
113
+        foreach ($groups as $group){
114
+            foreach ($group->attrs as $attr){
115 115
                 $arguments = $this->parseAttributeArguments($attr, $file, $eval);
116 116
 
117 117
                 yield new AttributePrototype($attr->name->toString(), $arguments);
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 
129 129
     private function read(string $file): string
130 130
     {
131
-        if (!\is_readable($file)) {
132
-            throw new InvalidArgumentException('Unable to read file "' . $file . '"');
131
+        if (!\is_readable($file)){
132
+            throw new InvalidArgumentException('Unable to read file "'.$file.'"');
133 133
         }
134 134
 
135 135
         return \file_get_contents($file);
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
     private function evaluator(string $file, array $context): Closure
139 139
     {
140 140
         return static function (Expr $expr) use ($file, $context) {
141
-            switch (\get_class($expr)) {
141
+            switch (\get_class($expr)){
142 142
                 case File::class:
143 143
                     return $file;
144 144
 
@@ -152,19 +152,19 @@  discard block
 block discarded – undo
152 152
                     $namespace = $context[self::CTX_NAMESPACE] ?? '';
153 153
                     $function = $context[self::CTX_FUNCTION] ?? '';
154 154
 
155
-                    return \ltrim($namespace . '\\' . $function, '\\');
155
+                    return \ltrim($namespace.'\\'.$function, '\\');
156 156
 
157 157
                 case ClassConstFetch::class:
158 158
                     $constant = $expr->name->toString();
159 159
                     $class = $expr->class->toString();
160 160
 
161
-                    if (\strtolower($constant) === 'class') {
161
+                    if (\strtolower($constant) === 'class'){
162 162
                         return $class;
163 163
                     }
164 164
 
165
-                    $definition = $class . '::' . $constant;
165
+                    $definition = $class.'::'.$constant;
166 166
 
167
-                    if (!\defined($definition)) {
167
+                    if (!\defined($definition)){
168 168
                         $exception = new ParseError(\sprintf(self::ERROR_BAD_CONSTANT, $definition));
169 169
                         throw Exception::withLocation($exception, $file, $expr->getStartLine());
170 170
                     }
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
                     return \constant($definition);
173 173
             }
174 174
 
175
-            if ($expr instanceof MagicConst) {
175
+            if ($expr instanceof MagicConst){
176 176
                 return $context[$expr->getName()] ?? '';
177 177
             }
178 178
 
@@ -190,13 +190,13 @@  discard block
 block discarded – undo
190 190
         $hasNamedArguments = false;
191 191
         $arguments = [];
192 192
 
193
-        foreach ($attr->args as $argument) {
193
+        foreach ($attr->args as $argument){
194 194
             $value = $eval->evaluateDirectly($argument->value);
195 195
 
196
-            if ($argument->name === null) {
196
+            if ($argument->name === null){
197 197
                 $arguments[] = $value;
198 198
 
199
-                if ($hasNamedArguments) {
199
+                if ($hasNamedArguments){
200 200
                     $exception = new ParseError(self::ERROR_NAMED_ARGUMENTS_ORDER);
201 201
                     throw Exception::withLocation($exception, $file, $argument->getStartLine());
202 202
                 }
Please login to merge, or discard this patch.
Braces   +22 added lines, -11 removed lines patch added patch discarded remove patch
@@ -110,8 +110,10 @@  discard block
 block discarded – undo
110 110
     {
111 111
         $eval = new ConstExprEvaluator($this->evaluator($file, $context));
112 112
 
113
-        foreach ($groups as $group) {
114
-            foreach ($group->attrs as $attr) {
113
+        foreach ($groups as $group)
114
+        {
115
+            foreach ($group->attrs as $attr)
116
+            {
115 117
                 $arguments = $this->parseAttributeArguments($attr, $file, $eval);
116 118
 
117 119
                 yield new AttributePrototype($attr->name->toString(), $arguments);
@@ -128,7 +130,8 @@  discard block
 block discarded – undo
128 130
 
129 131
     private function read(string $file): string
130 132
     {
131
-        if (!\is_readable($file)) {
133
+        if (!\is_readable($file))
134
+        {
132 135
             throw new InvalidArgumentException('Unable to read file "' . $file . '"');
133 136
         }
134 137
 
@@ -137,8 +140,10 @@  discard block
 block discarded – undo
137 140
 
138 141
     private function evaluator(string $file, array $context): Closure
139 142
     {
140
-        return static function (Expr $expr) use ($file, $context) {
141
-            switch (\get_class($expr)) {
143
+        return static function (Expr $expr) use ($file, $context)
144
+        {
145
+            switch (\get_class($expr))
146
+            {
142 147
                 case File::class:
143 148
                     return $file;
144 149
 
@@ -158,13 +163,15 @@  discard block
 block discarded – undo
158 163
                     $constant = $expr->name->toString();
159 164
                     $class = $expr->class->toString();
160 165
 
161
-                    if (\strtolower($constant) === 'class') {
166
+                    if (\strtolower($constant) === 'class')
167
+                    {
162 168
                         return $class;
163 169
                     }
164 170
 
165 171
                     $definition = $class . '::' . $constant;
166 172
 
167
-                    if (!\defined($definition)) {
173
+                    if (!\defined($definition))
174
+                    {
168 175
                         $exception = new ParseError(\sprintf(self::ERROR_BAD_CONSTANT, $definition));
169 176
                         throw Exception::withLocation($exception, $file, $expr->getStartLine());
170 177
                     }
@@ -172,7 +179,8 @@  discard block
 block discarded – undo
172 179
                     return \constant($definition);
173 180
             }
174 181
 
175
-            if ($expr instanceof MagicConst) {
182
+            if ($expr instanceof MagicConst)
183
+            {
176 184
                 return $context[$expr->getName()] ?? '';
177 185
             }
178 186
 
@@ -190,13 +198,16 @@  discard block
 block discarded – undo
190 198
         $hasNamedArguments = false;
191 199
         $arguments = [];
192 200
 
193
-        foreach ($attr->args as $argument) {
201
+        foreach ($attr->args as $argument)
202
+        {
194 203
             $value = $eval->evaluateDirectly($argument->value);
195 204
 
196
-            if ($argument->name === null) {
205
+            if ($argument->name === null)
206
+            {
197 207
                 $arguments[] = $value;
198 208
 
199
-                if ($hasNamedArguments) {
209
+                if ($hasNamedArguments)
210
+                {
200 211
                     $exception = new ParseError(self::ERROR_NAMED_ARGUMENTS_ORDER);
201 212
                     throw Exception::withLocation($exception, $file, $argument->getStartLine());
202 213
                 }
Please login to merge, or discard this patch.
src/Cookies/src/Cookie.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
         bool $secure = false,
117 117
         bool $httpOnly = true,
118 118
         ?string $sameSite = null
119
-    ) {
119
+    ){
120 120
         $this->name = $name;
121 121
         $this->value = $value;
122 122
         $this->lifetime = $lifetime;
@@ -221,30 +221,30 @@  discard block
 block discarded – undo
221 221
      */
222 222
     public function createHeader(): string
223 223
     {
224
-        $header = [rawurlencode($this->name) . '=' . rawurlencode((string)$this->value)];
224
+        $header = [rawurlencode($this->name).'='.rawurlencode((string)$this->value)];
225 225
 
226
-        if ($this->lifetime !== null) {
227
-            $header[] = 'Expires=' . gmdate(DateTime::COOKIE, $this->getExpires());
226
+        if ($this->lifetime !== null){
227
+            $header[] = 'Expires='.gmdate(DateTime::COOKIE, $this->getExpires());
228 228
             $header[] = "Max-Age={$this->lifetime}";
229 229
         }
230 230
 
231
-        if (!empty($this->path)) {
231
+        if (!empty($this->path)){
232 232
             $header[] = "Path={$this->path}";
233 233
         }
234 234
 
235
-        if (!empty($this->domain)) {
235
+        if (!empty($this->domain)){
236 236
             $header[] = "Domain={$this->domain}";
237 237
         }
238 238
 
239
-        if ($this->secure) {
239
+        if ($this->secure){
240 240
             $header[] = 'Secure';
241 241
         }
242 242
 
243
-        if ($this->httpOnly) {
243
+        if ($this->httpOnly){
244 244
             $header[] = 'HttpOnly';
245 245
         }
246 246
 
247
-        if ($this->sameSite->get() !== null) {
247
+        if ($this->sameSite->get() !== null){
248 248
             $header[] = "SameSite={$this->sameSite->get()}";
249 249
         }
250 250
 
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
      */
259 259
     public function getExpires(): ?int
260 260
     {
261
-        if ($this->lifetime === null) {
261
+        if ($this->lifetime === null){
262 262
             return null;
263 263
         }
264 264
 
Please login to merge, or discard this patch.
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -223,28 +223,34 @@  discard block
 block discarded – undo
223 223
     {
224 224
         $header = [rawurlencode($this->name) . '=' . rawurlencode((string)$this->value)];
225 225
 
226
-        if ($this->lifetime !== null) {
226
+        if ($this->lifetime !== null)
227
+        {
227 228
             $header[] = 'Expires=' . gmdate(DateTime::COOKIE, $this->getExpires());
228 229
             $header[] = "Max-Age={$this->lifetime}";
229 230
         }
230 231
 
231
-        if (!empty($this->path)) {
232
+        if (!empty($this->path))
233
+        {
232 234
             $header[] = "Path={$this->path}";
233 235
         }
234 236
 
235
-        if (!empty($this->domain)) {
237
+        if (!empty($this->domain))
238
+        {
236 239
             $header[] = "Domain={$this->domain}";
237 240
         }
238 241
 
239
-        if ($this->secure) {
242
+        if ($this->secure)
243
+        {
240 244
             $header[] = 'Secure';
241 245
         }
242 246
 
243
-        if ($this->httpOnly) {
247
+        if ($this->httpOnly)
248
+        {
244 249
             $header[] = 'HttpOnly';
245 250
         }
246 251
 
247
-        if ($this->sameSite->get() !== null) {
252
+        if ($this->sameSite->get() !== null)
253
+        {
248 254
             $header[] = "SameSite={$this->sameSite->get()}";
249 255
         }
250 256
 
@@ -258,7 +264,8 @@  discard block
 block discarded – undo
258 264
      */
259 265
     public function getExpires(): ?int
260 266
     {
261
-        if ($this->lifetime === null) {
267
+        if ($this->lifetime === null)
268
+        {
262 269
             return null;
263 270
         }
264 271
 
Please login to merge, or discard this patch.