Passed
Push — master ( 7bd689...ed0e19 )
by butschster
16:50 queued 18s
created
src/Core/tests/Internal/Proxy/ProxyClassRendererTest.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -34,24 +34,24 @@  discard block
 block discarded – undo
34 34
         yield [$from(fn(string $string = self::STRING_CONST) => 0), 'string $string = self::STRING_CONST'];
35 35
         yield [
36 36
             $from(fn(string $string = ProxyClassRendererTest::STRING_CONST) => 0),
37
-            'string $string = \\' . self::class . '::STRING_CONST',
37
+            'string $string = \\'.self::class.'::STRING_CONST',
38 38
         ];
39
-        yield [$from(fn(string|int $string = self::INT_CONST) => 0), 'string|int $string = self::INT_CONST'];
39
+        yield [$from(fn(string | int $string = self::INT_CONST) => 0), 'string|int $string = self::INT_CONST'];
40 40
         yield [$from(fn(mixed $string = 42) => 0), 'mixed $string = 42'];
41 41
         yield [$from(fn(int $string = 42) => 0), 'int $string = 42'];
42 42
         yield [$from(fn(float $string = 42) => 0), 'float $string = 42.0'];
43 43
         yield [$from(fn(?bool $string = false) => 0), '?bool $string = false'];
44
-        yield [$from(fn(bool|null $string = true) => 0), '?bool $string = true'];
44
+        yield [$from(fn(bool | null $string = true) => 0), '?bool $string = true'];
45 45
         yield [$from(fn(object $string = null) => 0), '?object $string = NULL'];
46 46
         yield [$from(fn(iterable $string = null) => 0), '?iterable $string = NULL'];
47 47
         yield [$from(fn(Countable&ArrayAccess $val) => 0), '\Countable&\ArrayAccess $val'];
48 48
         yield [$from(fn(string ...$val) => 0), 'string ...$val'];
49
-        yield [$from(fn(string|int ...$val) => 0), 'string|int ...$val'];
50
-        yield [$from(fn(string|int &$link) => 0), 'string|int &$link'];
49
+        yield [$from(fn(string | int ...$val) => 0), 'string|int ...$val'];
50
+        yield [$from(fn(string | int &$link) => 0), 'string|int &$link'];
51 51
         yield [$from(self::withSelf(...)), \sprintf('\%s $self = new self()', self::class)];
52 52
         yield [$from(fn(object $link = new \stdClass()) => 0), 'object $link = new \stdClass()'];
