Passed
Pull Request — master (#821)
by Maxim
09:15 queued 02:28
created
src/Core/tests/ScopesTest.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
 
34 34
         $this->assertNull(ContainerScope::getContainer());
35 35
 
36
-        try {
36
+        try{
37 37
             $this->assertTrue(ContainerScope::runScope($container, function () use ($container): void {
38 38
                 throw new RuntimeException('exception');
39 39
             }));
40
-        } catch (\Throwable $e) {
40
+        }catch (\Throwable $e){
41 41
         }
42 42
 
43 43
         $this->assertInstanceOf(RuntimeException::class, $e);
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
             return $c->get('bucket')->getName() == 'b' && $c->has('other');
85 85
         }));
86 86
 
87
-        try {
87
+        try{
88 88
             $this->assertTrue($c->runScope([
89 89
                 'bucket' => new Bucket('b'),
90 90
                 'other'  => new SampleClass()
91 91
             ], function () use ($c): void {
92 92
                 throw new RuntimeException('exception');
93 93
             }));
94
-        } catch (\Throwable $e) {
94
+        }catch (\Throwable $e){
95 95
         }
96 96
 
97 97
         $this->assertSame('a', $c->get('bucket')->getName());
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
             ContainerScope::runScope($container, static fn (ContainerInterface $container) => $container)
108 108
         );
109 109
 
