Passed
Pull Request — master (#817)
by Maxim
06:26
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/tests/ExceptionsTest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 
80 80
         $this->expectException(ContainerException::class);
81 81
 
82
-        try {
82
+        try{
83 83
             $container->get(WithContainerInside::class);
84
-        } catch (ContainerException $e) {
84
+        }catch (ContainerException $e){
85 85
             $this->assertSame(
86 86
                 \preg_replace('/\s+/', '', 'Can\'tresolve`Spiral\Tests\Core\Fixtures\
87 87
                     WithContainerInside`:undefinedclassorbinding`Spiral\Tests\Core\Fixtures\InvalidClass`.
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
     {
102 102
         $this->expectException(ContainerException::class);
103 103
 
104
-        try {
104
+        try{
105 105
             $container->get(ClassWithUndefinedDependency::class);
106
-        } catch (ContainerException $e) {
106
+        }catch (ContainerException $e){
107 107
             $this->assertSame(
108 108
                 \preg_replace('/\s+/', '', $message),
109 109
                 \preg_replace('/\s+/', '', $e->getMessage())
Please login to merge, or discard this patch.
src/Core/src/Internal/Trace.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,16 +13,16 @@
 block discarded – undo
13 13
         public readonly string $alias,
14 14
         public readonly string $information,
15 15
         public ?string $context = null
16
-    ) {
16
+    ){
17 17
         $this->context ??= '-';
18 18
     }
19 19
 
20 20
     public function __toString(): string
21 21
     {
22 22
         $result = [];
23
-        $result[] = '- ' . $this->alias;
24
-        $result[] = '    Info: ' . $this->information;
25
-        $result[] = '    Context: ' . $this->context;
23
+        $result[] = '- '.$this->alias;
24
+        $result[] = '    Info: '.$this->information;
25
+        $result[] = '    Context: '.$this->context;
26 26
 
27 27
         return \implode(PHP_EOL, $result);
28 28
     }
Please login to merge, or discard this patch.
src/Core/src/Internal/Factory.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function make(string $alias, array $parameters = [], string $context = null): mixed
55 55
     {
56
-        if (!isset($this->state->bindings[$alias])) {
56
+        if (!isset($this->state->bindings[$alias])){
57 57
             $this->tracer->traceAutowire($alias, $context);
58 58
             //No direct instructions how to construct class, make is automatically
59 59
             return $this->autowire($alias, $parameters, $context);
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
         $binding = $this->state->bindings[$alias];
63 63
         $this->tracer->traceBinding($alias, $binding, $context);
64 64
 
65
-        if (\is_object($binding)) {
66
-            if ($binding::class === WeakReference::class) {
67
-                if ($binding->get() === null && \class_exists($alias)) {
65
+        if (\is_object($binding)){
66
+            if ($binding::class === WeakReference::class){
67
+                if ($binding->get() === null && \class_exists($alias)){
68 68
                     $object = $this->createInstance($alias, $parameters, $context);
69 69
                     $binding = $this->state->bindings[$alias] = WeakReference::create($object);
70 70
                 }
@@ -74,23 +74,23 @@  discard block
 block discarded – undo
74 74
             return $binding;
75 75
         }
76 76
 
77
-        if (\is_string($binding)) {
77
+        if (\is_string($binding)){
78 78
             //Binding is pointing to something else
79 79
             return $this->make($binding, $parameters, $context);
80 80
         }
81 81
 
82 82
         unset($this->state->bindings[$alias]);
83
-        try {
83
+        try{
84 84
             $instance = $binding[0] === $alias
85 85
                 ? $this->autowire($alias, $parameters, $context)
86 86
                 : $this->evaluateBinding($alias, $binding[0], $parameters, $context);
87
-        } finally {
87
+        }finally{
88 88
             /** @psalm-var class-string $alias */
89 89
             $this->state->bindings[$alias] = $binding;
90 90
             $this->tracer->clean();
91 91
         }
92 92
 
93
-        if ($binding[1]) {
93
+        if ($binding[1]){
94 94
             // Indicates singleton
95 95
             /** @psalm-var class-string $alias */
96 96
             $this->state->bindings[$alias] = $instance;
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     private function autowire(string $class, array $parameters, string $context = null): object
111 111
     {
112
-        if (!\class_exists($class) && !isset($this->state->injectors[$class])) {
112
+        if (!\class_exists($class) && !isset($this->state->injectors[$class])){
113 113
             throw new NotFoundException(\sprintf(
114 114
                 'Can\'t resolve `%s`: undefined class or binding `%s`.', $this->tracer->getRootConstructedClass(),
115 115
                 $class
@@ -135,18 +135,18 @@  discard block
 block discarded – undo
135 135
         array $parameters,
136 136
         string $context = null
137 137
     ): mixed {
138
-        if (\is_string($target)) {
138
+        if (\is_string($target)){
139 139
             // Reference
140 140
             return $this->make($target, $parameters, $context);
141 141
         }
142 142
 
143
-        if ($target instanceof Autowire) {
143
+        if ($target instanceof Autowire){
144 144
             return $target->resolve($this, $parameters);
145 145
         }
146 146
 
147
-        try {
147
+        try{
148 148
             return $this->invoker->invoke($target, $parameters);
149
-        } catch (NotCallableException $e) {
149
+        }catch (NotCallableException $e){
150 150
             throw new ContainerException(
151 151
                 \sprintf('Invalid binding for `%s`.', $alias),
152 152
                 $e->getCode(),
@@ -171,20 +171,20 @@  discard block
 block discarded – undo
171 171
      */
172 172
     private function createInstance(string $class, array $parameters, string $context = null): object
173 173
     {
174
-        try {
174
+        try{
175 175
             $reflection = new \ReflectionClass($class);
176
-        } catch (\ReflectionException $e) {
176
+        }catch (\ReflectionException $e){
177 177
             throw new ContainerException($e->getMessage(), $e->getCode(), $e, $this->tracer);
178 178
         }
179 179
 
180 180
         //We have to construct class using external injector when we know exact context
181
-        if ($parameters === [] && $this->binder->hasInjector($class)) {
181
+        if ($parameters === [] && $this->binder->hasInjector($class)){
182 182
             $injector = $this->state->injectors[$reflection->getName()];
183 183
 
184
-            try {
184
+            try{
185 185
                 $injectorInstance = $this->container->get($injector);
186 186
 
187
-                if (!$injectorInstance instanceof InjectorInterface) {
187
+                if (!$injectorInstance instanceof InjectorInterface){
188 188
                     throw new InjectionException(
189 189
                         \sprintf(
190 190
                             "Class '%s' must be an instance of InjectorInterface for '%s'.",
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 
197 197
                 /** @var InjectorInterface<TObject> $injectorInstance */
198 198
                 $instance = $injectorInstance->createInjection($reflection, $context);
199
-                if (!$reflection->isInstance($instance)) {
199
+                if (!$reflection->isInstance($instance)){
200 200
                     throw new InjectionException(
201 201
                         \sprintf(
202 202
                             "Invalid injection response for '%s'.",
@@ -206,12 +206,12 @@  discard block
 block discarded – undo
206 206
                 }
207 207
 
208 208
                 return $instance;
209
-            } finally {
209
+            }finally{
210 210
                 $this->state->injectors[$reflection->getName()] = $injector;
211 211
             }
212 212
         }
213 213
 
214
-        if (!$reflection->isInstantiable()) {
214
+        if (!$reflection->isInstantiable()){
215 215
             $itIs = match (true) {
216 216
                 $reflection->isEnum() => 'Enum',
217 217
                 $reflection->isAbstract() => 'Abstract class',
@@ -227,14 +227,14 @@  discard block
 block discarded – undo
227 227
 
228 228
         $constructor = $reflection->getConstructor();
229 229
 
230
-        if ($constructor !== null) {
231
-            try {
230
+        if ($constructor !== null){
231
+            try{
232 232
                 // Using constructor with resolved arguments
233 233
                 $instance = new $class(...$this->resolver->resolveArguments($constructor, $parameters));
234
-            } catch (\TypeError $e) {
234
+            }catch (\TypeError $e){
235 235
                 throw new WrongTypeException($constructor, $e);
236 236
             }
237
-        } else {
237
+        }else{
238 238
             // No constructor specified
239 239
             $instance = $reflection->newInstance();
240 240
         }
@@ -252,9 +252,9 @@  discard block
 block discarded – undo
252 252
     private function registerInstance(object $instance, array $parameters): object
253 253
     {
254 254
         //Declarative singletons (only when class received via direct get)
255
-        if ($parameters === [] && $instance instanceof SingletonInterface) {
255
+        if ($parameters === [] && $instance instanceof SingletonInterface){
256 256
             $alias = $instance::class;
257
-            if (!isset($this->state->bindings[$alias])) {
257
+            if (!isset($this->state->bindings[$alias])){
258 258
                 $this->state->bindings[$alias] = $instance;
259 259
             }
260 260
         }
Please login to merge, or discard this patch.
src/Core/src/Internal/Tracer.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
         $this->trace($alias, 'Autowiring', $context);
20 20
     }
21 21
 
22
-    public function traceBinding(string $alias, string|array|object $binding, string $context = null): void
22
+    public function traceBinding(string $alias, string | array | object $binding, string $context = null): void
23 23
     {
24 24
         $message = match (true) {
25 25
             \is_string($binding) => \sprintf('Binding found `%s`', $binding),
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
     public function __toString(): string
44 44
     {
45 45
         $result = [];
46
-        if ($this->traces !== []) {
46
+        if ($this->traces !== []){
47 47
             $result[] = 'Container trace list:';
48 48
 
49
-            foreach ($this->traces as $item) {
50
-                $result[] = (string) $item;
49
+            foreach ($this->traces as $item){
50
+                $result[] = (string)$item;
51 51
             }
52 52
         }
53 53
 
Please login to merge, or discard this patch.
src/Core/src/Exception/Container/ContainerException.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
         int $code = 0,
19 19
         ?\Throwable $previous = null,
20 20
         protected ?Tracer $tracer = null
21
-    ) {
22
-        parent::__construct($tracer !== null ? $message . PHP_EOL . $tracer : $message, $code, $previous);
21
+    ){
22
+        parent::__construct($tracer !== null ? $message.PHP_EOL.$tracer : $message, $code, $previous);
23 23
     }
24 24
 }
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.