Passed
Pull Request — master (#1145)
by Aleksei
11:36
created
src/Core/tests/Scope/ProxyTest.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
                     // from the current `foo` scope
49 49
                     self::assertInstanceOf(KVLogger::class, $logger);
50 50
 
51
-                    for ($i = 0; $i < 10; $i++) {
51
+                    for ($i = 0; $i < 10; $i++){
52 52
                         // because of proxy
53 53
                         self::assertNotInstanceOf(KVLogger::class, $carrier->getLogger());
54 54
                         self::assertSame('kv', $carrier->logger->getName());
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
                     // from the current `foo` scope
69 69
                     self::assertInstanceOf(FileLogger::class, $logger);
70 70
 
71
-                    for ($i = 0; $i < 10; $i++) {
71
+                    for ($i = 0; $i < 10; $i++){
72 72
                         // because of proxy
73 73
                         self::assertNotInstanceOf(FileLogger::class, $carrier->getLogger());
74 74
                         self::assertSame('file', $carrier->logger->getName());
@@ -85,14 +85,14 @@  discard block
 block discarded – undo
85 85
         $root = new Container();
86 86
         $root->getBinder('http')->bindSingleton(LoggerInterface::class, KVLogger::class);
87 87
 
88
-        $root->runScope(new Scope(), static function (Container $c1) {
88
+        $root->runScope(new Scope(), static function (Container $c1){
89 89
             $c1->runScope(
90 90
                 new Scope(name: 'http'),
91 91
                 static function (
92 92
                     ScopedProxyLoggerCarrier $carrier,
93 93
                     ScopedProxyLoggerCarrier $carrier2,
94 94
                     LoggerInterface $logger,
95
-                ) {
95
+                ){
96 96
                     // from the current `foo` scope
97 97
                     self::assertInstanceOf(KVLogger::class, $logger);
98 98
 
@@ -112,10 +112,10 @@  discard block
 block discarded – undo
112 112
         $root = new Container();
113 113
         $root->getBinder('foo')->bind(LoggerInterface::class, KVLogger::class);
114 114
 
115
-        $root->runScope(new Scope(), static function (Container $c1) {
115
+        $root->runScope(new Scope(), static function (Container $c1){
116 116
             $c1->runScope(
117 117
                 new Scope(name: 'foo'),
118
-                static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) {
118
+                static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger){
119 119
                     // from the current `foo` scope
120 120
                     self::assertInstanceOf(KVLogger::class, $logger);
121 121
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
             ->bind(
137 137
                 ContextInterface::class,
138 138
                 new \Spiral\Core\Config\Injectable(
139
-                    new class implements InjectorInterface {
139
+                    new class implements InjectorInterface{
140 140
                         public function createInjection(\ReflectionClass $class, mixed $context = null): Context
141 141
                         {
142 142
                             return new Context($context);
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
                 ),
146 146
             );
147 147
 
148
-        $root->runScope(new Scope(), static function (Container $c1) {
149
-            $c1->runScope(new Scope(name: 'foo'), static function (Container $c, ContextInterface $param) {
148
+        $root->runScope(new Scope(), static function (Container $c1){
149
+            $c1->runScope(new Scope(name: 'foo'), static function (Container $c, ContextInterface $param){
150 150
                 self::assertInstanceOf(ReflectionParameter::class, $param->value);
151 151
                 self::assertSame('param', $param->value->getName());
152 152
 
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
             ->bind(
178 178
                 ContextInterface::class,
179 179
                 new \Spiral\Core\Config\Injectable(
180
-                    new class implements InjectorInterface {
180
+                    new class implements InjectorInterface{
181 181
                         public function createInjection(\ReflectionClass $class, mixed $context = null): Context
182 182
                         {
183 183
                             return new Context($context);
@@ -187,15 +187,15 @@  discard block
 block discarded – undo
187 187
             );
188 188
 
189 189
         FiberHelper::runFiberSequence(
190
-            static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $ctx) {
191
-                for ($i = 0; $i < 10; $i++) {
190
+            static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $ctx){
191
+                for ($i = 0; $i < 10; $i++){
192 192
                     self::assertInstanceOf(ReflectionParameter::class, $ctx->getValue(), 'Context injected');
193 193
                     self::assertSame('ctx', $ctx->getValue()->getName());
194 194
                     \Fiber::suspend();
195 195
                 }
196 196
             }),
197
-            static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $context) {
198
-                for ($i = 0; $i < 10; $i++) {
197
+            static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $context){
198
+                for ($i = 0; $i < 10; $i++){
199 199
                     self::assertInstanceOf(ReflectionParameter::class, $context->getValue(), 'Context injected');
200 200
                     self::assertSame('context', $context->getValue()->getName());
201 201
                     \Fiber::suspend();
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
     {
257 257
         $root = new Container();
258 258
         $context = (object)['destroyed' => false];
259
-        $class = new class($context) implements DestroyableInterface {
259
+        $class = new class($context) implements DestroyableInterface{
260 260
             public function __construct(
261 261
                 private readonly \stdClass $context,
262
-            ) {
262
+            ){
263 263
             }
264 264
 
265 265
             public function __destruct()
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
             new Scope('http'),
288 288
             static function () use ($root, $proxy) {
289 289
                 self::assertSame('Foo', $proxy->getName());
290
-                $proxy->setName(new class implements \Stringable {
290
+                $proxy->setName(new class implements \Stringable{
291 291
                     public function __toString(): string
292 292
                     {
293 293
                         return 'Bar';
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 
327 327
         $root->runScope(
328 328
             new Scope(),
329
-            static function (#[Proxy] ContainerInterface $proxy, ContainerInterface $scoped) {
329
+            static function (#[Proxy] ContainerInterface $proxy, ContainerInterface $scoped){
330 330
                 self::assertNotSame($scoped, $proxy);
331 331
                 ContainerScope::runScope($proxy, static function (ContainerInterface $passed) use ($proxy, $scoped) {
332 332
                     self::assertNotSame($passed, $proxy);
Please login to merge, or discard this patch.
src/Core/src/Internal/Proxy/Resolver.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -19,27 +19,27 @@  discard block
 block discarded – undo
19 19
 {
20 20
     public static function resolve(
21 21
         string $alias,
22
-        \Stringable|string|null $context = null,
22
+        \Stringable | string | null $context = null,
23 23
         ?ContainerInterface $c = null,
24 24
     ): object {
25 25
         $c ??= ContainerScope::getContainer() ?? throw new ContainerException('Proxy is out of scope.');
26 26
 
27
-        try {
27
+        try{
28 28
             /** @psalm-suppress TooManyArguments */
29 29
             $result = $c->get($alias, $context) ?? throw new ContainerException(
30 30
                 'Resolved `null` from the container.',
31 31
             );
32
-        } catch (\Throwable $e) {
32
+        }catch (\Throwable $e){
33 33
             $scope = self::getScope($c);
34 34
             throw new ContainerException(
35 35
                 $scope === null
36 36
                     ? "Unable to resolve `{$alias}` in a Proxy."
37 37
                     : "Unable to resolve `{$alias}` in a Proxy in `{$scope}` scope.",
38
-                previous: $e,
38
+                previous : $e,
39 39
             );
40 40
         }
41 41
 
42
-        if (Proxy::isProxy($result)) {
42
+        if (Proxy::isProxy($result)){
43 43
             $scope = self::getScope($c);
44 44
             throw new RecursiveProxyException(
45 45
                 $scope === null
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
      */
57 57
     private static function getScope(ContainerInterface $c): ?string
58 58
     {
59
-        if (!$c instanceof Container) {
60
-            if (!Proxy::isProxy($c)) {
59
+        if (!$c instanceof Container){
60
+            if (!Proxy::isProxy($c)){
61 61
                 return null;
62 62
             }
63 63
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         }
66 66
 
67 67
         return \implode('.', \array_reverse(\array_map(
68
-            static fn (?string $name): string => $name ?? 'null',
68
+            static fn (?string $name) : string => $name ?? 'null',
69 69
             Introspector::scopeNames($c),
70 70
         )));
71 71
     }
Please login to merge, or discard this patch.
src/Core/src/ContainerScope.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -34,26 +34,26 @@  discard block
 block discarded – undo
34 34
      */
35 35
     public static function runScope(ContainerInterface $container, callable $scope): mixed
36 36
     {
37
-        if (Proxy::isProxy($container)) {
37
+        if (Proxy::isProxy($container)){
38 38
             // Ignore Proxy to avoid recursion
39 39
             $container = $previous = self::$container ?? throw new ContainerException('Proxy is out of scope.');
40
-        } else {
40
+        }else{
41 41
             [$previous, self::$container] = [self::$container, $container];
42 42
         }
43 43
 
44
-        try {
45
-            if (Fiber::getCurrent() === null) {
44
+        try{
45
+            if (Fiber::getCurrent() === null){
46 46
                 return $scope(self::$container);
47 47
             }
48 48
 
49 49
             // Wrap scope into fiber
50 50
             $fiber = new Fiber(static fn () => $scope(self::$container));
51 51
             $value = $fiber->start();
52
-            while (!$fiber->isTerminated()) {
52
+            while (!$fiber->isTerminated()){
53 53
                 self::$container = $previous;
54
-                try {
54
+                try{
55 55
                     $resume = Fiber::suspend($value);
56
-                } catch (Throwable $e) {
56
+                }catch (Throwable $e){
57 57
                     self::$container = $container;
58 58
                     $value = $fiber->throw($e);
59 59
                     continue;
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
                 $value = $fiber->resume($resume);
64 64
             }
65 65
             return $fiber->getReturn();
66
-        } finally {
66
+        }finally{
67 67
             self::$container = $previous;
68 68
         }
69 69
     }
Please login to merge, or discard this patch.