@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | // from the current `foo` scope |
| 47 | 47 | self::assertInstanceOf(KVLogger::class, $logger); |
| 48 | 48 | |
| 49 | - for ($i = 0; $i < 10; $i++) { |
|
| 49 | + for ($i = 0; $i < 10; $i++){ |
|
| 50 | 50 | // because of proxy |
| 51 | 51 | self::assertNotInstanceOf(KVLogger::class, $carrier->getLogger()); |
| 52 | 52 | self::assertSame('kv', $carrier->logger->getName()); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | // from the current `foo` scope |
| 67 | 67 | self::assertInstanceOf(FileLogger::class, $logger); |
| 68 | 68 | |
| 69 | - for ($i = 0; $i < 10; $i++) { |
|
| 69 | + for ($i = 0; $i < 10; $i++){ |
|
| 70 | 70 | // because of proxy |
| 71 | 71 | self::assertNotInstanceOf(FileLogger::class, $carrier->getLogger()); |
| 72 | 72 | self::assertSame('file', $carrier->logger->getName()); |
@@ -83,14 +83,14 @@ discard block |
||
| 83 | 83 | $root = new Container(); |
| 84 | 84 | $root->getBinder('http')->bindSingleton(LoggerInterface::class, KVLogger::class); |
| 85 | 85 | |
| 86 | - $root->runScope(new Scope(), static function (Container $c1) { |
|
| 86 | + $root->runScope(new Scope(), static function (Container $c1){ |
|
| 87 | 87 | $c1->runScope( |
| 88 | 88 | new Scope(name: 'http'), |
| 89 | 89 | static function ( |
| 90 | 90 | ScopedProxyLoggerCarrier $carrier, |
| 91 | 91 | ScopedProxyLoggerCarrier $carrier2, |
| 92 | 92 | LoggerInterface $logger, |
| 93 | - ) { |
|
| 93 | + ){ |
|
| 94 | 94 | // from the current `foo` scope |
| 95 | 95 | self::assertInstanceOf(KVLogger::class, $logger); |
| 96 | 96 | |
@@ -110,10 +110,10 @@ discard block |
||
| 110 | 110 | $root = new Container(); |
| 111 | 111 | $root->getBinder('foo')->bind(LoggerInterface::class, KVLogger::class); |
| 112 | 112 | |
| 113 | - $root->runScope(new Scope(), static function (Container $c1) { |
|
| 113 | + $root->runScope(new Scope(), static function (Container $c1){ |
|
| 114 | 114 | $c1->runScope( |
| 115 | 115 | new Scope(name: 'foo'), |
| 116 | - static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) { |
|
| 116 | + static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger){ |
|
| 117 | 117 | // from the current `foo` scope |
| 118 | 118 | self::assertInstanceOf(KVLogger::class, $logger); |
| 119 | 119 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | ->bind( |
| 135 | 135 | ContextInterface::class, |
| 136 | 136 | new \Spiral\Core\Config\Injectable( |
| 137 | - new class implements InjectorInterface { |
|
| 137 | + new class implements InjectorInterface{ |
|
| 138 | 138 | public function createInjection(\ReflectionClass $class, mixed $context = null): Context |
| 139 | 139 | { |
| 140 | 140 | return new Context($context); |
@@ -143,8 +143,8 @@ discard block |
||
| 143 | 143 | ), |
| 144 | 144 | ); |
| 145 | 145 | |
| 146 | - $root->runScope(new Scope(), static function (Container $c1) { |
|
| 147 | - $c1->runScope(new Scope(name: 'foo'), static function (Container $c, ContextInterface $param) { |
|
| 146 | + $root->runScope(new Scope(), static function (Container $c1){ |
|
| 147 | + $c1->runScope(new Scope(name: 'foo'), static function (Container $c, ContextInterface $param){ |
|
| 148 | 148 | self::assertInstanceOf(ReflectionParameter::class, $param->value); |
| 149 | 149 | self::assertSame('param', $param->value->getName()); |
| 150 | 150 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | ->bind( |
| 176 | 176 | ContextInterface::class, |
| 177 | 177 | new \Spiral\Core\Config\Injectable( |
| 178 | - new class implements InjectorInterface { |
|
| 178 | + new class implements InjectorInterface{ |
|
| 179 | 179 | public function createInjection(\ReflectionClass $class, mixed $context = null): Context |
| 180 | 180 | { |
| 181 | 181 | return new Context($context); |
@@ -185,15 +185,15 @@ discard block |
||
| 185 | 185 | ); |
| 186 | 186 | |
| 187 | 187 | FiberHelper::runFiberSequence( |
| 188 | - static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $ctx) { |
|
| 189 | - for ($i = 0; $i < 10; $i++) { |
|
| 188 | + static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $ctx){ |
|
| 189 | + for ($i = 0; $i < 10; $i++){ |
|
| 190 | 190 | self::assertInstanceOf(ReflectionParameter::class, $ctx->getValue(), 'Context injected'); |
| 191 | 191 | self::assertSame('ctx', $ctx->getValue()->getName()); |
| 192 | 192 | \Fiber::suspend(); |
| 193 | 193 | } |
| 194 | 194 | }), |
| 195 | - static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $context) { |
|
| 196 | - for ($i = 0; $i < 10; $i++) { |
|
| 195 | + static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $context){ |
|
| 196 | + for ($i = 0; $i < 10; $i++){ |
|
| 197 | 197 | self::assertInstanceOf(ReflectionParameter::class, $context->getValue(), 'Context injected'); |
| 198 | 198 | self::assertSame('context', $context->getValue()->getName()); |
| 199 | 199 | \Fiber::suspend(); |
@@ -254,10 +254,10 @@ discard block |
||
| 254 | 254 | { |
| 255 | 255 | $root = new Container(); |
| 256 | 256 | $context = (object)['destroyed' => false]; |
| 257 | - $class = new class($context) implements DestroyableInterface { |
|
| 257 | + $class = new class($context) implements DestroyableInterface{ |
|
| 258 | 258 | public function __construct( |
| 259 | 259 | private readonly \stdClass $context, |
| 260 | - ) { |
|
| 260 | + ){ |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | public function __destruct() |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | new Scope('http'), |
| 286 | 286 | static function () use ($root, $proxy) { |
| 287 | 287 | self::assertSame('Foo', $proxy->getName()); |
| 288 | - $proxy->setName(new class implements \Stringable { |
|
| 288 | + $proxy->setName(new class implements \Stringable{ |
|
| 289 | 289 | public function __toString(): string |
| 290 | 290 | { |
| 291 | 291 | return 'Bar'; |
@@ -42,11 +42,13 @@ discard block |
||
| 42 | 42 | LoggerInterface::class => KVLogger::class, |
| 43 | 43 | ], |
| 44 | 44 | ), |
| 45 | - static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) use ($lc) { |
|
| 45 | + static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) use ($lc) |
|
| 46 | + { |
|
| 46 | 47 | // from the current `foo` scope |
| 47 | 48 | self::assertInstanceOf(KVLogger::class, $logger); |
| 48 | 49 | |
| 49 | - for ($i = 0; $i < 10; $i++) { |
|
| 50 | + for ($i = 0; $i < 10; $i++) |
|
| 51 | + { |
|
| 50 | 52 | // because of proxy |
| 51 | 53 | self::assertNotInstanceOf(KVLogger::class, $carrier->getLogger()); |
| 52 | 54 | self::assertSame('kv', $carrier->logger->getName()); |
@@ -62,11 +64,13 @@ discard block |
||
| 62 | 64 | LoggerInterface::class => FileLogger::class, |
| 63 | 65 | ], |
| 64 | 66 | ), |
| 65 | - static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) use ($lc) { |
|
| 67 | + static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) use ($lc) |
|
| 68 | + { |
|
| 66 | 69 | // from the current `foo` scope |
| 67 | 70 | self::assertInstanceOf(FileLogger::class, $logger); |
| 68 | 71 | |
| 69 | - for ($i = 0; $i < 10; $i++) { |
|
| 72 | + for ($i = 0; $i < 10; $i++) |
|
| 73 | + { |
|
| 70 | 74 | // because of proxy |
| 71 | 75 | self::assertNotInstanceOf(FileLogger::class, $carrier->getLogger()); |
| 72 | 76 | self::assertSame('file', $carrier->logger->getName()); |
@@ -83,7 +87,8 @@ discard block |
||
| 83 | 87 | $root = new Container(); |
| 84 | 88 | $root->getBinder('http')->bindSingleton(LoggerInterface::class, KVLogger::class); |
| 85 | 89 | |
| 86 | - $root->runScope(new Scope(), static function (Container $c1) { |
|
| 90 | + $root->runScope(new Scope(), static function (Container $c1) |
|
| 91 | + { |
|
| 87 | 92 | $c1->runScope( |
| 88 | 93 | new Scope(name: 'http'), |
| 89 | 94 | static function ( |
@@ -110,10 +115,12 @@ discard block |
||
| 110 | 115 | $root = new Container(); |
| 111 | 116 | $root->getBinder('foo')->bind(LoggerInterface::class, KVLogger::class); |
| 112 | 117 | |
| 113 | - $root->runScope(new Scope(), static function (Container $c1) { |
|
| 118 | + $root->runScope(new Scope(), static function (Container $c1) |
|
| 119 | + { |
|
| 114 | 120 | $c1->runScope( |
| 115 | 121 | new Scope(name: 'foo'), |
| 116 | - static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) { |
|
| 122 | + static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) |
|
| 123 | + { |
|
| 117 | 124 | // from the current `foo` scope |
| 118 | 125 | self::assertInstanceOf(KVLogger::class, $logger); |
| 119 | 126 | |
@@ -134,7 +141,8 @@ discard block |
||
| 134 | 141 | ->bind( |
| 135 | 142 | ContextInterface::class, |
| 136 | 143 | new \Spiral\Core\Config\Injectable( |
| 137 | - new class implements InjectorInterface { |
|
| 144 | + new class implements InjectorInterface |
|
| 145 | + { |
|
| 138 | 146 | public function createInjection(\ReflectionClass $class, mixed $context = null): Context |
| 139 | 147 | { |
| 140 | 148 | return new Context($context); |
@@ -143,8 +151,10 @@ discard block |
||
| 143 | 151 | ), |
| 144 | 152 | ); |
| 145 | 153 | |
| 146 | - $root->runScope(new Scope(), static function (Container $c1) { |
|
| 147 | - $c1->runScope(new Scope(name: 'foo'), static function (Container $c, ContextInterface $param) { |
|
| 154 | + $root->runScope(new Scope(), static function (Container $c1) |
|
| 155 | + { |
|
| 156 | + $c1->runScope(new Scope(name: 'foo'), static function (Container $c, ContextInterface $param) |
|
| 157 | + { |
|
| 148 | 158 | self::assertInstanceOf(ReflectionParameter::class, $param->value); |
| 149 | 159 | self::assertSame('param', $param->value->getName()); |
| 150 | 160 | |
@@ -175,7 +185,8 @@ discard block |
||
| 175 | 185 | ->bind( |
| 176 | 186 | ContextInterface::class, |
| 177 | 187 | new \Spiral\Core\Config\Injectable( |
| 178 | - new class implements InjectorInterface { |
|
| 188 | + new class implements InjectorInterface |
|
| 189 | + { |
|
| 179 | 190 | public function createInjection(\ReflectionClass $class, mixed $context = null): Context |
| 180 | 191 | { |
| 181 | 192 | return new Context($context); |
@@ -185,15 +196,19 @@ discard block |
||
| 185 | 196 | ); |
| 186 | 197 | |
| 187 | 198 | FiberHelper::runFiberSequence( |
| 188 | - static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $ctx) { |
|
| 189 | - for ($i = 0; $i < 10; $i++) { |
|
| 199 | + static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $ctx) |
|
| 200 | + { |
|
| 201 | + for ($i = 0; $i < 10; $i++) |
|
| 202 | + { |
|
| 190 | 203 | self::assertInstanceOf(ReflectionParameter::class, $ctx->getValue(), 'Context injected'); |
| 191 | 204 | self::assertSame('ctx', $ctx->getValue()->getName()); |
| 192 | 205 | \Fiber::suspend(); |
| 193 | 206 | } |
| 194 | 207 | }), |
| 195 | - static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $context) { |
|
| 196 | - for ($i = 0; $i < 10; $i++) { |
|
| 208 | + static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $context) |
|
| 209 | + { |
|
| 210 | + for ($i = 0; $i < 10; $i++) |
|
| 211 | + { |
|
| 197 | 212 | self::assertInstanceOf(ReflectionParameter::class, $context->getValue(), 'Context injected'); |
| 198 | 213 | self::assertSame('context', $context->getValue()->getName()); |
| 199 | 214 | \Fiber::suspend(); |
@@ -209,8 +224,10 @@ discard block |
||
| 209 | 224 | |
| 210 | 225 | $root->runScope( |
| 211 | 226 | new Scope(), |
| 212 | - static function (#[Proxy] ContainerInterface $cp) use ($root) { |
|
| 213 | - $root->runScope(new Scope(name: 'http'), static function (ContainerInterface $c) use ($cp) { |
|
| 227 | + static function (#[Proxy] ContainerInterface $cp) use ($root) |
|
| 228 | + { |
|
| 229 | + $root->runScope(new Scope(name: 'http'), static function (ContainerInterface $c) use ($cp) |
|
| 230 | + { |
|
| 214 | 231 | self::assertNotSame($c, $cp); |
| 215 | 232 | self::assertSame($c, $cp->get(ContainerInterface::class)); |
| 216 | 233 | self::assertInstanceOf(KVLogger::class, $cp->get(LoggerInterface::class)); |
@@ -254,7 +271,8 @@ discard block |
||
| 254 | 271 | { |
| 255 | 272 | $root = new Container(); |
| 256 | 273 | $context = (object)['destroyed' => false]; |
| 257 | - $class = new class($context) implements DestroyableInterface { |
|
| 274 | + $class = new class($context) implements DestroyableInterface |
|
| 275 | + { |
|
| 258 | 276 | public function __construct( |
| 259 | 277 | private readonly \stdClass $context, |
| 260 | 278 | ) { |
@@ -283,7 +301,8 @@ discard block |
||
| 283 | 301 | |
| 284 | 302 | $root->runScope( |
| 285 | 303 | new Scope('http'), |
| 286 | - static function () use ($root, $proxy) { |
|
| 304 | + static function () use ($root, $proxy) |
|
| 305 | + { |
|
| 287 | 306 | self::assertSame('Foo', $proxy->getName()); |
| 288 | 307 | $proxy->setName(new class implements \Stringable { |
| 289 | 308 | public function __toString(): string |