Passed
Push — master ( 8b0beb...b8f44e )
by Aleksei
10:34
created
src/Core/tests/Scope/FibersTest.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         );
64 64
 
65 65
         self::assertCount(5, $result);
66
-        foreach ($result as $suspendValue) {
66
+        foreach ($result as $suspendValue){
67 67
             self::assertSame(self::TEST_DATA, $suspendValue);
68 68
         }
69 69
     }
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
         );
82 82
 
83 83
         self::assertCount(2, $result);
84
-        foreach ($result as $suspendValue) {
84
+        foreach ($result as $suspendValue){
85 85
             self::assertSame(self::TEST_DATA, $suspendValue);
86 86
         }
87 87
     }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
                     $result = '';
98 98
                     $result .= Fiber::suspend('foo');
99 99
                     $result .= Fiber::suspend('bar');
100
-                    return $result . Fiber::suspend('error');
100
+                    return $result.Fiber::suspend('error');
101 101
                 }
102 102
             ),
103 103
             static fn(string $suspendValue): string => $suspendValue !== 'error'
@@ -114,12 +114,12 @@  discard block
 block discarded – undo
114 114
                     $result = '';
115 115
                     $result .= Fiber::suspend('foo');
116 116
                     $result .= Fiber::suspend('bar');
117
-                    try {
117
+                    try{
118 118
                         $result .= Fiber::suspend('error');
119
-                    } catch (\Throwable $e) {
119
+                    }catch (\Throwable $e){
120 120
                         $result .= $e->getMessage();
121 121
                     }
122
-                    return $result . Fiber::suspend('baz');
122
+                    return $result.Fiber::suspend('baz');
123 123
                 }
124 124
             ),
125 125
             static fn(string $suspendValue): string => $suspendValue !== 'error'
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
         ?callable $load = null,
143 143
         ?Container $container = null,
144 144
     ): callable {
145
-        return static function () use ($load, $container): array {
145
+        return static function () use ($load, $container) : array {
146 146
             // The function should be called in a fiber
147 147
             self::assertNotNull(Fiber::getCurrent());
148 148
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
                         $resource = $c3->get('resource');
164 164
                         self::assertInstanceOf(DateTimeImmutable::class, $c3->get('bar'));
165 165
                         self::assertInstanceOf(stdClass::class, $resource);
166
-                        foreach (self::TEST_DATA as $key => $value) {
166
+                        foreach (self::TEST_DATA as $key => $value){
167 167
                             $resource->$key = $value;
168 168
                             $load === null or $load();
169 169
                             Fiber::suspend($value);
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
             }, ['foo' => new DateTime()]);
177 177
             self::assertFalse($c1->has('foo'));
178 178
 
179
-            self::assertSame(self::TEST_DATA, (array) $result);
180
-            return (array) $result;
179
+            self::assertSame(self::TEST_DATA, (array)$result);
180
+            return (array)$result;
181 181
         };
182 182
     }
183 183
 }
Please login to merge, or discard this patch.
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -63,7 +63,8 @@  discard block
 block discarded – undo
63 63
         );
64 64
 
65 65
         self::assertCount(5, $result);
66
-        foreach ($result as $suspendValue) {
66
+        foreach ($result as $suspendValue)
67
+        {
67 68
             self::assertSame(self::TEST_DATA, $suspendValue);
68 69
         }
69 70
     }
@@ -81,7 +82,8 @@  discard block
 block discarded – undo
81 82
         );
82 83
 
83 84
         self::assertCount(2, $result);
84
-        foreach ($result as $suspendValue) {
85
+        foreach ($result as $suspendValue)
86
+        {
85 87
             self::assertSame(self::TEST_DATA, $suspendValue);
86 88
         }
87 89
     }
@@ -114,9 +116,12 @@  discard block
 block discarded – undo
114 116
                     $result = '';
115 117
                     $result .= Fiber::suspend('foo');
116 118
                     $result .= Fiber::suspend('bar');
