Passed
Push — master ( 9d85cf...c2de74 )
by butschster
17:53 queued 11:39
created
src/Core/tests/Internal/Resolver/CommonCasesTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         $this->expectExceptionMessage('Enum `Spiral\Tests\Core\Stub\EnumObject` can not be constructed.');
64 64
 
65 65
         $this->resolveClosure(
66
-            static function (EnumObject $enum) {},
66
+            static function (EnumObject $enum){},
67 67
         );
68 68
     }
69 69
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
         );
76 76
 
77 77
         $this->resolveClosure(
78
-            static function (TestTrait $enum) {},
78
+            static function (TestTrait $enum){},
79 79
         );
80 80
     }
81 81
 }
Please login to merge, or discard this patch.
src/Core/src/Config.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
         public readonly string $binder = Binder::class,
41 41
         public readonly string $invoker = Invoker::class,
42 42
         public readonly string $tracer = Tracer::class,
43
-    ) {
43
+    ){
44 44
     }
45 45
 
46 46
     public function getIterator(): Traversable
Please login to merge, or discard this patch.
src/Core/src/Exception/Resolver/InvalidArgumentException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
     public function __construct(
14 14
         \ReflectionFunctionAbstract $reflection,
15 15
         private readonly string $parameter
16
-    ) {
16
+    ){
17 17
         $pattern = "Invalid argument value type for the `$parameter` parameter when validating arguments for `%s`.";
18 18
         parent::__construct($this->renderFunctionAndParameter($reflection, $pattern));
19 19
     }
Please login to merge, or discard this patch.
src/Core/tests/ExceptionsTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -131,9 +131,9 @@
 block discarded – undo
