Passed
Pull Request — master (#1045)
by Aleksei
10:05
created
src/Core/tests/Scope/Stub/Context.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@
 block discarded – undo
7 7
 final class Context implements ContextInterface
8 8
 {
9 9
     public function __construct(
10
-        public \Stringable|string|null $value,
11
-    ) {
10
+        public \Stringable | string | null $value,
11
+    ){
12 12
     }
13 13
 
14
-    public function getValue(): \Stringable|string|null
14
+    public function getValue(): \Stringable | string | null
15 15
     {
16 16
         return $this->value;
17 17
     }
Please login to merge, or discard this patch.
src/Core/tests/Scope/Stub/ContextInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,5 +6,5 @@
 block discarded – undo
6 6
 
7 7
 interface ContextInterface
8 8
 {
9
-    public function getValue(): \Stringable|string|null;
9
+    public function getValue(): \Stringable | string | null;
10 10
 }
Please login to merge, or discard this patch.
src/Core/tests/Scope/ProxyTest.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
                     // from the current `foo` scope
43 43
                     self::assertInstanceOf(KVLogger::class, $logger);
44 44
 
45
-                    for ($i = 0; $i < 10; $i++) {
45
+                    for ($i = 0; $i < 10; $i++){
46 46
                         // because of proxy
47 47
                         self::assertNotInstanceOf(KVLogger::class, $carrier->getLogger());
48 48
                         self::assertSame('kv', $carrier->logger->getName());
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
                     // from the current `foo` scope
63 63
                     self::assertInstanceOf(FileLogger::class, $logger);
64 64
 
65
-                    for ($i = 0; $i < 10; $i++) {
65
+                    for ($i = 0; $i < 10; $i++){
66 66
                         // because of proxy
67 67
                         self::assertNotInstanceOf(FileLogger::class, $carrier->getLogger());
68 68
                         self::assertSame('file', $carrier->logger->getName());
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
         $root = new Container();
80 80
         $root->getBinder('http')->bindSingleton(LoggerInterface::class, KVLogger::class);
81 81
 
82
-        $root->runScope(new Scope(), static function (Container $c1) {
82
+        $root->runScope(new Scope(), static function (Container $c1){
83 83
             $c1->runScope(
84 84
                 new Scope(name: 'http'),
85 85
                 static function (
86 86
                     ScopedProxyLoggerCarrier $carrier,
87 87
                     ScopedProxyLoggerCarrier $carrier2,
88 88
                     LoggerInterface $logger
89
-                ) {
89
+                ){
90 90
                     // from the current `foo` scope
91 91
                     self::assertInstanceOf(KVLogger::class, $logger);
92 92
 
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
         $root = new Container();
107 107
         $root->getBinder('foo')->bind(LoggerInterface::class, KVLogger::class);
108 108
 
109
-        $root->runScope(new Scope(), static function (Container $c1) {
109
+        $root->runScope(new Scope(), static function (Container $c1){
110 110
             $c1->runScope(
111 111
                 new Scope(name: 'foo'),
112
-                static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) {
112
+                static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger){
113 113
                     // from the current `foo` scope
114 114
                     self::assertInstanceOf(KVLogger::class, $logger);
115 115
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
             ->bind(
131 131
                 ContextInterface::class,
132 132
                 new \Spiral\Core\Config\Injectable(
133
-                    new class implements InjectorInterface {
133
+                    new class implements InjectorInterface{
134 134
                         public function createInjection(\ReflectionClass $class, mixed $context = null): Context
135 135
                         {
136 136
                             return new Context($context);
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
                 )
140 140
             );
141 141
 
142
-        $root->runScope(new Scope(), static function (Container $c1) {
143
-            $c1->runScope(new Scope(name: 'foo'), static function (Container $c, ContextInterface $param) {
142
+        $root->runScope(new Scope(), static function (Container $c1){
143
+            $c1->runScope(new Scope(name: 'foo'), static function (Container $c, ContextInterface $param){
144 144
                 self::assertInstanceOf(ReflectionParameter::class, $param->value);
145 145
                 self::assertSame('param', $param->value->getName());
146 146
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
             ->bind(
172 172
                 ContextInterface::class,
173 173
                 new \Spiral\Core\Config\Injectable(
174
-                    new class implements InjectorInterface {
174
+                    new class implements InjectorInterface{
175 175
                         public function createInjection(\ReflectionClass $class, mixed $context = null): Context
176 176
                         {
177 177
                             return new Context($context);
@@ -181,15 +181,15 @@  discard block
 block discarded – undo
181 181
             );
182 182
 
183 183
         FiberHelper::runFiberSequence(
184
-            static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $ctx) {
185
-                for ($i = 0; $i < 10; $i++) {
184
+            static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $ctx){
185
+                for ($i = 0; $i < 10; $i++){
186 186
                     self::assertInstanceOf(ReflectionParameter::class, $ctx->getValue(), 'Context injected');
187 187
                     self::assertSame('ctx', $ctx->getValue()->getName());
188 188
                     \Fiber::suspend();
189 189
                 }
190 190
             }),
191
-            static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $context) {
192
-                for ($i = 0; $i < 10; $i++) {
191
+            static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $context){
192
+                for ($i = 0; $i < 10; $i++){
193 193
                     self::assertInstanceOf(ReflectionParameter::class, $context->getValue(), 'Context injected');
194 194
                     self::assertSame('context', $context->getValue()->getName());
195 195
                     \Fiber::suspend();
Please login to merge, or discard this patch.
Braces   +34 added lines, -17 removed lines patch added patch discarded remove patch
@@ -38,11 +38,13 @@  discard block
 block discarded – undo
38 38
                         LoggerInterface::class => KVLogger::class,
39 39
                     ],
40 40
                 ),
41
-                static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) use ($lc) {
41
+                static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) use ($lc)
42
+                {
42 43
                     // from the current `foo` scope
43 44
                     self::assertInstanceOf(KVLogger::class, $logger);
44 45
 
45
-                    for ($i = 0; $i < 10; $i++) {
46
+                    for ($i = 0; $i < 10; $i++)
47
+                    {
46 48
                         // because of proxy
47 49
                         self::assertNotInstanceOf(KVLogger::class, $carrier->getLogger());
48 50
                         self::assertSame('kv', $carrier->logger->getName());
@@ -58,11 +60,13 @@  discard block
 block discarded – undo
58 60
                         LoggerInterface::class => FileLogger::class,
59 61
                     ],
60 62
                 ),
61
-                static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) use ($lc) {
63
+                static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) use ($lc)
64
+                {
62 65
                     // from the current `foo` scope
63 66
                     self::assertInstanceOf(FileLogger::class, $logger);
64 67
 
65
-                    for ($i = 0; $i < 10; $i++) {
68
+                    for ($i = 0; $i < 10; $i++)
69
+                    {
66 70
                         // because of proxy
67 71
                         self::assertNotInstanceOf(FileLogger::class, $carrier->getLogger());
68 72
                         self::assertSame('file', $carrier->logger->getName());
@@ -79,7 +83,8 @@  discard block
 block discarded – undo
79 83
         $root = new Container();
80 84
         $root->getBinder('http')->bindSingleton(LoggerInterface::class, KVLogger::class);
81 85
 
82
-        $root->runScope(new Scope(), static function (Container $c1) {
86
+        $root->runScope(new Scope(), static function (Container $c1)
87
+        {
83 88
             $c1->runScope(
84 89
                 new Scope(name: 'http'),
85 90
                 static function (
@@ -106,10 +111,12 @@  discard block
 block discarded – undo
106 111
         $root = new Container();
107 112
         $root->getBinder('foo')->bind(LoggerInterface::class, KVLogger::class);
108 113
 
109
-        $root->runScope(new Scope(), static function (Container $c1) {
114
+        $root->runScope(new Scope(), static function (Container $c1)
115
+        {
110 116
             $c1->runScope(
111 117
                 new Scope(name: 'foo'),
112
-                static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) {
118
+                static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger)
119
+                {
113 120
                     // from the current `foo` scope
114 121
                     self::assertInstanceOf(KVLogger::class, $logger);
115 122
 
@@ -130,7 +137,8 @@  discard block
 block discarded – undo
130 137
             ->bind(
131 138
                 ContextInterface::class,
132 139
                 new \Spiral\Core\Config\Injectable(
133
-                    new class implements InjectorInterface {
140
+                    new class implements InjectorInterface
141
+                    {
134 142
                         public function createInjection(\ReflectionClass $class, mixed $context = null): Context
135 143
                         {
136 144
                             return new Context($context);
@@ -139,8 +147,10 @@  discard block
 block discarded – undo
139 147
                 )
140 148
             );
141 149
 
142
-        $root->runScope(new Scope(), static function (Container $c1) {
143
-            $c1->runScope(new Scope(name: 'foo'), static function (Container $c, ContextInterface $param) {
150
+        $root->runScope(new Scope(), static function (Container $c1)
151
+        {
152
+            $c1->runScope(new Scope(name: 'foo'), static function (Container $c, ContextInterface $param)
153
+            {
144 154
                 self::assertInstanceOf(ReflectionParameter::class, $param->value);
145 155
                 self::assertSame('param', $param->value->getName());
146 156
 
@@ -171,7 +181,8 @@  discard block
 block discarded – undo
171 181
             ->bind(
172 182
                 ContextInterface::class,
173 183
                 new \Spiral\Core\Config\Injectable(
174
-                    new class implements InjectorInterface {
184
+                    new class implements InjectorInterface
185
+                    {
175 186
                         public function createInjection(\ReflectionClass $class, mixed $context = null): Context
176 187
                         {
177 188
                             return new Context($context);
@@ -181,15 +192,19 @@  discard block
 block discarded – undo
181 192
             );
182 193
 
183 194
         FiberHelper::runFiberSequence(
184
-            static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $ctx) {
185
-                for ($i = 0; $i < 10; $i++) {
195
+            static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $ctx)
196
+            {
197
+                for ($i = 0; $i < 10; $i++)
198
+                {
186 199
                     self::assertInstanceOf(ReflectionParameter::class, $ctx->getValue(), 'Context injected');
187 200
                     self::assertSame('ctx', $ctx->getValue()->getName());
188 201
                     \Fiber::suspend();
189 202
                 }
190 203
             }),
191
-            static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $context) {
192
-                for ($i = 0; $i < 10; $i++) {
204
+            static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $context)
205
+            {
206
+                for ($i = 0; $i < 10; $i++)
207
+                {
193 208
                     self::assertInstanceOf(ReflectionParameter::class, $context->getValue(), 'Context injected');
194 209
                     self::assertSame('context', $context->getValue()->getName());
195 210
                     \Fiber::suspend();
@@ -205,8 +220,10 @@  discard block
 block discarded – undo
205 220
 
206 221
         $root->runScope(
207 222
             new Scope(),
208
-            static function (#[Proxy] ContainerInterface $cp) use ($root) {
209
-                $root->runScope(new Scope(name: 'http'), static function (ContainerInterface $c) use ($cp) {
223
+            static function (#[Proxy] ContainerInterface $cp) use ($root)
224
+            {
225
+                $root->runScope(new Scope(name: 'http'), static function (ContainerInterface $c) use ($cp)
226
+                {
210 227
                     self::assertNotSame($c, $cp);
211 228
                     self::assertSame($c, $cp->get(ContainerInterface::class));
212 229
                     self::assertInstanceOf(KVLogger::class, $cp->get(LoggerInterface::class));
Please login to merge, or discard this patch.
src/Core/tests/Scope/SideEffectTest.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
         $root = new Container();
24 24
         $root->bind(LoggerInterface::class, KVLogger::class);
25 25
 
26
-        $root->runScope(new Scope(), static function (Container $c1) {
26
+        $root->runScope(new Scope(), static function (Container $c1){
27 27
             $c1->bind(LoggerInterface::class, FileLogger::class);
28 28
 
29
-            $c1->runScope(new Scope(), static function (LoggerCarrier $carrier, LoggerInterface $logger) {
29
+            $c1->runScope(new Scope(), static function (LoggerCarrier $carrier, LoggerInterface $logger){
30 30
                 // from the $root container
31 31
                 self::assertInstanceOf(KVLogger::class, $carrier->logger);
32 32
                 // from the $c1 container
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
         $root = new Container();
41 41
         $root->bind(LoggerInterface::class, KVLogger::class);
42 42
 
43
-        $root->runScope(new Scope(), static function (Container $c1) {
43
+        $root->runScope(new Scope(), static function (Container $c1){
44 44
             $c1->bind(LoggerInterface::class, FileLogger::class);
45 45
 
46 46
             self::assertInstanceOf(
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,10 +23,12 @@  discard block
 block discarded – undo
23 23
         $root = new Container();
24 24
         $root->bind(LoggerInterface::class, KVLogger::class);
25 25
 
26
-        $root->runScope(new Scope(), static function (Container $c1) {
26
+        $root->runScope(new Scope(), static function (Container $c1)
27
+        {
27 28
             $c1->bind(LoggerInterface::class, FileLogger::class);
28 29
 
29
-            $c1->runScope(new Scope(), static function (LoggerCarrier $carrier, LoggerInterface $logger) {
30
+            $c1->runScope(new Scope(), static function (LoggerCarrier $carrier, LoggerInterface $logger)
31
+            {
30 32
                 // from the $root container
31 33
                 self::assertInstanceOf(KVLogger::class, $carrier->logger);
32 34
                 // from the $c1 container
@@ -40,7 +42,8 @@  discard block
 block discarded – undo
40 42
         $root = new Container();
41 43
         $root->bind(LoggerInterface::class, KVLogger::class);
42 44
 
43
-        $root->runScope(new Scope(), static function (Container $c1) {
45
+        $root->runScope(new Scope(), static function (Container $c1)
46
+        {
44 47
             $c1->bind(LoggerInterface::class, FileLogger::class);
45 48
 
46 49
             self::assertInstanceOf(
Please login to merge, or discard this patch.
src/Core/src/Internal/Resolver.php 2 patches
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     ): array {
54 54
         $state = new ResolvingState($reflection, $parameters);
55 55
 
56
-        foreach ($reflection->getParameters() as $parameter) {
56
+        foreach ($reflection->getParameters() as $parameter){
57 57
             $this->resolveParameter($parameter, $state, $validate)
58 58
             or
59 59
             throw new ArgumentResolvingException($reflection, $parameter->getName());
@@ -67,47 +67,47 @@  discard block
 block discarded – undo
67 67
         $positional = true;
68 68
         $variadic = false;
69 69
         $parameters = $reflection->getParameters();
70
-        if (\count($parameters) === 0) {
70
+        if (\count($parameters) === 0){
71 71
             return;
72 72
         }
73 73
 
74 74
         $parameter = null;
75
-        while (\count($parameters) > 0 || \count($arguments) > 0) {
75
+        while (\count($parameters) > 0 || \count($arguments) > 0){
76 76
             // get related argument value
77 77
             $key = \key($arguments);
78 78
 
79 79
             // For a variadic parameter it's no sense - named or positional argument will be sent
80 80
             // But you can't send positional argument after named in any case
81
-            if (\is_int($key) && !$positional) {
81
+            if (\is_int($key) && !$positional){
82 82
                 throw new PositionalArgumentException($reflection, $key);
83 83
             }
84 84
 
85 85
             $positional = $positional && \is_int($key);
86 86
 
87
-            if (!$variadic) {
87
+            if (!$variadic){
88 88
                 $parameter = \array_shift($parameters);
89 89
                 $variadic = $parameter?->isVariadic() ?? false;
90 90
             }
91 91
 
92
-            if ($parameter === null) {
92
+            if ($parameter === null){
93 93
                 throw new UnknownParameterException($reflection, $key);
94 94
             }
95 95
             $name = $parameter->getName();
96 96
 
97
-            if (($positional || $variadic) && $key !== null) {
97
+            if (($positional || $variadic) && $key !== null){
98 98
                 /** @psalm-suppress ReferenceReusedFromConfusingScope */
99 99
                 $value = \array_shift($arguments);
100
-            } elseif ($key === null || !\array_key_exists($name, $arguments)) {
101
-                if ($parameter->isOptional()) {
100
+            } elseif ($key === null || !\array_key_exists($name, $arguments)){
101
+                if ($parameter->isOptional()){
102 102
                     continue;
103 103
                 }
104 104
                 throw new MissingRequiredArgumentException($reflection, $name);
105
-            } else {
105
+            }else{
106 106
                 $value = &$arguments[$name];
107 107
                 unset($arguments[$name]);
108 108
             }
109 109
 
110
-            if (!$this->validateValueToParameter($parameter, $value)) {
110
+            if (!$this->validateValueToParameter($parameter, $value)){
111 111
                 throw new InvalidArgumentException($reflection, $name);
112 112
             }
113 113
         }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 
116 116
     private function validateValueToParameter(ReflectionParameter $parameter, mixed $value): bool
117 117
     {
118
-        if (!$parameter->hasType() || ($parameter->allowsNull() && $value === null)) {
118
+        if (!$parameter->hasType() || ($parameter->allowsNull() && $value === null)){
119 119
             return true;
120 120
         }
121 121
         $type = $parameter->getType();
@@ -126,17 +126,17 @@  discard block
 block discarded – undo
126 126
             $type instanceof ReflectionIntersectionType => [false, $type->getTypes()],
127 127
         };
128 128
 
129
-        foreach ($types as $t) {
129
+        foreach ($types as $t){
130 130
             \assert($t instanceof ReflectionNamedType);
131
-            if (!$this->validateValueNamedType($t, $value)) {
131
+            if (!$this->validateValueNamedType($t, $value)){
132 132
                 // If it is TypeIntersection
133
-                if ($or) {
133
+                if ($or){
134 134
                     continue;
135 135
                 }
136 136
                 return false;
137 137
             }
138 138
             // If it is not type intersection then we can skip that value after first successful check
139
-            if ($or) {
139
+            if ($or){
140 140
                 return true;
141 141
             }
142 142
         }
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
     {
152 152
         $name = $type->getName();
153 153
 
154
-        if ($type->isBuiltin()) {
154
+        if ($type->isBuiltin()){
155 155
             return match ($name) {
156 156
                 'mixed' => true,
157 157
                 'string' => \is_string($value),
@@ -184,13 +184,13 @@  discard block
 block discarded – undo
184 184
 
185 185
         // Try to resolve parameter by name
186 186
         $res = $state->resolveParameterByNameOrPosition($param, $isVariadic);
187
-        if ($res !== [] || $isVariadic) {
187
+        if ($res !== [] || $isVariadic){
188 188
             // validate
189
-            if ($isVariadic) {
190
-                foreach ($res as $k => &$v) {
191
-                    $this->processArgument($state, $v, validateWith: $validate ? $param : null, key: $k);
189
+            if ($isVariadic){
190
+                foreach ($res as $k => &$v){
191
+                    $this->processArgument($state, $v, validateWith: $validate ? $param : null, key : $k);
192 192
                 }
193
-            } else {
193
+            }else{
194 194
                 $this->processArgument($state, $res[0], validateWith: $validate ? $param : null);
195 195
             }
196 196
 
@@ -198,41 +198,41 @@  discard block
 block discarded – undo
198 198
         }
199 199
 
200 200
         $error = null;
201
-        while ($hasType) {
201
+        while ($hasType){
202 202
             /** @var ReflectionIntersectionType|ReflectionUnionType|ReflectionNamedType $refType */
203 203
             $refType = $param->getType();
204 204
 
205
-            if ($refType::class === ReflectionNamedType::class) {
206
-                if ($refType->isBuiltin()) {
205
+            if ($refType::class === ReflectionNamedType::class){
206
+                if ($refType->isBuiltin()){
207 207
                     break;
208 208
                 }
209 209
 
210 210
                 if (\interface_exists($refType->getName()) && !empty(
211 211
                     $attrs = $param->getAttributes(ProxyAttribute::class)
212
-                )) {
212
+                )){
213 213
                     $proxy = Proxy::create(
214 214
                         new \ReflectionClass($refType->getName()), $param, $attrs[0]->newInstance());
215 215
                     $this->processArgument($state, $proxy);
216 216
                     return true;
217 217
                 }
218 218
 
219
-                try {
220
-                    if ($this->resolveObject($state, $refType, $param, $validate)) {
219
+                try{
220
+                    if ($this->resolveObject($state, $refType, $param, $validate)){
221 221
                         return true;
222 222
                     }
223
-                } catch (Throwable $e) {
223
+                }catch (Throwable $e){
224 224
                     $error = $e;
225 225
                 }
226 226
                 break;
227 227
             }
228 228
 
229
-            if ($refType::class === ReflectionUnionType::class) {
230
-                foreach ($refType->getTypes() as $namedType) {
231
-                    try {
232
-                        if (!$namedType->isBuiltin() && $this->resolveObject($state, $namedType, $param, $validate)) {
229
+            if ($refType::class === ReflectionUnionType::class){
230
+                foreach ($refType->getTypes() as $namedType){
231
+                    try{
232
+                        if (!$namedType->isBuiltin() && $this->resolveObject($state, $namedType, $param, $validate)){
233 233
                             return true;
234 234
                         }
235
-                    } catch (Throwable $e) {
235
+                    }catch (Throwable $e){
236 236
                         $error = $e;
237 237
                     }
238 238
                 }
@@ -242,19 +242,19 @@  discard block
 block discarded – undo
242 242
             throw new UnsupportedTypeException($param->getDeclaringFunction(), $param->getName());
243 243
         }
244 244
 
245
-        if ($param->isDefaultValueAvailable()) {
245
+        if ($param->isDefaultValueAvailable()){
246 246
             $argument = $param->getDefaultValue();
247 247
             $this->processArgument($state, $argument);
248 248
             return true;
249 249
         }
250 250
 
251
-        if ($hasType && $param->allowsNull()) {
251
+        if ($hasType && $param->allowsNull()){
252 252
             $argument = null;
253 253
             $this->processArgument($state, $argument);
254 254
             return true;
255 255
         }
256 256
 
257
-        if ($error === null) {
257
+        if ($error === null){
258 258
             return false;
259 259
         }
260 260
 
@@ -292,15 +292,15 @@  discard block
 block discarded – undo
292 292
         ResolvingState $state,
293 293
         mixed &$value,
294 294
         ReflectionParameter $validateWith = null,
295
-        int|string $key = null
295
+        int | string $key = null
296 296
     ): void {
297 297
         // Resolve Autowire objects
298
-        if ($value instanceof Autowire) {
298
+        if ($value instanceof Autowire){
299 299
             $value = $value->resolve($this->factory);
300 300
         }
301 301
 
302 302
         // Validation
303
-        if ($validateWith !== null && !$this->validateValueToParameter($validateWith, $value)) {
303
+        if ($validateWith !== null && !$this->validateValueToParameter($validateWith, $value)){
304 304
             throw new InvalidArgumentException(
305 305
                 $validateWith->getDeclaringFunction(),
306 306
                 $validateWith->getName()
Please login to merge, or discard this patch.
Braces   +81 added lines, -38 removed lines patch added patch discarded remove patch
@@ -53,7 +53,8 @@  discard block
 block discarded – undo
53 53
     ): array {
54 54
         $state = new ResolvingState($reflection, $parameters);
55 55
 
56
-        foreach ($reflection->getParameters() as $parameter) {
56
+        foreach ($reflection->getParameters() as $parameter)
57
+        {
57 58
             $this->resolveParameter($parameter, $state, $validate)
58 59
             or
59 60
             throw new ArgumentResolvingException($reflection, $parameter->getName());
@@ -67,47 +68,59 @@  discard block
 block discarded – undo
67 68
         $positional = true;
68 69
         $variadic = false;
69 70
         $parameters = $reflection->getParameters();
70
-        if (\count($parameters) === 0) {
71
+        if (\count($parameters) === 0)
72
+        {
71 73
             return;
72 74
         }
73 75
 
74 76
         $parameter = null;
75
-        while (\count($parameters) > 0 || \count($arguments) > 0) {
77
+        while (\count($parameters) > 0 || \count($arguments) > 0)
78
+        {
76 79
             // get related argument value
77 80
             $key = \key($arguments);
78 81
 
79 82
             // For a variadic parameter it's no sense - named or positional argument will be sent
80 83
             // But you can't send positional argument after named in any case
81
-            if (\is_int($key) && !$positional) {
84
+            if (\is_int($key) && !$positional)
85
+            {
82 86
                 throw new PositionalArgumentException($reflection, $key);
83 87
             }
84 88
 
85 89
             $positional = $positional && \is_int($key);
86 90
 
87
-            if (!$variadic) {
91
+            if (!$variadic)
92
+            {
88 93
                 $parameter = \array_shift($parameters);
89 94
                 $variadic = $parameter?->isVariadic() ?? false;
90 95
             }
91 96
 
92
-            if ($parameter === null) {
97
+            if ($parameter === null)
98
+            {
93 99
                 throw new UnknownParameterException($reflection, $key);
94 100
             }
95 101
             $name = $parameter->getName();
96 102
 
97
-            if (($positional || $variadic) && $key !== null) {
103
+            if (($positional || $variadic) && $key !== null)
104
+            {
98 105
                 /** @psalm-suppress ReferenceReusedFromConfusingScope */
99 106
                 $value = \array_shift($arguments);
100
-            } elseif ($key === null || !\array_key_exists($name, $arguments)) {
101
-                if ($parameter->isOptional()) {
107
+            }
108
+            elseif ($key === null || !\array_key_exists($name, $arguments))
109
+            {
110
+                if ($parameter->isOptional())
111
+                {
102 112
                     continue;
103 113
                 }
104 114
                 throw new MissingRequiredArgumentException($reflection, $name);
105
-            } else {
115
+            }
116
+            else
117
+            {
106 118
                 $value = &$arguments[$name];
107 119
                 unset($arguments[$name]);
108 120
             }
109 121
 
110
-            if (!$this->validateValueToParameter($parameter, $value)) {
122
+            if (!$this->validateValueToParameter($parameter, $value))
123
+            {
111 124
                 throw new InvalidArgumentException($reflection, $name);
112 125
             }
113 126
         }
@@ -115,7 +128,8 @@  discard block
 block discarded – undo
115 128
 
116 129
     private function validateValueToParameter(ReflectionParameter $parameter, mixed $value): bool
117 130
     {
118
-        if (!$parameter->hasType() || ($parameter->allowsNull() && $value === null)) {
131
+        if (!$parameter->hasType() || ($parameter->allowsNull() && $value === null))
132
+        {
119 133
             return true;
120 134
         }
121 135
         $type = $parameter->getType();
@@ -126,17 +140,21 @@  discard block
 block discarded – undo
126 140
             $type instanceof ReflectionIntersectionType => [false, $type->getTypes()],
127 141
         };
128 142
 
129
-        foreach ($types as $t) {
143
+        foreach ($types as $t)
144
+        {
130 145
             \assert($t instanceof ReflectionNamedType);
131
-            if (!$this->validateValueNamedType($t, $value)) {
146
+            if (!$this->validateValueNamedType($t, $value))
147
+            {
132 148
                 // If it is TypeIntersection
133
-                if ($or) {
149
+                if ($or)
150
+                {
134 151
                     continue;
135 152
                 }
136 153
                 return false;
137 154
             }
138 155
             // If it is not type intersection then we can skip that value after first successful check
139
-            if ($or) {
156
+            if ($or)
157
+            {
140 158
                 return true;
141 159
             }
142 160
         }
@@ -151,7 +169,8 @@  discard block
 block discarded – undo
151 169
     {
152 170
         $name = $type->getName();
153 171
 
154
-        if ($type->isBuiltin()) {
172
+        if ($type->isBuiltin())
173
+        {
155 174
             return match ($name) {
156 175
                 'mixed' => true,
157 176
                 'string' => \is_string($value),
@@ -184,13 +203,18 @@  discard block
 block discarded – undo
184 203
 
185 204
         // Try to resolve parameter by name
186 205
         $res = $state->resolveParameterByNameOrPosition($param, $isVariadic);
187
-        if ($res !== [] || $isVariadic) {
206
+        if ($res !== [] || $isVariadic)
207
+        {
188 208
             // validate
189
-            if ($isVariadic) {
190
-                foreach ($res as $k => &$v) {
209
+            if ($isVariadic)
210
+            {
211
+                foreach ($res as $k => &$v)
212
+                {
191 213
                     $this->processArgument($state, $v, validateWith: $validate ? $param : null, key: $k);
192 214
                 }
193
-            } else {
215
+            }
216
+            else
217
+            {
194 218
                 $this->processArgument($state, $res[0], validateWith: $validate ? $param : null);
195 219
             }
196 220
 
@@ -198,41 +222,55 @@  discard block
 block discarded – undo
198 222
         }
199 223
 
200 224
         $error = null;
201
-        while ($hasType) {
225
+        while ($hasType)
226
+        {
202 227
             /** @var ReflectionIntersectionType|ReflectionUnionType|ReflectionNamedType $refType */
203 228
             $refType = $param->getType();
204 229
 
205
-            if ($refType::class === ReflectionNamedType::class) {
206
-                if ($refType->isBuiltin()) {
230
+            if ($refType::class === ReflectionNamedType::class)
231
+            {
232
+                if ($refType->isBuiltin())
233
+                {
207 234
                     break;
208 235
                 }
209 236
 
210 237
                 if (\interface_exists($refType->getName()) && !empty(
211 238
                     $attrs = $param->getAttributes(ProxyAttribute::class)
212
-                )) {
239
+                ))
240
+                {
213 241
                     $proxy = Proxy::create(
214 242
                         new \ReflectionClass($refType->getName()), $param, $attrs[0]->newInstance());
215 243
                     $this->processArgument($state, $proxy);
216 244
                     return true;
217 245
                 }
218 246
 
219
-                try {
220
-                    if ($this->resolveObject($state, $refType, $param, $validate)) {
247
+                try
248
+                {
249
+                    if ($this->resolveObject($state, $refType, $param, $validate))
250
+                    {
221 251
                         return true;
222 252
                     }
223
-                } catch (Throwable $e) {
253
+                }
254
+                catch (Throwable $e)
255
+                {
224 256
                     $error = $e;
225 257
                 }
226 258
                 break;
227 259
             }
228 260
 
229
-            if ($refType::class === ReflectionUnionType::class) {
230
-                foreach ($refType->getTypes() as $namedType) {
231
-                    try {
232
-                        if (!$namedType->isBuiltin() && $this->resolveObject($state, $namedType, $param, $validate)) {
261
+            if ($refType::class === ReflectionUnionType::class)
262
+            {
263
+                foreach ($refType->getTypes() as $namedType)
264
+                {
265
+                    try
266
+                    {
267
+                        if (!$namedType->isBuiltin() && $this->resolveObject($state, $namedType, $param, $validate))
268
+                        {
233 269
                             return true;
234 270
                         }
235
-                    } catch (Throwable $e) {
271
+                    }
272
+                    catch (Throwable $e)
273
+                    {
236 274
                         $error = $e;
237 275
                     }
238 276
                 }
@@ -242,19 +280,22 @@  discard block
 block discarded – undo
242 280
             throw new UnsupportedTypeException($param->getDeclaringFunction(), $param->getName());
243 281
         }
244 282
 
245
-        if ($param->isDefaultValueAvailable()) {
283
+        if ($param->isDefaultValueAvailable())
284
+        {
246 285
             $argument = $param->getDefaultValue();
247 286
             $this->processArgument($state, $argument);
248 287
             return true;
249 288
         }
250 289
 
251
-        if ($hasType && $param->allowsNull()) {
290
+        if ($hasType && $param->allowsNull())
291
+        {
252 292
             $argument = null;
253 293
             $this->processArgument($state, $argument);
254 294
             return true;
255 295
         }
256 296
 
257
-        if ($error === null) {
297
+        if ($error === null)
298
+        {
258 299
             return false;
259 300
         }
260 301
 
@@ -295,12 +336,14 @@  discard block
 block discarded – undo
295 336
         int|string $key = null
296 337
     ): void {
297 338
         // Resolve Autowire objects
298
-        if ($value instanceof Autowire) {
339
+        if ($value instanceof Autowire)
340
+        {
299 341
             $value = $value->resolve($this->factory);
300 342
         }
301 343
 
302 344
         // Validation
303
-        if ($validateWith !== null && !$this->validateValueToParameter($validateWith, $value)) {
345
+        if ($validateWith !== null && !$this->validateValueToParameter($validateWith, $value))
346
+        {
304 347
             throw new InvalidArgumentException(
305 348
                 $validateWith->getDeclaringFunction(),
306 349
                 $validateWith->getName()
Please login to merge, or discard this patch.
src/Core/src/Internal/Proxy.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
      */
23 23
     public static function create(
24 24
         \ReflectionClass $type,
25
-        \Stringable|string|null $context,
25
+        \Stringable | string | null $context,
26 26
         \Spiral\Core\Attribute\Proxy $attribute,
27 27
     ): object {
28 28
         $interface = $type->getName();
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
             $attribute->proxyOverloads ? '[magic-calls]' : '',
38 38
         );
39 39
 
40
-        if (!\array_key_exists($cacheKey, self::$cache)) {
40
+        if (!\array_key_exists($cacheKey, self::$cache)){
41 41
             $n = 0;
42
-            do {
42
+            do{
43 43
                 /** @var class-string<TClass> $className */
44 44
                 $className = \sprintf(
45 45
                     '%s\%s SCOPED PROXY%s',
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
                     $type->getShortName(),
48 48
                     $n++ > 0 ? " {$n}" : ''
49 49
                 );
50
-            } while (\class_exists($className));
50
+            }while (\class_exists($className));
51 51
 
52
-            try {
52
+            try{
53 53
                 $classString = ProxyClassRenderer::renderClass(
54 54
                     $type,
55 55
                     $className,
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
                 );
59 59
 
60 60
                 eval($classString);
61
-            } catch (\Throwable $e) {
61
+            }catch (\Throwable $e){
62 62
                 throw new \Error("Unable to create proxy for `{$interface}`: {$e->getMessage()}", 0, $e);
63 63
             }
64 64
 
@@ -67,12 +67,12 @@  discard block
 block discarded – undo
67 67
 
68 68
             // Store in cache without context
69 69
             self::$cache[$cacheKey] = $instance;
70
-        } else {
70
+        }else{
71 71
             /** @var TClass $instance */
72 72
             $instance = self::$cache[$cacheKey];
73 73
         }
74 74
 
75
-        if ($context !== null || $attachContainer) {
75
+        if ($context !== null || $attachContainer){
76 76
             $instance = clone $instance;
77 77
             (static function () use ($instance, $context, $attachContainer): void {
78 78
                 // Set the Current Context
Please login to merge, or discard this patch.
Braces   +14 added lines, -6 removed lines patch added patch discarded remove patch
@@ -37,9 +37,11 @@  discard block
 block discarded – undo
37 37
             $attribute->proxyOverloads ? '[magic-calls]' : '',
38 38
         );
39 39
 
40
-        if (!\array_key_exists($cacheKey, self::$cache)) {
40
+        if (!\array_key_exists($cacheKey, self::$cache))
41
+        {
41 42
             $n = 0;
42
-            do {
43
+            do
44
+            {
43 45
                 /** @var class-string<TClass> $className */
44 46
                 $className = \sprintf(
45 47
                     '%s\%s SCOPED PROXY%s',
@@ -49,7 +51,8 @@  discard block
 block discarded – undo
49 51
                 );
50 52
             } while (\class_exists($className));
51 53
 
52
-            try {
54
+            try
55
+            {
53 56
                 $classString = ProxyClassRenderer::renderClass(
54 57
                     $type,
55 58
                     $className,
@@ -58,7 +61,9 @@  discard block
 block discarded – undo
58 61
                 );
59 62
 
60 63
                 eval($classString);
61
-            } catch (\Throwable $e) {
64
+            }
65
+            catch (\Throwable $e)
66
+            {
62 67
                 throw new \Error("Unable to create proxy for `{$interface}`: {$e->getMessage()}", 0, $e);
63 68
             }
64 69
 
@@ -67,12 +72,15 @@  discard block
 block discarded – undo
67 72
 
68 73
             // Store in cache without context
69 74
             self::$cache[$cacheKey] = $instance;
70
-        } else {
75
+        }
76
+        else
77
+        {
71 78
             /** @var TClass $instance */
72 79
             $instance = self::$cache[$cacheKey];
73 80
         }
74 81
 
75
-        if ($context !== null || $attachContainer) {
82
+        if ($context !== null || $attachContainer)
83
+        {
76 84
             $instance = clone $instance;
77 85
             (static function () use ($instance, $context, $attachContainer): void {
78 86
                 // Set the Current Context
Please login to merge, or discard this patch.
src/Core/src/Internal/Proxy/ProxyTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,6 +12,6 @@
 block discarded – undo
12 12
 trait ProxyTrait
13 13
 {
14 14
     private static string $__container_proxy_alias;
15
-    private \Stringable|string|null $__container_proxy_context = null;
15
+    private \Stringable | string | null $__container_proxy_context = null;
16 16
     private ?ContainerInterface $__container_proxy_container = null;
17 17
 }
Please login to merge, or discard this patch.
src/Core/src/Internal/Proxy/Resolver.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,16 +15,16 @@
 block discarded – undo
15 15
 {
16 16
     public static function resolve(
17 17
         string $alias,
18
-        \Stringable|string|null $context = null,
18
+        \Stringable | string | null $context = null,
19 19
         ?ContainerInterface $c = null
20 20
     ): object {
21 21
         $c ??= ContainerScope::getContainer() ?? throw new ContainerException('Proxy is out of scope.');
22 22
 
23
-        try {
23
+        try{
24 24
             $result = $c->get($alias, $context) ?? throw new ContainerException(
25 25
                 'Resolved `null` from the container.',
26 26
             );
27
-        } catch (\Throwable $e) {
27
+        }catch (\Throwable $e){
28 28
             throw new ContainerException(
29 29
                 \sprintf('Unable to resolve `%s` in a Proxy.', $alias),
30 30
                 previous: $e,
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,11 +20,14 @@
 block discarded – undo
20 20
     ): object {
21 21
         $c ??= ContainerScope::getContainer() ?? throw new ContainerException('Proxy is out of scope.');
22 22
 
23
-        try {
23
+        try
24
+        {
24 25
             $result = $c->get($alias, $context) ?? throw new ContainerException(
25 26
                 'Resolved `null` from the container.',
26 27
             );
27
-        } catch (\Throwable $e) {
28
+        }
29
+        catch (\Throwable $e)
30
+        {
28 31
             throw new ContainerException(
29 32
                 \sprintf('Unable to resolve `%s` in a Proxy.', $alias),
30 33
                 previous: $e,
Please login to merge, or discard this patch.
src/Core/src/Internal/Proxy/ProxyClassRenderer.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -27,24 +27,24 @@  discard block
 block discarded – undo
27 27
             MagicCallTrait::class,
28 28
         ] : [];
29 29
 
30
-        if (\str_contains($className, '\\')) {
30
+        if (\str_contains($className, '\\')){
31 31
             $classShortName = \substr($className, \strrpos($className, '\\') + 1);
32
-            $classNamespaceStr = 'namespace ' . \substr($className, 0, \strrpos($className, '\\')) . ';';
33
-        } else {
32
+            $classNamespaceStr = 'namespace '.\substr($className, 0, \strrpos($className, '\\')).';';
33
+        }else{
34 34
             $classShortName = $className;
35 35
             $classNamespaceStr = '';
36 36
         }
37 37
 
38 38
         $interface = $type->getName();
39 39
         $classBody = [];
40
-        foreach ($type->getMethods() as $method) {
41
-            if ($method->isConstructor()) {
40
+        foreach ($type->getMethods() as $method){
41
+            if ($method->isConstructor()){
42 42
                 continue;
43 43
             }
44 44
 
45 45
             $hasRefs = false;
46 46
             $return = $method->hasReturnType() && (string)$method->getReturnType() === 'void' ? '' : 'return ';
47
-            $call = ($method->isStatic() ? '::' : '->') . $method->getName();
47
+            $call = ($method->isStatic() ? '::' : '->').$method->getName();
48 48
             $context = $method->isStatic() ? 'null' : '$this->__container_proxy_context';
49 49
             $containerStr = match (false) {
50 50
                 $attachContainer => 'null',
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
                 PHP;
65 65
 
66 66
             $args = [];
67
-            foreach ($method->getParameters() as $param) {
67
+            foreach ($method->getParameters() as $param){
68 68
                 $hasRefs = $hasRefs || $param->isPassedByReference();
69
-                $args[] = ($param->isVariadic() ? '...' : '') . '$' . $param->getName();
69
+                $args[] = ($param->isVariadic() ? '...' : '').'$'.$param->getName();
70 70
             }
71 71
 
72
-            if (!$hasRefs && !$method->isVariadic()) {
72
+            if (!$hasRefs && !$method->isVariadic()){
73 73
                 $classBody[] = self::renderMethod(
74 74
                     $method,
75 75
                     <<<PHP
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 
82 82
             $argsStr = \implode(', ', $args);
83 83
 
84
-            if ($method->isVariadic()) {
84
+            if ($method->isVariadic()){
85 85
                 $classBody[] = self::renderMethod(
86 86
                     $method,
87 87
                     <<<PHP
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 
104 104
         $traitsStr = $traits === [] ? '' : \implode(
105 105
             "\n    ",
106
-            \array_map(fn(string $trait): string => 'use \\' . \ltrim($trait, '\\') . ';', $traits)
106
+            \array_map(fn(string $trait) : string => 'use \\'.\ltrim($trait, '\\').';', $traits)
107 107
         );
108 108
         return <<<PHP
109 109
             $classNamespaceStr
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
             $m->getName(),
127 127
             \implode(', ', \array_map([self::class, 'renderParameter'], $m->getParameters())),
128 128
             $m->hasReturnType()
129
-                ? ': ' . self::renderParameterTypes($m->getReturnType(), $m->getDeclaringClass())
129
+                ? ': '.self::renderParameterTypes($m->getReturnType(), $m->getDeclaringClass())
130 130
                 : '',
131 131
             $body,
132 132
         );
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
                 $param->hasType() ? self::renderParameterTypes($param->getType(), $param->getDeclaringClass()) : '',
141 141
                 $param->isPassedByReference() ? '&' : '',
142 142
                 $param->isVariadic() ? '...' : '',
143
-                '$' . $param->getName(),
144
-                $param->isOptional() && !$param->isVariadic() ? ' = ' . self::renderDefaultValue($param) : '',
143
+                '$'.$param->getName(),
144
+                $param->isOptional() && !$param->isVariadic() ? ' = '.self::renderDefaultValue($param) : '',
145 145
             ),
146 146
             ' '
147 147
         );
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 
150 150
     public static function renderParameterTypes(\ReflectionType $types, \ReflectionClass $class): string
151 151
     {
152
-        if ($types instanceof \ReflectionNamedType) {
153
-            return ($types->allowsNull() && $types->getName() !== 'mixed' ? '?' : '') . ($types->isBuiltin()
152
+        if ($types instanceof \ReflectionNamedType){
153
+            return ($types->allowsNull() && $types->getName() !== 'mixed' ? '?' : '').($types->isBuiltin()
154 154
                     ? $types->getName()
155 155
                     : self::normalizeClassType($types, $class));
156 156
         }
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
         };
163 163
 
164 164
         $result = [];
165
-        foreach ($types as $type) {
165
+        foreach ($types as $type){
166 166
             $result[] = $type->isBuiltin()
167 167
                 ? $type->getName()
168 168
                 : self::normalizeClassType($type, $class);
@@ -173,12 +173,12 @@  discard block
 block discarded – undo
173 173
 
174 174
     public static function renderDefaultValue(\ReflectionParameter $param): string
175 175
     {
176
-        if ($param->isDefaultValueConstant()) {
176
+        if ($param->isDefaultValueConstant()){
177 177
             $result = $param->getDefaultValueConstantName();
178 178
 
179 179
             return \explode('::', $result)[0] === 'self'
180 180
                 ? $result
181
-                : '\\' . $result;
181
+                : '\\'.$result;
182 182
         }
183 183
 
184 184
         $cut = self::cutDefaultValue($param);
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 
191 191
     public static function normalizeClassType(\ReflectionNamedType $type, \ReflectionClass $class): string
192 192
     {
193
-        return '\\' . ($type->getName() === 'self' ? $class->getName() : $type->getName());
193
+        return '\\'.($type->getName() === 'self' ? $class->getName() : $type->getName());
194 194
     }
195 195
 
196 196
     private static function cutDefaultValue(\ReflectionParameter $param): string
Please login to merge, or discard this patch.
Braces   +21 added lines, -10 removed lines patch added patch discarded remove patch
@@ -27,18 +27,23 @@  discard block
 block discarded – undo
27 27
             MagicCallTrait::class,
28 28
         ] : [];
29 29
 
30
-        if (\str_contains($className, '\\')) {
30
+        if (\str_contains($className, '\\'))
31
+        {
31 32
             $classShortName = \substr($className, \strrpos($className, '\\') + 1);
32 33
             $classNamespaceStr = 'namespace ' . \substr($className, 0, \strrpos($className, '\\')) . ';';
33
-        } else {
34
+        }
35
+        else
36
+        {
34 37
             $classShortName = $className;
35 38
             $classNamespaceStr = '';
36 39
         }
37 40
 
38 41
         $interface = $type->getName();
39 42
         $classBody = [];
40
-        foreach ($type->getMethods() as $method) {
41
-            if ($method->isConstructor()) {
43
+        foreach ($type->getMethods() as $method)
44
+        {
45
+            if ($method->isConstructor())
46
+            {
42 47
                 continue;
43 48
             }
44 49
 
@@ -64,12 +69,14 @@  discard block
 block discarded – undo
64 69
                 PHP;
65 70
 
66 71
             $args = [];
67
-            foreach ($method->getParameters() as $param) {
72
+            foreach ($method->getParameters() as $param)
73
+            {
68 74
                 $hasRefs = $hasRefs || $param->isPassedByReference();
69 75
                 $args[] = ($param->isVariadic() ? '...' : '') . '$' . $param->getName();
70 76
             }
71 77
 
72
-            if (!$hasRefs && !$method->isVariadic()) {
78
+            if (!$hasRefs && !$method->isVariadic())
79
+            {
73 80
                 $classBody[] = self::renderMethod(
74 81
                     $method,
75 82
                     <<<PHP
@@ -81,7 +88,8 @@  discard block
 block discarded – undo
81 88
 
82 89
             $argsStr = \implode(', ', $args);
83 90
 
84
-            if ($method->isVariadic()) {
91
+            if ($method->isVariadic())
92
+            {
85 93
                 $classBody[] = self::renderMethod(
86 94
                     $method,
87 95
                     <<<PHP
@@ -149,7 +157,8 @@  discard block
 block discarded – undo
149 157
 
150 158
     public static function renderParameterTypes(\ReflectionType $types, \ReflectionClass $class): string
151 159
     {
152
-        if ($types instanceof \ReflectionNamedType) {
160
+        if ($types instanceof \ReflectionNamedType)
161
+        {
153 162
             return ($types->allowsNull() && $types->getName() !== 'mixed' ? '?' : '') . ($types->isBuiltin()
154 163
                     ? $types->getName()
155 164
                     : self::normalizeClassType($types, $class));
@@ -162,7 +171,8 @@  discard block
 block discarded – undo
162 171
         };
163 172
 
164 173
         $result = [];
165
-        foreach ($types as $type) {
174
+        foreach ($types as $type)
175
+        {
166 176
             $result[] = $type->isBuiltin()
167 177
                 ? $type->getName()
168 178
                 : self::normalizeClassType($type, $class);
@@ -173,7 +183,8 @@  discard block
 block discarded – undo
173 183
 
174 184
     public static function renderDefaultValue(\ReflectionParameter $param): string
175 185
     {
176
-        if ($param->isDefaultValueConstant()) {
186
+        if ($param->isDefaultValueConstant())
187
+        {
177 188
             $result = $param->getDefaultValueConstantName();
178 189
 
179 190
             return \explode('::', $result)[0] === 'self'
Please login to merge, or discard this patch.