117
-                    try {
119
+                    try
120
+                    {
118 121
                         $result .= Fiber::suspend('error');
119
-                    } catch (\Throwable $e) {
122
+                    }
123
+                    catch (\Throwable $e)
124
+                    {
120 125
                         $result .= $e->getMessage();
121 126
                     }
122 127
                     return $result . Fiber::suspend('baz');
@@ -150,20 +155,23 @@  discard block
 block discarded – undo
150 155
             $c1 = $container ?? new Container();
151 156
             $c1->bindSingleton('resource', new stdClass());
152 157
 
153
-            $result = $c1->runScoped(static function (Container $c2) use ($load) {
158
+            $result = $c1->runScoped(static function (Container $c2) use ($load)
159
+            {
154 160
                 // check local binding
155 161
                 self::assertTrue($c2->has('foo'));
156 162
                 self::assertInstanceOf(DateTime::class, $c2->get('foo'));
157 163
 
158 164
                 return $c2->runScoped(
159
-                    static function (ContainerInterface $c3) use ($load) {
165
+                    static function (ContainerInterface $c3) use ($load)
166
+                    {
160 167
                         // check local binding
161 168
                         self::assertTrue($c3->has('bar'));
162 169
 
163 170
                         $resource = $c3->get('resource');
164 171
                         self::assertInstanceOf(DateTimeImmutable::class, $c3->get('bar'));
165 172
                         self::assertInstanceOf(stdClass::class, $resource);
166
-                        foreach (self::TEST_DATA as $key => $value) {
173
+                        foreach (self::TEST_DATA as $key => $value)
174
+                        {
167 175
                             $resource->$key = $value;
168 176
                             $load === null or $load();
169 177
                             Fiber::suspend($value);
Please login to merge, or discard this patch.
src/Core/tests/Scope/ProxyTest.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
                     // from the current `foo` scope
50 50
                     self::assertInstanceOf(KVLogger::class, $logger);
51 51
 
52
-                    for ($i = 0; $i < 10; $i++) {
52
+                    for ($i = 0; $i < 10; $i++){
53 53
                         // because of proxy
54 54
                         self::assertNotInstanceOf(KVLogger::class, $carrier->getLogger());
55 55
                         self::assertSame('kv', $carrier->logger->getName());
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
                     // from the current `foo` scope
70 70
                     self::assertInstanceOf(FileLogger::class, $logger);
71 71
 
72
-                    for ($i = 0; $i < 10; $i++) {
72
+                    for ($i = 0; $i < 10; $i++){
73 73
                         // because of proxy
74 74
                         self::assertNotInstanceOf(FileLogger::class, $carrier->getLogger());
75 75
                         self::assertSame('file', $carrier->logger->getName());
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
             ->bind(
138 138
                 ContextInterface::class,
139 139
                 new \Spiral\Core\Config\Injectable(
140
-                    new class implements InjectorInterface {
140
+                    new class implements InjectorInterface{
141 141
                         public function createInjection(\ReflectionClass $class, mixed $context = null): Context
142 142
                         {
143 143
                             return new Context($context);
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
             ->bind(
179 179
                 ContextInterface::class,
180 180
                 new \Spiral\Core\Config\Injectable(
181
-                    new class implements InjectorInterface {
181
+                    new class implements InjectorInterface{
182 182
                         public function createInjection(\ReflectionClass $class, mixed $context = null): Context
183 183
                         {
184 184
                             return new Context($context);
@@ -189,14 +189,14 @@  discard block
 block discarded – undo
189 189
 
190 190
         FiberHelper::runFiberSequence(
191 191
             static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $ctx): void {
192
-                for ($i = 0; $i < 10; $i++) {
192
+                for ($i = 0; $i < 10; $i++){
193 193
                     self::assertInstanceOf(ReflectionParameter::class, $ctx->getValue(), 'Context injected');
194 194
                     self::assertSame('ctx', $ctx->getValue()->getName());
195 195
                     \Fiber::suspend();
196 196
                 }
197 197
             }),
198 198
             static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $context): void {
199
-                for ($i = 0; $i < 10; $i++) {
199
+                for ($i = 0; $i < 10; $i++){
200 200
                     self::assertInstanceOf(ReflectionParameter::class, $context->getValue(), 'Context injected');
201 201
                     self::assertSame('context', $context->getValue()->getName());
202 202
                     \Fiber::suspend();
@@ -257,10 +257,10 @@  discard block
 block discarded – undo
257 257
     {
258 258
         $root = new Container();
259 259
         $context = (object)['destroyed' => false];
260
-        $class = new class($context) implements DestroyableInterface {
260
+        $class = new class($context) implements DestroyableInterface{
261 261
             public function __construct(
262 262
                 private readonly \stdClass $context,
263
-            ) {
263
+            ){
264 264
             }
265 265
 
266 266
             public function __destruct()
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
             new Scope('http'),
289 289
             static function () use ($root, $proxy): void {
290 290
                 self::assertSame('Foo', $proxy->getName());
291
-                $proxy->setName(new class implements \Stringable {
291
+                $proxy->setName(new class implements \Stringable{
292 292
                     public function __toString(): string
293 293
                     {
294 294
                         return 'Bar';
Please login to merge, or discard this patch.
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -49,7 +49,8 @@  discard block
 block discarded – undo
49 49
                     // from the current `foo` scope
50 50
                     self::assertInstanceOf(KVLogger::class, $logger);
51 51
 
52
-                    for ($i = 0; $i < 10; $i++) {
52
+                    for ($i = 0; $i < 10; $i++)
53
+                    {
53 54
                         // because of proxy
54 55
                         self::assertNotInstanceOf(KVLogger::class, $carrier->getLogger());
55 56
                         self::assertSame('kv', $carrier->logger->getName());
@@ -69,7 +70,8 @@  discard block
 block discarded – undo
69 70
                     // from the current `foo` scope
70 71
                     self::assertInstanceOf(FileLogger::class, $logger);
71 72
 
72
-                    for ($i = 0; $i < 10; $i++) {
73
+                    for ($i = 0; $i < 10; $i++)
74
+                    {
73 75
                         // because of proxy
74 76
                         self::assertNotInstanceOf(FileLogger::class, $carrier->getLogger());
75 77
                         self::assertSame('file', $carrier->logger->getName());
@@ -137,7 +139,8 @@  discard block
 block discarded – undo
137 139
             ->bind(
138 140
                 ContextInterface::class,
139 141
                 new \Spiral\Core\Config\Injectable(
140
-                    new class implements InjectorInterface {
142
+                    new class implements InjectorInterface
143
+                    {
141 144
                         public function createInjection(\ReflectionClass $class, mixed $context = null): Context
142 145
                         {
143 146
                             return new Context($context);
@@ -178,7 +181,8 @@  discard block
 block discarded – undo
178 181
             ->bind(
179 182
                 ContextInterface::class,
180 183
                 new \Spiral\Core\Config\Injectable(
181
-                    new class implements InjectorInterface {
184
+                    new class implements InjectorInterface
185
+                    {
182 186
                         public function createInjection(\ReflectionClass $class, mixed $context = null): Context
183 187
                         {
184 188
                             return new Context($context);
@@ -189,14 +193,16 @@  discard block
 block discarded – undo
189 193
 
190 194
         FiberHelper::runFiberSequence(
191 195
             static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $ctx): void {
192
-                for ($i = 0; $i < 10; $i++) {
196
+                for ($i = 0; $i < 10; $i++)
197
+                {
193 198
                     self::assertInstanceOf(ReflectionParameter::class, $ctx->getValue(), 'Context injected');
194 199
                     self::assertSame('ctx', $ctx->getValue()->getName());
195 200
                     \Fiber::suspend();
196 201
                 }
197 202
             }),
198 203
             static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $context): void {
199
-                for ($i = 0; $i < 10; $i++) {
204
+                for ($i = 0; $i < 10; $i++)
205
+                {
200 206
                     self::assertInstanceOf(ReflectionParameter::class, $context->getValue(), 'Context injected');
201 207
                     self::assertSame('context', $context->getValue()->getName());
202 208
                     \Fiber::suspend();
@@ -257,7 +263,8 @@  discard block
 block discarded – undo
257 263
     {
258 264
         $root = new Container();
259 265
         $context = (object)['destroyed' => false];
260
-        $class = new class($context) implements DestroyableInterface {
266
+        $class = new class($context) implements DestroyableInterface
267
+        {
261 268
             public function __construct(
262 269
                 private readonly \stdClass $context,
263 270
             ) {
Please login to merge, or discard this patch.
src/Core/tests/Scope/ExceptionsTest.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
         $container = new Container();
22 22
 
23 23
         $container->runScoped(static function (Container $c1): void {
24
-            try {
24
+            try{
25 25
                 $c1->get(ExceptionConstructor::class);
26 26
                 self::fail('Exception should be thrown');
27
-            } catch (\Throwable $e) {
27
+            }catch (\Throwable $e){
28 28
                 self::assertInstanceOf(\Exception::class, $e);
29 29
                 throw $e;
30 30
             }
@@ -39,10 +39,10 @@  discard block
 block discarded – undo
39 39
         $container = new Container();
40 40
 
41 41
         $container->runScoped(static function (Container $c1): void {
42
-            try {
42
+            try{
43 43
                 $c1->get(ExceptionConstructor::class);
44 44
                 self::fail('Exception should be thrown');
45
-            } catch (\Throwable $e) {
45
+            }catch (\Throwable $e){
46 46
                 self::assertInstanceOf(\Exception::class, $e);
47 47
                 throw $e;
48 48
             }
@@ -57,10 +57,10 @@  discard block
 block discarded – undo
57 57
         $container = new Container();
58 58
 
59 59
         $container->runScoped(static function (Container $c1): void {
60
-            try {
60
+            try{
61 61
                 $c1->get(DatetimeCarrier::class);
62 62
                 self::fail('Exception should be thrown');
63
-            } catch (\Throwable $e) {
63
+            }catch (\Throwable $e){
64 64
                 self::assertInstanceOf(NotFoundException::class, $e);
65 65
                 self::assertInstanceOf(NotFoundException::class, $e->getPrevious());
66 66
                 self::assertStringContainsString(
Please login to merge, or discard this patch.
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,10 +21,13 @@  discard block
 block discarded – undo
21 21
         $container = new Container();
22 22
 
23 23
         $container->runScoped(static function (Container $c1): void {
24
-            try {
24
+            try
25
+            {
25 26
                 $c1->get(ExceptionConstructor::class);
26 27
                 self::fail('Exception should be thrown');
27
-            } catch (\Throwable $e) {
28
+            }
29
+            catch (\Throwable $e)
30
+            {
28 31
                 self::assertInstanceOf(\Exception::class, $e);
29 32
                 throw $e;
30 33
             }
@@ -39,10 +42,13 @@  discard block
 block discarded – undo
39 42
         $container = new Container();
40 43
 
41 44
         $container->runScoped(static function (Container $c1): void {
42
-            try {
45
+            try
46
+            {
43 47
                 $c1->get(ExceptionConstructor::class);
44 48
                 self::fail('Exception should be thrown');
45
-            } catch (\Throwable $e) {
49
+            }
50
+            catch (\Throwable $e)
51
+            {
46 52
                 self::assertInstanceOf(\Exception::class, $e);
47 53
                 throw $e;
48 54
             }
@@ -57,10 +63,13 @@  discard block
 block discarded – undo
57 63
         $container = new Container();
58 64
 
59 65
         $container->runScoped(static function (Container $c1): void {
60
-            try {
66
+            try
67
+            {
61 68
                 $c1->get(DatetimeCarrier::class);
62 69
                 self::fail('Exception should be thrown');
63
-            } catch (\Throwable $e) {
70
+            }
71
+            catch (\Throwable $e)
72
+            {
64 73
                 self::assertInstanceOf(NotFoundException::class, $e);
65 74
                 self::assertInstanceOf(NotFoundException::class, $e->getPrevious());
66 75
                 self::assertStringContainsString(
Please login to merge, or discard this patch.
src/Core/tests/ScopesTest.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
 
33 33
         $this->assertNull(ContainerScope::getContainer());
34 34
 
35
-        try {
35
+        try{
36 36
             $this->assertTrue(ContainerScope::runScope($container, function () use ($container): void {
37 37
                 throw new RuntimeException('exception');
38 38
             }));
39
-        } catch (\Throwable $e) {
39
+        }catch (\Throwable $e){
40 40
         }
41 41
 
42 42
         $this->assertInstanceOf(RuntimeException::class, $e);
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         $this->assertTrue($c->runScope([
55 55
             'bucket' => new Bucket('b'),
56 56
             'other'  => new SampleClass()
57
-        ], function ($c) {
57
+        ], function ($c){
58 58
             $this->assertSame('b', $c->get('bucket')->getName());
59 59
             $this->assertTrue($c->has('other'));
60 60
 
@@ -76,21 +76,21 @@  discard block
 block discarded – undo
76 76
         $this->assertTrue($c->runScope([
77 77
             'bucket' => new Bucket('b'),
78 78
             'other'  => new SampleClass()
79
-        ], function ($c) {
79
+        ], function ($c){
80 80
             $this->assertSame('b', $c->get('bucket')->getName());
81 81
             $this->assertTrue($c->has('other'));
82 82
 
83 83
             return $c->get('bucket')->getName() == 'b' && $c->has('other');
84 84
         }));
85 85
 
86
-        try {
86
+        try{
87 87
             $this->assertTrue($c->runScope([
88 88
                 'bucket' => new Bucket('b'),
89 89
                 'other'  => new SampleClass()
90 90
             ], function () use ($c): void {
91 91
                 throw new RuntimeException('exception');
92 92
             }));
93
-        } catch (\Throwable) {
93
+        }catch (\Throwable){
94 94
         }
95 95
 
96 96
         $this->assertSame('a', $c->get('bucket')->getName());
Please login to merge, or discard this patch.
Braces   +17 added lines, -7 removed lines patch added patch discarded remove patch
@@ -32,11 +32,14 @@  discard block
 block discarded – undo
32 32
 
33 33
         $this->assertNull(ContainerScope::getContainer());
34 34
 
35
-        try {
35
+        try
36
+        {
36 37
             $this->assertTrue(ContainerScope::runScope($container, function () use ($container): void {
37 38
                 throw new RuntimeException('exception');
38 39
             }));
39
-        } catch (\Throwable $e) {
40
+        }
41
+        catch (\Throwable $e)
42
+        {
40 43
         }
41 44
 
42 45
         $this->assertInstanceOf(RuntimeException::class, $e);
@@ -54,7 +57,8 @@  discard block
 block discarded – undo
54 57
         $this->assertTrue($c->runScope([
55 58
             'bucket' => new Bucket('b'),
56 59
             'other'  => new SampleClass()
57
-        ], function ($c) {
60
+        ], function ($c)
61
+        {
58 62
             $this->assertSame('b', $c->get('bucket')->getName());
59 63
             $this->assertTrue($c->has('other'));
60 64
 
@@ -76,21 +80,25 @@  discard block
 block discarded – undo
76 80
         $this->assertTrue($c->runScope([
77 81
             'bucket' => new Bucket('b'),
78 82
             'other'  => new SampleClass()
79
-        ], function ($c) {
83
+        ], function ($c)
84
+        {
80 85
             $this->assertSame('b', $c->get('bucket')->getName());
81 86
             $this->assertTrue($c->has('other'));
82 87
 
83 88
             return $c->get('bucket')->getName() == 'b' && $c->has('other');
84 89
         }));
85 90
 
86
-        try {
91
+        try
92
+        {
87 93
             $this->assertTrue($c->runScope([
88 94
                 'bucket' => new Bucket('b'),
89 95
                 'other'  => new SampleClass()
90 96
             ], function () use ($c): void {
91 97
                 throw new RuntimeException('exception');
92 98
             }));
93
-        } catch (\Throwable) {
99
+        }
100
+        catch (\Throwable)
101
+        {
94 102
         }
95 103
 
96 104
         $this->assertSame('a', $c->get('bucket')->getName());
@@ -138,7 +146,9 @@  discard block
 block discarded – undo
138 146
     public function testHasInstanceAfterMakeWithoutAliasInScope(): void
139 147
     {
140 148
         $container = new Container();
141
-        $container->bindSingleton('test', new #[Singleton] class {});
149
+        $container->bindSingleton('test', new #[Singleton] class
150
+        {
151
+});
142 152
         $container->make('test');
143 153
 
144 154
         $container->runScoped(function (Container $container): void {
Please login to merge, or discard this patch.