131 131
     {
132 132
         $container = new Container();
133 133
 
134
-        try {
134
+        try{
135 135
             $container->get('invalid');
136
-        } catch (ContainerException $e) {
136
+        }catch (ContainerException $e){
137 137
             $this->assertSame(
138 138
                 <<<MARKDOWN
139 139
                 Can't resolve `invalid`: undefined class or binding `invalid`.
Please login to merge, or discard this patch.
src/Core/src/Internal/Tracer.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 
19 19
     public function __toString(): string
20 20
     {
21
-        return $this->traces === [] ? '' : "Container trace list:\n" . $this->renderTraceList($this->traces);
21
+        return $this->traces === [] ? '' : "Container trace list:\n".$this->renderTraceList($this->traces);
22 22
     }
23 23
 
24 24
     /**
@@ -34,19 +34,19 @@  discard block
 block discarded – undo
34 34
     public function push(bool $nextLevel, mixed ...$details): void
35 35
     {
36 36
         $trace = $details === [] ? null : new Trace($details);
37
-        if ($nextLevel || $this->traces === []) {
37
+        if ($nextLevel || $this->traces === []){
38 38
             $this->traces[] = $trace === null ? [] : [$trace];
39
-        } elseif ($trace !== null) {
39
+        } elseif ($trace !== null){
40 40
             $this->traces[\array_key_last($this->traces)][] = $trace;
41 41
         }
42 42
     }
43 43
 
44 44
     public function pop(bool $previousLevel = false): void
45 45
     {
46
-        if ($this->traces === []) {
46
+        if ($this->traces === []){
47 47
             return;
48 48
         }
49
-        if ($previousLevel) {
49
+        if ($previousLevel){
50 50
             \array_pop($this->traces);
51 51
             return;
52 52
         }
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     {
68 68
         $result = [];
69 69
         $i = 0;
70
-        foreach ($blocks as $block) {
70
+        foreach ($blocks as $block){
71 71
             \array_push($result, ...$this->blockToStringList($block, $i++));
72 72
         }
73 73
         return \implode("\n", $result);
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
         // Separator
88 88
         $s = "\n";
89 89
         $nexPrefix = "$s$padding  ";
90
-        foreach ($items as $item) {
91
-            $result[] = $firstPrefix . \str_replace($s, $nexPrefix, (string)$item);
90
+        foreach ($items as $item){
91
+            $result[] = $firstPrefix.\str_replace($s, $nexPrefix, (string)$item);
92 92
         }
93 93
         return $result;
94 94
     }
Please login to merge, or discard this patch.
src/Core/src/Internal/Trace.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -19,14 +19,14 @@  discard block
 block discarded – undo
19 19
 
20 20
     public function __construct(
21 21
         public array $info = [],
22
-    ) {
22
+    ){
23 23
         $this->alias = $info['alias'] ?? null;
24 24
     }
25 25
 
26 26
     public function __toString(): string
27 27
     {
28 28
         $info = [];
29
-        foreach ($this->info as $key => $item) {
29
+        foreach ($this->info as $key => $item){
30 30
             $info[] = "$key: {$this->stringifyValue($item)}";
31 31
         }
32 32
         return \implode("\n", $info);
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
             \is_scalar($item) => \var_export($item, true),
40 40
             $item instanceof \Closure => $this->renderClosureSignature(new \ReflectionFunction($item)),
41 41
             $item instanceof \ReflectionFunctionAbstract => $this->renderClosureSignature($item),
42
-            $item instanceof \UnitEnum => $item::class . "::$item->name",
43
-            \is_object($item) => 'instance of ' . $item::class,
42
+            $item instanceof \UnitEnum => $item::class."::$item->name",
43
+            \is_object($item) => 'instance of '.$item::class,
44 44
             \is_array($item) => $this->renderArray($item),
45 45
             default => \gettype($item),
46 46
         };
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
 
49 49
     private function renderArray(array $array, int $level = 0): string
50 50
     {
51
-        if ($array === []) {
51
+        if ($array === []){
52 52
             return '[]';
53 53
         }
54
-        if ($level >= self::ARRAY_MAX_LEVEL) {
54
+        if ($level >= self::ARRAY_MAX_LEVEL){
55 55
             return 'array';
56 56
         }
57 57
         $result = [];
58
-        foreach ($array as $key => $value) {
58
+        foreach ($array as $key => $value){
59 59
             $result[] = \sprintf(
60 60
                 '%s: %s',
61 61
                 $key,
@@ -66,6 +66,6 @@  discard block
 block discarded – undo
66 66
         }
67 67
 
68 68
         $pad = \str_repeat('  ', $level);
69
-        return "[\n  $pad" . \implode(",\n  $pad", $result) . "\n$pad]";
69
+        return "[\n  $pad".\implode(",\n  $pad", $result)."\n$pad]";
70 70
     }
71 71
 }
Please login to merge, or discard this patch.
src/Core/src/Internal/Factory.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -54,35 +54,35 @@  discard block
 block discarded – undo
54 54
      */
55 55
     public function make(string $alias, array $parameters = [], string $context = null): mixed
56 56
     {
57
-        if (!isset($this->state->bindings[$alias])) {
57
+        if (!isset($this->state->bindings[$alias])){
58 58
             $this->tracer->push(false, action: 'autowire', alias: $alias, context: $context);
59
-            try {
59
+            try{
60 60
                 //No direct instructions how to construct class, make is automatically
61 61
                 return $this->autowire($alias, $parameters, $context);
62
-            } finally {
62
+            }finally{
63 63
                 $this->tracer->pop(false);
64 64
             }
65 65
         }
66 66
 
67 67
         $binding = $this->state->bindings[$alias];
68
-        try {
68
+        try{
69 69
             $this->tracer->push(false, action: 'resolve from binding', alias: $alias, context: $context, binding: $binding);
70 70
             $this->tracer->push(true);
71 71
 
72
-            if (\is_object($binding)) {
73
-                if ($binding::class === WeakReference::class) {
74
-                    if ($binding->get() === null && \class_exists($alias)) {
75
-                        try {
72
+            if (\is_object($binding)){
73
+                if ($binding::class === WeakReference::class){
74
+                    if ($binding->get() === null && \class_exists($alias)){
75
+                        try{
76 76
                             $this->tracer->push(false, alias: $alias, source: WeakReference::class, context: $context);
77 77
                             $object = $this->createInstance($alias, $parameters, $context);
78 78
                             $binding = $this->state->bindings[$alias] = WeakReference::create($object);
79
-                        } catch (\Throwable) {
79
+                        }catch (\Throwable){
80 80
                             throw new ContainerException($this->tracer->combineTraceMessage(\sprintf(
81 81
                                 'Can\'t resolve `%s`: can\'t instantiate `%s` from WeakReference binding.',
82 82
                                 $this->tracer->getRootAlias(),
83 83
                                 $alias,
84 84
                             )));
85
-                        } finally {
85
+                        }finally{
86 86
                             $this->tracer->pop();
87 87
                         }
88 88
                     }
@@ -92,26 +92,26 @@  discard block
 block discarded – undo
92 92
                 return $binding;
93 93
             }
94 94
 
95
-            if (\is_string($binding)) {
95
+            if (\is_string($binding)){
96 96
                 //Binding is pointing to something else
97 97
                 return $this->make($binding, $parameters, $context);
98 98
             }
99 99
 
100 100
             unset($this->state->bindings[$alias]);
101
-            try {
101
+            try{
102 102
                 $instance = $binding[0] === $alias
103 103
                     ? $this->autowire($alias, $parameters, $context)
104 104
                     : $this->evaluateBinding($alias, $binding[0], $parameters, $context);
105
-            } finally {
105
+            }finally{
106 106
                 /** @psalm-var class-string $alias */
107 107
                 $this->state->bindings[$alias] = $binding;
108 108
             }
109
-        } finally {
109
+        }finally{
110 110
             $this->tracer->pop(true);
111 111
             $this->tracer->pop(false);
112 112
         }
113 113
 
114
-        if ($binding[1]) {
114
+        if ($binding[1]){
115 115
             // Indicates singleton
116 116
             /** @psalm-var class-string $alias */
117 117
             $this->state->bindings[$alias] = $instance;
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      */
131 131
     private function autowire(string $class, array $parameters, string $context = null): object
132 132
     {
133
-        if (!\class_exists($class) && !isset($this->state->injectors[$class])) {
133
+        if (!\class_exists($class) && !isset($this->state->injectors[$class])){
134 134
             throw new NotFoundException($this->tracer->combineTraceMessage(\sprintf(
135 135
                 'Can\'t resolve `%s`: undefined class or binding `%s`.',
136 136
                 $this->tracer->getRootAlias(),
@@ -157,18 +157,18 @@  discard block
 block discarded – undo
157 157
         array $parameters,
158 158
         string $context = null
159 159
     ): mixed {
160
-        if (\is_string($target)) {
160
+        if (\is_string($target)){
161 161
             // Reference
162 162
             return $this->make($target, $parameters, $context);
163 163
         }
164 164
 
165
-        if ($target instanceof Autowire) {
165
+        if ($target instanceof Autowire){
166 166
             return $target->resolve($this, $parameters);
167 167
         }
168 168
 
169
-        try {
169
+        try{
170 170
             return $this->invoker->invoke($target, $parameters);
171
-        } catch (NotCallableException $e) {
171
+        }catch (NotCallableException $e){
172 172
             throw new ContainerException(
173 173
                 $this->tracer->combineTraceMessage(\sprintf('Invalid binding for `%s`.', $alias)),
174 174
                 $e->getCode(),
@@ -192,20 +192,20 @@  discard block
 block discarded – undo
192 192
      */
193 193
     private function createInstance(string $class, array $parameters, string $context = null): object
194 194
     {
195
-        try {
195
+        try{
196 196
             $reflection = new \ReflectionClass($class);
197
-        } catch (\ReflectionException $e) {
197
+        }catch (\ReflectionException $e){
198 198
             throw new ContainerException($e->getMessage(), $e->getCode(), $e);
199 199
         }
200 200
 
201 201
         //We have to construct class using external injector when we know exact context
202
-        if ($parameters === [] && $this->binder->hasInjector($class)) {
202
+        if ($parameters === [] && $this->binder->hasInjector($class)){
203 203
             $injector = $this->state->injectors[$reflection->getName()];
204 204
 
205
-            try {
205
+            try{
206 206
                 $injectorInstance = $this->container->get($injector);
207 207
 
208
-                if (!$injectorInstance instanceof InjectorInterface) {
208
+                if (!$injectorInstance instanceof InjectorInterface){
209 209
                     throw new InjectionException(
210 210
                         \sprintf(
211 211
                             "Class '%s' must be an instance of InjectorInterface for '%s'.",
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 
218 218
                 /** @var InjectorInterface<TObject> $injectorInstance */
219 219
                 $instance = $injectorInstance->createInjection($reflection, $context);
220
-                if (!$reflection->isInstance($instance)) {
220
+                if (!$reflection->isInstance($instance)){
221 221
                     throw new InjectionException(
222 222
                         \sprintf(
223 223
                             "Invalid injection response for '%s'.",
@@ -227,12 +227,12 @@  discard block
 block discarded – undo
227 227
                 }
228 228
 
229 229
                 return $instance;
230
-            } finally {
230
+            }finally{
231 231
                 $this->state->injectors[$reflection->getName()] = $injector;
232 232
             }
233 233
         }
234 234
 
235
-        if (!$reflection->isInstantiable()) {
235
+        if (!$reflection->isInstantiable()){
236 236
             $itIs = match (true) {
237 237
                 $reflection->isEnum() => 'Enum',
238 238
                 $reflection->isAbstract() => 'Abstract class',
@@ -245,12 +245,12 @@  discard block
 block discarded – undo
245 245
 
246 246
         $constructor = $reflection->getConstructor();
247 247
 
248
-        if ($constructor !== null) {
249
-            try {
248
+        if ($constructor !== null){
249
+            try{
250 250
                 $this->tracer->push(false, action: 'resolve arguments', signature: $constructor);
251 251
                 $this->tracer->push(true);
252 252
                 $arguments = $this->resolver->resolveArguments($constructor, $parameters);
253
-            } catch (ValidationException $e) {
253
+            }catch (ValidationException $e){
254 254
                 throw new ContainerException(
255 255
                     $this->tracer->combineTraceMessage(
256 256
                         \sprintf(
@@ -260,22 +260,22 @@  discard block
 block discarded – undo
260 260
                         )
261 261
                     ),
262 262
                 );
263
-            } finally {
263
+            }finally{
264 264
                 $this->tracer->pop(true);
265 265
                 $this->tracer->pop(false);
266 266
             }
267
-            try {
267
+            try{
268 268
                 // Using constructor with resolved arguments
269 269
                 $this->tracer->push(false, call: "$class::__construct", arguments: $arguments);
270 270
                 $this->tracer->push(true);
271 271
                 $instance = new $class(...$arguments);
272
-            } catch (\TypeError $e) {
272
+            }catch (\TypeError $e){
273 273
                 throw new WrongTypeException($constructor, $e);
274
-            } finally {
274
+            }finally{
275 275
                 $this->tracer->pop(true);
276 276
                 $this->tracer->pop(false);
277 277
             }
278
-        } else {
278
+        }else{
279 279
             // No constructor specified
280 280
             $instance = $reflection->newInstance();
281 281
         }
@@ -293,9 +293,9 @@  discard block
 block discarded – undo
293 293
     private function registerInstance(object $instance, array $parameters): object
294 294
     {
295 295
         //Declarative singletons (only when class received via direct get)
296
-        if ($parameters === [] && $instance instanceof SingletonInterface) {
296
+        if ($parameters === [] && $instance instanceof SingletonInterface){
297 297
             $alias = $instance::class;
298
-            if (!isset($this->state->bindings[$alias])) {
298
+            if (!isset($this->state->bindings[$alias])){
299 299
                 $this->state->bindings[$alias] = $instance;
300 300
             }
301 301
         }
Please login to merge, or discard this patch.