53 53
         yield [
54
-            $from(fn(#[Proxy] float|int|\stdClass|null $string = new \stdClass(1, 2, bar: "\n'zero")) => 0),
54
+            $from(fn(#[Proxy] float | int | \stdClass | null $string = new \stdClass(1, 2, bar: "\n'zero")) => 0),
55 55
             "\stdClass|int|float|null \$string = new \stdClass(1, 2, bar: '\n\'zero')",
56 56
         ];
57 57
         yield [
@@ -76,18 +76,18 @@  discard block
 block discarded – undo
76 76
             public const INT_CONST = 42;
77 77
 
78 78
             #[ExpectedAttribute('public function test1(...$variadic)')]
79
-            public function test1(...$variadic) {}
79
+            public function test1(...$variadic){}
80 80
             #[ExpectedAttribute('public function test2(string|int $string = self::INT_CONST): string|int')]
81
-            public function test2(string|int $string = self::INT_CONST): string|int {}
81
+            public function test2(string | int $string = self::INT_CONST): string | int {}
82 82
             #[ExpectedAttribute('public function test3(object $obj = new \stdClass(new \stdClass(), new \stdClass()))')]
83
-            public function test3(object $obj = new stdClass(new stdClass(), new stdClass())) {}
84
-            #[ExpectedAttribute('public function test4(): \\' . ProxyClassRendererTest::class)]
83
+            public function test3(object $obj = new stdClass(new stdClass(), new stdClass())){}
84
+            #[ExpectedAttribute('public function test4(): \\'.ProxyClassRendererTest::class)]
85 85
             public function test4(): ProxyClassRendererTest {}
86 86
             #[ExpectedAttribute('public function &test5(): string')]
87 87
             public function &test5(): string {}
88 88
         };
89 89
 
90
-        foreach ((new \ReflectionClass($class))->getMethods() as $method) {
90
+        foreach ((new \ReflectionClass($class))->getMethods() as $method){
91 91
             $expected = $method->getAttributes(ExpectedAttribute::class)[0]->newInstance();
92 92
 
93 93
             yield [$method, $expected->value];
@@ -117,6 +117,6 @@  discard block
 block discarded – undo
117 117
 {
118 118
     public function __construct(
119 119
         public readonly string $value,
120
-    ) {
120
+    ){
121 121
     }
122 122
 }
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -72,22 +72,28 @@
 block discarded – undo
72 72
 
73 73
     public static function provideRenderMethod(): iterable
74 74
     {
75
-        $class = new class {
75
+        $class = new class
76
+        {
76 77
             public const INT_CONST = 42;
77 78
 
78 79
             #[ExpectedAttribute('public function test1(...$variadic)')]
79
-            public function test1(...$variadic) {}
80
+            public function test1(...$variadic)
81
+            {
82
+}
80 83
             #[ExpectedAttribute('public function test2(string|int $string = self::INT_CONST): string|int')]
81 84
             public function test2(string|int $string = self::INT_CONST): string|int {}
82 85
             #[ExpectedAttribute('public function test3(object $obj = new \stdClass(new \stdClass(), new \stdClass()))')]
83
-            public function test3(object $obj = new stdClass(new stdClass(), new stdClass())) {}
86
+            public function test3(object $obj = new stdClass(new stdClass(), new stdClass()))
87
+            {
88
+}
84 89
             #[ExpectedAttribute('public function test4(): \\' . ProxyClassRendererTest::class)]
85 90
             public function test4(): ProxyClassRendererTest {}
86 91
             #[ExpectedAttribute('public function &test5(): string')]
87 92
             public function &test5(): string {}
88 93
         };
89 94
 
90
-        foreach ((new \ReflectionClass($class))->getMethods() as $method) {
95
+        foreach ((new \ReflectionClass($class))->getMethods() as $method)
96
+        {
91 97
             $expected = $method->getAttributes(ExpectedAttribute::class)[0]->newInstance();
92 98
 
93 99
             yield [$method, $expected->value];
Please login to merge, or discard this patch.
src/Core/tests/Internal/Proxy/Stub/MockInterfaceImpl.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
         return $name;
16 16
     }
17 17
 
18
-    public function qux(int|string $age = 42): string|int
18
+    public function qux(int | string $age = 42): string | int
19 19
     {
20 20
         return $age;
21 21
     }
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
     public function concat(string $prefix, string &$byLink): array
39 39
     {
40
-        $byLink = $prefix . $byLink;
40
+        $byLink = $prefix.$byLink;
41 41
         return \func_get_args();
42 42
     }
43 43
 
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
 
49 49
     public function concatMultiple(string $prefix, string &...$byLink): array
50 50
     {
51
-        foreach ($byLink as $k => $link) {
52
-            $byLink[$k] = $prefix . $link;
51
+        foreach ($byLink as $k => $link){
52
+            $byLink[$k] = $prefix.$link;
53 53
             unset($link);
54 54
         }
55 55
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,8 @@
 block discarded – undo
48 48
 
49 49
     public function concatMultiple(string $prefix, string &...$byLink): array
50 50
     {
51
-        foreach ($byLink as $k => $link) {
51
+        foreach ($byLink as $k => $link)
52
+        {
52 53
             $byLink[$k] = $prefix . $link;
53 54
             unset($link);
54 55
         }
Please login to merge, or discard this patch.
src/Core/tests/Internal/Proxy/Stub/MockInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 
13 13
     public function baz(string $name, int $age): string;
14 14
 
15
-    public function qux(string|int $age = 42): string|int;
15
+    public function qux(string | int $age = 42): string | int;
16 16
 
17 17
     public function space(mixed $test age = 42): mixed;
18 18
 
Please login to merge, or discard this patch.
src/Core/tests/Scope/FibersTest.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
         FiberHelper::runInFiber(
32 32
             self::functionScopedTestDataIterator(),
33
-            static function (mixed $suspendValue) {
33
+            static function (mixed $suspendValue){
34 34
                 self::assertNull(ContainerScope::getContainer());
35 35
                 self::assertTrue(\in_array($suspendValue, self::TEST_DATA, true));
36 36
             },
@@ -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
     }
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         $this->expectExceptionMessage('test');
93 93
 
94 94
         FiberHelper::runInFiber(
95
-            static function () {
95
+            static function (){
96 96
                 return (new Container())->runScoped(
97 97
                     function (): string {
98 98
                         $result = '';
@@ -114,15 +114,15 @@  discard block
 block discarded – undo
114 114
     public function testCatchThrownException(): void
115 115
     {
116 116
         $result = FiberHelper::runInFiber(
117
-            static function () {
117
+            static function (){
118 118
                 return (new Container())->runScoped(
119 119
                     function (): string {
120 120
                         $result = '';
121 121
                         $result .= Fiber::suspend('foo');
122 122
                         $result .= Fiber::suspend('bar');
123
-                        try {
123
+                        try{
124 124
                             $result .= Fiber::suspend('error');
125
-                        } catch (\Throwable $e) {
125
+                        }catch (\Throwable $e){
126 126
                             $result .= $e->getMessage();
127 127
                         }
128 128
                         $result .= Fiber::suspend('baz');
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
         ?callable $load = null,
153 153
         ?Container $container = null,
154 154
     ): callable {
155
-        return static function () use ($load, $container): array {
155
+        return static function () use ($load, $container) : array {
156 156
             // The function should be called in a fiber
157 157
             self::assertNotNull(Fiber::getCurrent());
158 158
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
                         $resource = $c3->get('resource');
174 174
                         self::assertInstanceOf(DateTimeImmutable::class, $c3->get('bar'));
175 175
                         self::assertInstanceOf(stdClass::class, $resource);
176
-                        foreach (self::TEST_DATA as $key => $value) {
176
+                        foreach (self::TEST_DATA as $key => $value){
177 177
                             $resource->$key = $value;
178 178
                             $load === null or $load();
179 179
                             Fiber::suspend($value);
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
             }, ['foo' => new DateTime()]);
187 187
             self::assertFalse($c1->has('foo'));
188 188
 
189
-            self::assertSame(self::TEST_DATA, (array) $result);
190
-            return (array) $result;
189
+            self::assertSame(self::TEST_DATA, (array)$result);
190
+            return (array)$result;
191 191
         };
192 192
     }
193 193
 }
Please login to merge, or discard this patch.
Braces   +21 added lines, -10 removed lines patch added patch discarded remove patch
@@ -30,7 +30,8 @@  discard block
 block discarded – undo
30 30
 
31 31
         FiberHelper::runInFiber(
32 32
             self::functionScopedTestDataIterator(),
33
-            static function (mixed $suspendValue) {
33
+            static function (mixed $suspendValue)
34
+            {
34 35
                 self::assertNull(ContainerScope::getContainer());
35 36
                 self::assertTrue(\in_array($suspendValue, self::TEST_DATA, true));
36 37
             },
@@ -63,7 +64,8 @@  discard block
 block discarded – undo
63 64
         );
64 65
 
65 66
         self::assertCount(5, $result);
66
-        foreach ($result as $suspendValue) {
67
+        foreach ($result as $suspendValue)
68
+        {
67 69
             self::assertSame(self::TEST_DATA, $suspendValue);
68 70
         }
69 71
     }
@@ -81,7 +83,8 @@  discard block
 block discarded – undo
81 83
         );
82 84
 
83 85
         self::assertCount(2, $result);
84
-        foreach ($result as $suspendValue) {
86
+        foreach ($result as $suspendValue)
87
+        {
85 88
             self::assertSame(self::TEST_DATA, $suspendValue);
86 89
         }
87 90
     }
@@ -92,7 +95,8 @@  discard block
 block discarded – undo
92 95
         $this->expectExceptionMessage('test');
93 96
 
94 97
         FiberHelper::runInFiber(
95
-            static function () {
98
+            static function ()
99
+            {
96 100
                 return (new Container())->runScoped(
97 101
                     function (): string {
98 102
                         $result = '';
@@ -114,15 +118,19 @@  discard block
 block discarded – undo
114 118
     public function testCatchThrownException(): void
115 119
     {
116 120
         $result = FiberHelper::runInFiber(
117
-            static function () {
121
+            static function ()
122
+            {
118 123
                 return (new Container())->runScoped(
119 124
                     function (): string {
120 125
                         $result = '';
121 126
                         $result .= Fiber::suspend('foo');
122 127
                         $result .= Fiber::suspend('bar');
123
-                        try {
128
+                        try
129
+                        {
124 130
                             $result .= Fiber::suspend('error');
125
-                        } catch (\Throwable $e) {
131
+                        }
132
+                        catch (\Throwable $e)
133
+                        {
126 134
                             $result .= $e->getMessage();
127 135
                         }
128 136
                         $result .= Fiber::suspend('baz');
@@ -160,20 +168,23 @@  discard block
 block discarded – undo
160 168
             $c1 = $container ?? new Container();
161 169
             $c1->bindSingleton('resource', new stdClass());
162 170
 
163
-            $result = $c1->runScoped(static function (Container $c2) use ($load) {
171
+            $result = $c1->runScoped(static function (Container $c2) use ($load)
172
+            {
164 173
                 // check local binding
165 174
                 self::assertTrue($c2->has('foo'));
166 175
                 self::assertInstanceOf(DateTime::class, $c2->get('foo'));
167 176
 
168 177
                 return $c2->runScoped(
169
-                    static function (ContainerInterface $c3) use ($load) {
178
+                    static function (ContainerInterface $c3) use ($load)
179
+                    {
170 180
                         // check local binding
171 181
                         self::assertTrue($c3->has('bar'));
172 182
 
173 183
                         $resource = $c3->get('resource');
174 184
                         self::assertInstanceOf(DateTimeImmutable::class, $c3->get('bar'));
175 185
                         self::assertInstanceOf(stdClass::class, $resource);
176
-                        foreach (self::TEST_DATA as $key => $value) {
186
+                        foreach (self::TEST_DATA as $key => $value)
187
+                        {
177 188
                             $resource->$key = $value;
178 189
                             $load === null or $load();
179 190
                             Fiber::suspend($value);
Please login to merge, or discard this patch.
src/Core/tests/Scope/Stub/ScopedProxyLoggerCarrier.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 {
11 11
     public function __construct(
12 12
         #[Proxy] public LoggerInterface $logger,
13
-    ) {
13
+    ){
14 14
     }
15 15
 
16 16
     public function getLogger(): LoggerInterface
Please login to merge, or discard this patch.
src/Core/tests/Scope/FiberHelper.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -22,11 +22,11 @@  discard block
 block discarded – undo
22 22
     {
23 23
         $fiber = new Fiber($callable);
24 24
         $value = $fiber->start();
25
-        while (!$fiber->isTerminated()) {
26
-            if ($check !== null) {
27
-                try {
25
+        while (!$fiber->isTerminated()){
26
+            if ($check !== null){
27
+                try{
28 28
                     $value = $check($value);
29
-                } catch (\Throwable $e) {
29
+                }catch (\Throwable $e){
30 30
                     $value = $fiber->throw($e);
31 31
                     continue;
32 32
                 }
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
         /** Values that were suspended by the fiber. */
51 51
         $suspends = [];
52 52
         $results = [];
53
-        foreach ($callables as $key => $callable) {
53
+        foreach ($callables as $key => $callable){
54 54
             $fiberGenerators[$key] = (static function () use ($callable) {
55 55
                 $fiber = new Fiber($callable);
56 56
                 // Get ready
57 57
                 yield null;
58 58
 
59 59
                 $value = yield $fiber->start();
60
-                while (!$fiber->isTerminated()) {
60
+                while (!$fiber->isTerminated()){
61 61
                     $value = yield $fiber->resume($value);
62 62
                 }
63 63
                 return $fiber->getReturn();
@@ -67,15 +67,15 @@  discard block
 block discarded – undo
67 67
         }
68 68
 
69 69
 
70
-        while ($fiberGenerators !== []) {
71
-            foreach ($fiberGenerators as $key => $generator) {
72
-                try {
70
+        while ($fiberGenerators !== []){
71
+            foreach ($fiberGenerators as $key => $generator){
72
+                try{
73 73
                     $suspends[$key] = $generator->send($suspends[$key]);
74
-                    if (!$generator->valid()) {
74
+                    if (!$generator->valid()){
75 75
                         $results[$key] = $generator->getReturn();
76 76
                         unset($fiberGenerators[$key]);
77 77
                     }
78
-                } catch (\Throwable $e) {
78
+                }catch (\Throwable $e){
79 79
                     unset($fiberGenerators[$key]);
80 80
                     $results[$key] = $e;
81 81
                 }
Please login to merge, or discard this patch.
Braces   +26 added lines, -12 removed lines patch added patch discarded remove patch
@@ -22,11 +22,16 @@  discard block
 block discarded – undo
22 22
     {
23 23
         $fiber = new Fiber($callable);
24 24
         $value = $fiber->start();
25
-        while (!$fiber->isTerminated()) {
26
-            if ($check !== null) {
27
-                try {
25
+        while (!$fiber->isTerminated())
26
+        {
27
+            if ($check !== null)
28
+            {
29
+                try
30
+                {
28 31
                     $value = $check($value);
29
-                } catch (\Throwable $e) {
32
+                }
33
+                catch (\Throwable $e)
34
+                {
30 35
                     $value = $fiber->throw($e);
31 36
                     continue;
32 37
                 }
@@ -50,14 +55,17 @@  discard block
 block discarded – undo
50 55
         /** Values that were suspended by the fiber. */
51 56
         $suspends = [];
52 57
         $results = [];
53
-        foreach ($callables as $key => $callable) {
54
-            $fiberGenerators[$key] = (static function () use ($callable) {
58
+        foreach ($callables as $key => $callable)
59
+        {
60
+            $fiberGenerators[$key] = (static function () use ($callable)
61
+            {
55 62
                 $fiber = new Fiber($callable);
56 63
                 // Get ready
57 64
                 yield null;
58 65
 
59 66
                 $value = yield $fiber->start();
60
-                while (!$fiber->isTerminated()) {
67
+                while (!$fiber->isTerminated())
68
+                {
61 69
                     $value = yield $fiber->resume($value);
62 70
                 }
63 71
                 return $fiber->getReturn();
@@ -67,15 +75,21 @@  discard block
 block discarded – undo
67 75
         }
68 76
 
69 77
 
70
-        while ($fiberGenerators !== []) {
71
-            foreach ($fiberGenerators as $key => $generator) {
72
-                try {
78
+        while ($fiberGenerators !== [])
79
+        {
80
+            foreach ($fiberGenerators as $key => $generator)
81
+            {
82
+                try
83
+                {
73 84
                     $suspends[$key] = $generator->send($suspends[$key]);
74
-                    if (!$generator->valid()) {
85
+                    if (!$generator->valid())
86
+                    {
75 87
                         $results[$key] = $generator->getReturn();
76 88
                         unset($fiberGenerators[$key]);
77 89
                     }
78
-                } catch (\Throwable $e) {
90
+                }
91
+                catch (\Throwable $e)
92
+                {
79 93
                     unset($fiberGenerators[$key]);
80 94
                     $results[$key] = $e;
81 95
                 }
Please login to merge, or discard this patch.
src/Core/tests/Scope/UseCaseTest.php 1 patch
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -28,7 +28,8 @@  discard block
 block discarded – undo
28 28
         $root = new Container();
29 29
         $root->bind('foo', SampleClass::class);
30 30
 
31
-        $root->runScoped(function (ContainerInterface $c1) {
31
+        $root->runScoped(function (ContainerInterface $c1)
32
+        {
32 33
             $c1->get('foo');
33 34
         }, bindings: ['foo' => SampleClass::class]);
34 35
 
@@ -61,7 +62,8 @@  discard block
 block discarded – undo
61 62
     {
62 63
         $root = new Container();
63 64
 
64
-        $root->runScoped(function (ContainerInterface $c1) use ($theSame, $alias) {
65
+        $root->runScoped(function (ContainerInterface $c1) use ($theSame, $alias)
66
+        {
65 67
             $obj1 = $c1->get($alias);
66 68
             $obj2 = $c1->get($alias);
67 69
 
@@ -86,14 +88,16 @@  discard block
 block discarded – undo
86 88
     {
87 89
         $root = new Container();
88 90
 
89
-        $root->runScoped(function (ContainerInterface $c1) use ($root) {
91
+        $root->runScoped(function (ContainerInterface $c1) use ($root)
92
+        {
90 93
             $obj1 = $c1->get('foo');
91 94
             $this->weakMap->offsetSet($obj1, true);
92 95
 
93 96
             self::assertNotSame($root, $c1);
94 97
             self::assertInstanceOf(stdClass::class, $obj1);
95 98
 
96
-            $c1->runScoped(function (ContainerInterface $c2) use ($root, $c1, $obj1) {
99
+            $c1->runScoped(function (ContainerInterface $c2) use ($root, $c1, $obj1)
100
+            {
97 101
                 $obj2 = $c2->get('foo');
98 102
                 $this->weakMap->offsetSet($obj2, true);
99 103
 
@@ -122,14 +126,16 @@  discard block
 block discarded – undo
122 126
         $root->bindSingleton('bar', [Factory::class, 'makeStdClass']);
123 127
         $root->bind(stdClass::class, new stdClass());
124 128
 
125
-        $root->runScoped(function (ContainerInterface $c1) use ($root) {
129
+        $root->runScoped(function (ContainerInterface $c1) use ($root)
130
+        {
126 131
             $obj1 = $c1->get('foo');
127 132
             $this->weakMap->offsetSet($obj1, true);
128 133
 
129 134
             self::assertInstanceOf(stdClass::class, $obj1);
130 135
             // Singleton must be the same
131 136
             self::assertSame($c1->get('bar'), $root->get('bar'));
132
-            $c1->runScoped(function (ContainerInterface $c2) use ($root, $obj1) {
137
+            $c1->runScoped(function (ContainerInterface $c2) use ($root, $obj1)
138
+            {
133 139
                 $obj2 = $c2->get('foo');
134 140
 
135 141
                 self::assertInstanceOf(stdClass::class, $obj2);
@@ -262,7 +268,8 @@  discard block
 block discarded – undo
262 268
     {
263 269
         $root = new Container();
264 270
 
265
-        $root->invoke(static function () use ($root) {
271
+        $root->invoke(static function () use ($root)
272
+        {
266 273
             self::assertNotNull(\Spiral\Core\ContainerScope::getContainer());
267 274
             self::assertSame($root, \Spiral\Core\ContainerScope::getContainer());
268 275
         });
@@ -271,7 +278,8 @@  discard block
 block discarded – undo
271 278
     public function testRegisterContainerOnGet(): void
272 279
     {
273 280
         $root = new Container();
274
-        $root->bind('foo', function () use ($root) {
281
+        $root->bind('foo', function () use ($root)
282
+        {
275 283
             self::assertNotNull(\Spiral\Core\ContainerScope::getContainer());
276 284
             self::assertSame($root, \Spiral\Core\ContainerScope::getContainer());
277 285
         });
@@ -282,7 +290,8 @@  discard block
 block discarded – undo
282 290
     public function testRegisterContainerOnMake(): void
283 291
     {
284 292
         $root = new Container();
285
-        $root->bind('foo', function () use ($root) {
293
+        $root->bind('foo', function () use ($root)
294
+        {
286 295
             self::assertNotNull(\Spiral\Core\ContainerScope::getContainer());
287 296
             self::assertSame($root, \Spiral\Core\ContainerScope::getContainer());
288 297
         });
Please login to merge, or discard this patch.
src/Core/src/Scope.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,6 +23,6 @@
 block discarded – undo
23 23
         public readonly ?string $name = null,
24 24
         public readonly array $bindings = [],
25 25
         public readonly bool $autowire = true,
26
-    ) {
26
+    ){
27 27
     }
28 28
 }
Please login to merge, or discard this patch.
src/Core/src/Container.php 2 patches
Braces   +46 added lines, -21 removed lines patch added patch discarded remove patch
@@ -170,23 +170,29 @@  discard block
 block discarded – undo
170 170
      */
171 171
     public function runScope(Scope|array $bindings, callable $scope): mixed
172 172
     {
173
-        if (!\is_array($bindings)) {
173
+        if (!\is_array($bindings))
174
+        {
174 175
             return $this->runIsolatedScope($bindings, $scope);
175 176
         }
176 177
 
177 178
         $binds = &$this->state->bindings;
178 179
         $singletons = &$this->state->singletons;
179 180
         $cleanup = $previous = $prevSin = [];
180
-        foreach ($bindings as $alias => $resolver) {
181
+        foreach ($bindings as $alias => $resolver)
182
+        {
181 183
             // Store previous bindings
182
-            if (isset($binds[$alias])) {
184
+            if (isset($binds[$alias]))
185
+            {
183 186
                 $previous[$alias] = $binds[$alias];
184
-            } else {
187
+            }
188
+            else
189
+            {
185 190
                 // Store bindings to be removed
186 191
                 $cleanup[] = $alias;
187 192
             }
188 193
             // Store previous singletons
189
-            if (isset($singletons[$alias])) {
194
+            if (isset($singletons[$alias]))
195
+            {
190 196
                 $prevSin[$alias] = $singletons[$alias];
191 197
                 unset($singletons[$alias]);
192 198
             }
@@ -194,21 +200,27 @@  discard block
 block discarded – undo
194 200
             $this->binder->bind($alias, $resolver);
195 201
         }
196 202
 
197
-        try {
203
+        try
204
+        {
198 205
             return ContainerScope::getContainer() !== $this
199 206
                 ? ContainerScope::runScope($this, $scope)
200 207
                 : $scope($this);
201
-        } finally {
208
+        }
209
+        finally
210
+        {
202 211
             // Remove new bindings
203
-            foreach ($cleanup as $alias) {
212
+            foreach ($cleanup as $alias)
213
+            {
204 214
                 unset($binds[$alias], $singletons[$alias]);
205 215
             }
206 216
             // Restore previous bindings
207
-            foreach ($previous as $alias => $resolver) {
217
+            foreach ($previous as $alias => $resolver)
218
+            {
208 219
                 $binds[$alias] = $resolver;
209 220
             }
210 221
             // Restore singletons
211
-            foreach ($prevSin as $alias => $instance) {
222
+            foreach ($prevSin as $alias => $instance)
223
+            {
212 224
                 $singletons[$alias] = $instance;
213 225
             }
214 226
         }
@@ -265,7 +277,8 @@  discard block
 block discarded – undo
265 277
      */
266 278
     public function bindSingleton(string $alias, string|array|callable|object $resolver, bool $force = true): void
267 279
     {
268
-        if ($force) {
280
+        if ($force)
281
+        {
269 282
             $this->binder->removeBinding($alias);
270 283
         }
271 284
 
@@ -336,8 +349,10 @@  discard block
 block discarded – undo
336 349
         ]);
337 350
 
338 351
         // Create container services
339
-        foreach ($container->config as $property => $class) {
340
-            if (\property_exists($container, $property)) {
352
+        foreach ($container->config as $property => $class)
353
+        {
354
+            if (\property_exists($container, $property))
355
+            {
341 356
                 $container->$property = $constructor->get($property, $class);
342 357
             }
343 358
         }
@@ -351,7 +366,8 @@  discard block
 block discarded – undo
351 366
     private function closeScope(): void
352 367
     {
353 368
         /** @psalm-suppress RedundantPropertyInitializationCheck */
354
-        if (!isset($this->scope)) {
369
+        if (!isset($this->scope))
370
+        {
355 371
             $this->destruct();
356 372
             return;
357 373
         }
@@ -360,10 +376,14 @@  discard block
 block discarded – undo
360 376
 
361 377
         // Run finalizers
362 378
         $errors = [];
363
-        foreach ($this->state->finalizers as $finalizer) {
364
-            try {
379
+        foreach ($this->state->finalizers as $finalizer)
380
+        {
381
+            try
382
+            {
365 383
                 $this->invoker->invoke($finalizer);
366
-            } catch (\Throwable $e) {
384
+            }
385
+            catch (\Throwable $e)
386
+            {
367 387
                 $errors[] = $e;
368 388
             }
369 389
         }
@@ -372,7 +392,8 @@  discard block
 block discarded – undo
372 392
         $this->destruct();
373 393
 
374 394
         // Throw collected errors
375
-        if ($errors !== []) {
395
+        if ($errors !== [])
396
+        {
376 397
             throw new FinalizersException($scopeName, $errors);
377 398
         }
378 399
     }
@@ -394,18 +415,22 @@  discard block
 block discarded – undo
394 415
         $container->scope->setParent($this, $this->scope);
395 416
 
396 417
         // Add specific bindings
397
-        foreach ($config->bindings as $alias => $resolver) {
418
+        foreach ($config->bindings as $alias => $resolver)
419
+        {
398 420
             $container->binder->bind($alias, $resolver);
399 421
         }
400 422
 
401 423
         return ContainerScope::runScope(
402 424
             $container,
403 425
             static function (self $container) use ($config, $closure): mixed {
404
-                try {
426
+                try
427
+                {
405 428
                     return $config->autowire
406 429
                         ? $container->invoke($closure)
407 430
                         : $closure($container);
408
-                } finally {
431
+                }
432
+                finally
433
+                {
409 434
                     $container->closeScope();
410 435
                 }
411 436
             }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
     public const DEFAULT_ROOT_SCOPE_NAME = 'root';
48 48
 
49 49
     private Internal\State $state;
50
-    private ResolverInterface|Internal\Resolver $resolver;
51
-    private FactoryInterface|Internal\Factory $factory;
52
-    private ContainerInterface|Internal\Container $container;
53
-    private BinderInterface|Internal\Binder $binder;
54
-    private InvokerInterface|Internal\Invoker $invoker;
50
+    private ResolverInterface | Internal\Resolver $resolver;
51
+    private FactoryInterface | Internal\Factory $factory;
52
+    private ContainerInterface | Internal\Container $container;
53
+    private BinderInterface | Internal\Binder $binder;
54
+    private InvokerInterface | Internal\Invoker $invoker;
55 55
     private Internal\Scope $scope;
56 56
 
57 57
     /**
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     public function __construct(
61 61
         private Config $config = new Config(),
62 62
         ?string $scopeName = self::DEFAULT_ROOT_SCOPE_NAME,
63
-    ) {
63
+    ){
64 64
         $this->initServices($this, $scopeName);
65 65
 
66 66
         /** @psalm-suppress RedundantPropertyInitializationCheck */
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
      * @throws \Throwable
113 113
      * @psalm-suppress TooManyArguments
114 114
      */
115
-    public function make(string $alias, array $parameters = [], \Stringable|string|null $context = null): mixed
115
+    public function make(string $alias, array $parameters = [], \Stringable | string | null $context = null): mixed
116 116
     {
117 117
         return ContainerScope::getContainer() === $this
118 118
             ? $this->factory->make($alias, $parameters, $context)
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
      * @throws \Throwable
139 139
      * @psalm-suppress TooManyArguments
140 140
      */
141
-    public function get(string|Autowire $id, \Stringable|string|null $context = null): mixed
141
+    public function get(string | Autowire $id, \Stringable | string | null $context = null): mixed
142 142
     {
143 143
         return ContainerScope::getContainer() === $this
144 144
             ? $this->container->get($id, $context)
@@ -168,25 +168,25 @@  discard block
 block discarded – undo
168 168
     /**
169 169
      * @throws \Throwable
170 170
      */
171
-    public function runScope(Scope|array $bindings, callable $scope): mixed
171
+    public function runScope(Scope | array $bindings, callable $scope): mixed
172 172
     {
173
-        if (!\is_array($bindings)) {
173
+        if (!\is_array($bindings)){
174 174
             return $this->runIsolatedScope($bindings, $scope);
175 175
         }
176 176
 
177 177
         $binds = &$this->state->bindings;
178 178
         $singletons = &$this->state->singletons;
179 179
         $cleanup = $previous = $prevSin = [];
180
-        foreach ($bindings as $alias => $resolver) {
180
+        foreach ($bindings as $alias => $resolver){
181 181
             // Store previous bindings
182
-            if (isset($binds[$alias])) {
182
+            if (isset($binds[$alias])){
183 183
                 $previous[$alias] = $binds[$alias];
184
-            } else {
184
+            }else{
185 185
                 // Store bindings to be removed
186 186
                 $cleanup[] = $alias;
187 187
             }
188 188
             // Store previous singletons
189
-            if (isset($singletons[$alias])) {
189
+            if (isset($singletons[$alias])){
190 190
                 $prevSin[$alias] = $singletons[$alias];
191 191
                 unset($singletons[$alias]);
192 192
             }
@@ -194,21 +194,21 @@  discard block
 block discarded – undo
194 194
             $this->binder->bind($alias, $resolver);
195 195
         }
196 196
 
197
-        try {
197
+        try{
198 198
             return ContainerScope::getContainer() !== $this
199 199
                 ? ContainerScope::runScope($this, $scope)
200 200
                 : $scope($this);
201
-        } finally {
201
+        }finally{
202 202
             // Remove new bindings
203
-            foreach ($cleanup as $alias) {
203
+            foreach ($cleanup as $alias){
204 204
                 unset($binds[$alias], $singletons[$alias]);
205 205
             }
206 206
             // Restore previous bindings
207
-            foreach ($previous as $alias => $resolver) {
207
+            foreach ($previous as $alias => $resolver){
208 208
                 $binds[$alias] = $resolver;
209 209
             }
210 210
             // Restore singletons
211
-            foreach ($prevSin as $alias => $instance) {
211
+            foreach ($prevSin as $alias => $instance){
212 212
                 $singletons[$alias] = $instance;
213 213
             }
214 214
         }
@@ -254,9 +254,9 @@  discard block
 block discarded – undo
254 254
      * @param bool $force If the value is false, an exception will be thrown when attempting
255 255
      *  to bind an already constructed singleton.
256 256
      */
257
-    public function bindSingleton(string $alias, string|array|callable|object $resolver, bool $force = true): void
257
+    public function bindSingleton(string $alias, string | array | callable | object $resolver, bool $force = true): void
258 258
     {
259
-        if ($force) {
259
+        if ($force){
260 260
             $this->binder->removeBinding($alias);
261 261
         }
262 262
 
@@ -327,8 +327,8 @@  discard block
 block discarded – undo
327 327
         ]);
328 328
 
329 329
         // Create container services
330
-        foreach ($container->config as $property => $class) {
331
-            if (\property_exists($container, $property)) {
330
+        foreach ($container->config as $property => $class){
331
+            if (\property_exists($container, $property)){
332 332
                 $container->$property = $constructor->get($property, $class);
333 333
             }
334 334
         }
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
     private function closeScope(): void
343 343
     {
344 344
         /** @psalm-suppress RedundantPropertyInitializationCheck */
345
-        if (!isset($this->scope)) {
345
+        if (!isset($this->scope)){
346 346
             $this->destruct();
347 347
             return;
348 348
         }
@@ -351,10 +351,10 @@  discard block
 block discarded – undo
351 351
 
352 352
         // Run finalizers
353 353
         $errors = [];
354
-        foreach ($this->state->finalizers as $finalizer) {
355
-            try {
354
+        foreach ($this->state->finalizers as $finalizer){
355
+            try{
356 356
                 $this->invoker->invoke($finalizer);
357
-            } catch (\Throwable $e) {
357
+            }catch (\Throwable $e){
358 358
                 $errors[] = $e;
359 359
             }
360 360
         }
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
         $this->destruct();
364 364
 
365 365
         // Throw collected errors
366
-        if ($errors !== []) {
366
+        if ($errors !== []){
367 367
             throw new FinalizersException($scopeName, $errors);
368 368
         }
369 369
     }
@@ -385,18 +385,18 @@  discard block
 block discarded – undo
385 385
         $container->scope->setParent($this, $this->scope);
386 386
 
387 387
         // Add specific bindings
388
-        foreach ($config->bindings as $alias => $resolver) {
388
+        foreach ($config->bindings as $alias => $resolver){
389 389
             $container->binder->bind($alias, $resolver);
390 390
         }
391 391
 
392 392
         return ContainerScope::runScope(
393 393
             $container,
394 394
             static function (self $container) use ($config, $closure): mixed {
395
-                try {
395
+                try{
396 396
                     return $config->autowire
397 397
                         ? $container->invoke($closure)
398 398
                         : $closure($container);
399
-                } finally {
399
+                }finally{
400 400
                     $container->closeScope();
401 401
                 }
402 402
             }
Please login to merge, or discard this patch.