110
-        $result = ContainerScope::runScope($container, static function (Container $container) {
110
+        $result = ContainerScope::runScope($container, static function (Container $container){
111 111
             return $container->runScope([], static fn (Container $container) => $container);
112 112
         });
113 113
 
Please login to merge, or discard this patch.
Braces   +18 added lines, -8 removed lines patch added patch discarded remove patch
@@ -20,7 +20,8 @@  discard block
 block discarded – undo
20 20
 
21 21
         $this->assertNull(ContainerScope::getContainer());
22 22
 
23
-        $this->assertTrue(ContainerScope::runScope($container, function () use ($container) {
23
+        $this->assertTrue(ContainerScope::runScope($container, function () use ($container)
24
+        {
24 25
             return $container === ContainerScope::getContainer();
25 26
         }));
26 27
 
@@ -33,11 +34,14 @@  discard block
 block discarded – undo
33 34
 
34 35
         $this->assertNull(ContainerScope::getContainer());
35 36
 
36
-        try {
37
+        try
38
+        {
37 39
             $this->assertTrue(ContainerScope::runScope($container, function () use ($container): void {
38 40
                 throw new RuntimeException('exception');
39 41
             }));
40
-        } catch (\Throwable $e) {
42
+        }
43
+        catch (\Throwable $e)
44
+        {
41 45
         }
42 46
 
43 47
         $this->assertInstanceOf(RuntimeException::class, $e);
@@ -55,7 +59,8 @@  discard block
 block discarded – undo
55 59
         $this->assertTrue($c->runScope([
56 60
             'bucket' => new Bucket('b'),
57 61
             'other'  => new SampleClass()
58
-        ], function () use ($c) {
62
+        ], function () use ($c)
63
+        {
59 64
             $this->assertSame('b', $c->get('bucket')->getName());
60 65
             $this->assertTrue($c->has('other'));
61 66
 
@@ -77,21 +82,25 @@  discard block
 block discarded – undo
77 82
         $this->assertTrue($c->runScope([
78 83
             'bucket' => new Bucket('b'),
79 84
             'other'  => new SampleClass()
80
-        ], function () use ($c) {
85
+        ], function () use ($c)
86
+        {
81 87
             $this->assertSame('b', $c->get('bucket')->getName());
82 88
             $this->assertTrue($c->has('other'));
83 89
 
84 90
             return $c->get('bucket')->getName() == 'b' && $c->has('other');
85 91
         }));
86 92
 
87
-        try {
93
+        try
94
+        {
88 95
             $this->assertTrue($c->runScope([
89 96
                 'bucket' => new Bucket('b'),
90 97
                 'other'  => new SampleClass()
91 98
             ], function () use ($c): void {
92 99
                 throw new RuntimeException('exception');
93 100
             }));
94
-        } catch (\Throwable $e) {
101
+        }
102
+        catch (\Throwable $e)
103
+        {
95 104
         }
96 105
 
97 106
         $this->assertSame('a', $c->get('bucket')->getName());
@@ -107,7 +116,8 @@  discard block
 block discarded – undo
107 116
             ContainerScope::runScope($container, static fn (ContainerInterface $container) => $container)
108 117
         );
109 118
 
110
-        $result = ContainerScope::runScope($container, static function (Container $container) {
119
+        $result = ContainerScope::runScope($container, static function (Container $container)
120
+        {
111 121
             return $container->runScope([], static fn (Container $container) => $container);
112 122
         });
113 123
 
Please login to merge, or discard this patch.
src/Core/src/Container.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
     use DestructorTrait;
45 45
 
46 46
     private Internal\State $state;
47
-    private ResolverInterface|Internal\Resolver $resolver;
48
-    private FactoryInterface|Internal\Factory $factory;
49
-    private ContainerInterface|Internal\Container $container;
50
-    private BinderInterface|Internal\Binder $binder;
51
-    private InvokerInterface|Internal\Invoker $invoker;
47
+    private ResolverInterface | Internal\Resolver $resolver;
48
+    private FactoryInterface | Internal\Factory $factory;
49
+    private ContainerInterface | Internal\Container $container;
50
+    private BinderInterface | Internal\Binder $binder;
51
+    private InvokerInterface | Internal\Invoker $invoker;
52 52
 
53 53
     /**
54 54
      * Container constructor.
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         $constructor = new Internal\Registry($config, [
59 59
             'state' => new Internal\State(),
60 60
         ]);
61
-        foreach ($config as $property => $class) {
61
+        foreach ($config as $property => $class){
62 62
             $this->$property = $constructor->get($property, $class);
63 63
         }
64 64
 
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
      *
130 130
      * @psalm-suppress PossiblyInvalidArgument, PossiblyInvalidCast
131 131
      */
132
-    public function get(string|Autowire $id, string $context = null): mixed
132
+    public function get(string | Autowire $id, string $context = null): mixed
133 133
     {
134 134
         return $this->container->get($id, $context);
135 135
     }
@@ -143,26 +143,26 @@  discard block
 block discarded – undo
143 143
     {
144 144
         $binds = &$this->state->bindings;
145 145
         $cleanup = $previous = [];
146
-        foreach ($bindings as $alias => $resolver) {
147
-            if (isset($binds[$alias])) {
146
+        foreach ($bindings as $alias => $resolver){
147
+            if (isset($binds[$alias])){
148 148
                 $previous[$alias] = $binds[$alias];
149
-            } else {
149
+            }else{
150 150
                 $cleanup[] = $alias;
151 151
             }
152 152
 
153 153
             $this->binder->bind($alias, $resolver);
154 154
         }
155 155
 
156
-        try {
156
+        try{
157 157
             return ContainerScope::getContainer() !== $this
158 158
                 ? ContainerScope::runScope($this, $scope)
159 159
                 : $scope($this);
160
-        } finally {
161
-            foreach ($previous as $alias => $resolver) {
160
+        }finally{
161
+            foreach ($previous as $alias => $resolver){
162 162
                 $binds[$alias] = $resolver;
163 163
             }
164 164
 
165
-            foreach ($cleanup as $alias) {
165
+            foreach ($cleanup as $alias){
166 166
                 unset($binds[$alias]);
167 167
             }
168 168
         }
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
      * for each method call), function array or Closure (executed every call). Only object resolvers
174 174
      * supported by this method.
175 175
      */
176
-    public function bind(string $alias, string|array|callable|object $resolver): void
176
+    public function bind(string $alias, string | array | callable | object $resolver): void
177 177
     {
178 178
         $this->binder->bind($alias, $resolver);
179 179
     }
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
      *
185 185
      * @psalm-param TResolver $resolver
186 186
      */
187
-    public function bindSingleton(string $alias, string|array|callable|object $resolver): void
187
+    public function bindSingleton(string $alias, string | array | callable | object $resolver): void
188 188
     {
189 189
         $this->binder->bindSingleton($alias, $resolver);
190 190
     }
Please login to merge, or discard this patch.
Braces   +18 added lines, -8 removed lines patch added patch discarded remove patch
@@ -58,7 +58,8 @@  discard block
 block discarded – undo
58 58
         $constructor = new Internal\Registry($config, [
59 59
             'state' => new Internal\State(),
60 60
         ]);
61
-        foreach ($config as $property => $class) {
61
+        foreach ($config as $property => $class)
62
+        {
62 63
             $this->$property = $constructor->get($property, $class);
63 64
         }
64 65
 
@@ -143,26 +144,35 @@  discard block
 block discarded – undo
143 144
     {
144 145
         $binds = &$this->state->bindings;
145 146
         $cleanup = $previous = [];
146
-        foreach ($bindings as $alias => $resolver) {
147
-            if (isset($binds[$alias])) {
147
+        foreach ($bindings as $alias => $resolver)
148
+        {
149
+            if (isset($binds[$alias]))
150
+            {
148 151
                 $previous[$alias] = $binds[$alias];
149
-            } else {
152
+            }
153
+            else
154
+            {
150 155
                 $cleanup[] = $alias;
151 156
             }
152 157
 
153 158
             $this->binder->bind($alias, $resolver);
154 159
         }
155 160
 
156
-        try {
161
+        try
162
+        {
157 163
             return ContainerScope::getContainer() !== $this
158 164
                 ? ContainerScope::runScope($this, $scope)
159 165
                 : $scope($this);
160
-        } finally {
161
-            foreach ($previous as $alias => $resolver) {
166
+        }
167
+        finally
168
+        {
169
+            foreach ($previous as $alias => $resolver)
170
+            {
162 171
                 $binds[$alias] = $resolver;
163 172
             }
164 173
 
165
-            foreach ($cleanup as $alias) {
174
+            foreach ($cleanup as $alias)
175
+            {
166 176
                 unset($binds[$alias]);
167 177
             }
168 178
         }
Please login to merge, or discard this patch.
src/Core/src/ContainerScope.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,9 +33,9 @@
 block discarded – undo
33 33
     {
34 34
         [$previous, self::$container] = [self::$container, $container];
35 35
 
36
-        try {
36
+        try{
37 37
             return $scope(self::$container);
38
-        } finally {
38
+        }finally{
39 39
             self::$container = $previous;
40 40
         }
41 41
     }
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,9 +33,12 @@
 block discarded – undo
33 33
     {
34 34
         [$previous, self::$container] = [self::$container, $container];
35 35
 
36
-        try {
36
+        try
37
+        {
37 38
             return $scope(self::$container);
38
-        } finally {
39
+        }
40
+        finally
41
+        {
39 42
             self::$container = $previous;
40 43
         }
41 44
     }
Please login to merge, or discard this patch.