@@ -7,11 +7,11 @@ |
||
| 7 | 7 | final class Context implements ContextInterface |
| 8 | 8 | { |
| 9 | 9 | public function __construct( |
| 10 | - public \Stringable|string|null $value, |
|
| 11 | - ) { |
|
| 10 | + public \Stringable | string | null $value, |
|
| 11 | + ){ |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - public function getValue(): \Stringable|string|null |
|
| 14 | + public function getValue(): \Stringable | string | null |
|
| 15 | 15 | { |
| 16 | 16 | return $this->value; |
| 17 | 17 | } |
@@ -6,5 +6,5 @@ |
||
| 6 | 6 | |
| 7 | 7 | interface ContextInterface |
| 8 | 8 | { |
| 9 | - public function getValue(): \Stringable|string|null; |
|
| 9 | + public function getValue(): \Stringable | string | null; |
|
| 10 | 10 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | // from the current `foo` scope |
| 43 | 43 | self::assertInstanceOf(KVLogger::class, $logger); |
| 44 | 44 | |
| 45 | - for ($i = 0; $i < 10; $i++) { |
|
| 45 | + for ($i = 0; $i < 10; $i++){ |
|
| 46 | 46 | // because of proxy |
| 47 | 47 | self::assertNotInstanceOf(KVLogger::class, $carrier->getLogger()); |
| 48 | 48 | self::assertSame('kv', $carrier->logger->getName()); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | // from the current `foo` scope |
| 63 | 63 | self::assertInstanceOf(FileLogger::class, $logger); |
| 64 | 64 | |
| 65 | - for ($i = 0; $i < 10; $i++) { |
|
| 65 | + for ($i = 0; $i < 10; $i++){ |
|
| 66 | 66 | // because of proxy |
| 67 | 67 | self::assertNotInstanceOf(FileLogger::class, $carrier->getLogger()); |
| 68 | 68 | self::assertSame('file', $carrier->logger->getName()); |
@@ -79,14 +79,14 @@ discard block |
||
| 79 | 79 | $root = new Container(); |
| 80 | 80 | $root->getBinder('http')->bindSingleton(LoggerInterface::class, KVLogger::class); |
| 81 | 81 | |
| 82 | - $root->runScope(new Scope(), static function (Container $c1) { |
|
| 82 | + $root->runScope(new Scope(), static function (Container $c1){ |
|
| 83 | 83 | $c1->runScope( |
| 84 | 84 | new Scope(name: 'http'), |
| 85 | 85 | static function ( |
| 86 | 86 | ScopedProxyLoggerCarrier $carrier, |
| 87 | 87 | ScopedProxyLoggerCarrier $carrier2, |
| 88 | 88 | LoggerInterface $logger |
| 89 | - ) { |
|
| 89 | + ){ |
|
| 90 | 90 | // from the current `foo` scope |
| 91 | 91 | self::assertInstanceOf(KVLogger::class, $logger); |
| 92 | 92 | |
@@ -106,10 +106,10 @@ discard block |
||
| 106 | 106 | $root = new Container(); |
| 107 | 107 | $root->getBinder('foo')->bind(LoggerInterface::class, KVLogger::class); |
| 108 | 108 | |
| 109 | - $root->runScope(new Scope(), static function (Container $c1) { |
|
| 109 | + $root->runScope(new Scope(), static function (Container $c1){ |
|
| 110 | 110 | $c1->runScope( |
| 111 | 111 | new Scope(name: 'foo'), |
| 112 | - static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) { |
|
| 112 | + static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger){ |
|
| 113 | 113 | // from the current `foo` scope |
| 114 | 114 | self::assertInstanceOf(KVLogger::class, $logger); |
| 115 | 115 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | ->bind( |
| 131 | 131 | ContextInterface::class, |
| 132 | 132 | new \Spiral\Core\Config\Injectable( |
| 133 | - new class implements InjectorInterface { |
|
| 133 | + new class implements InjectorInterface{ |
|
| 134 | 134 | public function createInjection(\ReflectionClass $class, mixed $context = null): Context |
| 135 | 135 | { |
| 136 | 136 | return new Context($context); |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | ) |
| 140 | 140 | ); |
| 141 | 141 | |
| 142 | - $root->runScope(new Scope(), static function (Container $c1) { |
|
| 143 | - $c1->runScope(new Scope(name: 'foo'), static function (Container $c, ContextInterface $param) { |
|
| 142 | + $root->runScope(new Scope(), static function (Container $c1){ |
|
| 143 | + $c1->runScope(new Scope(name: 'foo'), static function (Container $c, ContextInterface $param){ |
|
| 144 | 144 | self::assertInstanceOf(ReflectionParameter::class, $param->value); |
| 145 | 145 | self::assertSame('param', $param->value->getName()); |
| 146 | 146 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | ->bind( |
| 172 | 172 | ContextInterface::class, |
| 173 | 173 | new \Spiral\Core\Config\Injectable( |
| 174 | - new class implements InjectorInterface { |
|
| 174 | + new class implements InjectorInterface{ |
|
| 175 | 175 | public function createInjection(\ReflectionClass $class, mixed $context = null): Context |
| 176 | 176 | { |
| 177 | 177 | return new Context($context); |
@@ -181,15 +181,15 @@ discard block |
||
| 181 | 181 | ); |
| 182 | 182 | |
| 183 | 183 | FiberHelper::runFiberSequence( |
| 184 | - static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $ctx) { |
|
| 185 | - for ($i = 0; $i < 10; $i++) { |
|
| 184 | + static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $ctx){ |
|
| 185 | + for ($i = 0; $i < 10; $i++){ |
|
| 186 | 186 | self::assertInstanceOf(ReflectionParameter::class, $ctx->getValue(), 'Context injected'); |
| 187 | 187 | self::assertSame('ctx', $ctx->getValue()->getName()); |
| 188 | 188 | \Fiber::suspend(); |
| 189 | 189 | } |
| 190 | 190 | }), |
| 191 | - static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $context) { |
|
| 192 | - for ($i = 0; $i < 10; $i++) { |
|
| 191 | + static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $context){ |
|
| 192 | + for ($i = 0; $i < 10; $i++){ |
|
| 193 | 193 | self::assertInstanceOf(ReflectionParameter::class, $context->getValue(), 'Context injected'); |
| 194 | 194 | self::assertSame('context', $context->getValue()->getName()); |
| 195 | 195 | \Fiber::suspend(); |
@@ -38,11 +38,13 @@ discard block |
||
| 38 | 38 | LoggerInterface::class => KVLogger::class, |
| 39 | 39 | ], |
| 40 | 40 | ), |
| 41 | - static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) use ($lc) { |
|
| 41 | + static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) use ($lc) |
|
| 42 | + { |
|
| 42 | 43 | // from the current `foo` scope |
| 43 | 44 | self::assertInstanceOf(KVLogger::class, $logger); |
| 44 | 45 | |
| 45 | - for ($i = 0; $i < 10; $i++) { |
|
| 46 | + for ($i = 0; $i < 10; $i++) |
|
| 47 | + { |
|
| 46 | 48 | // because of proxy |
| 47 | 49 | self::assertNotInstanceOf(KVLogger::class, $carrier->getLogger()); |
| 48 | 50 | self::assertSame('kv', $carrier->logger->getName()); |
@@ -58,11 +60,13 @@ discard block |
||
| 58 | 60 | LoggerInterface::class => FileLogger::class, |
| 59 | 61 | ], |
| 60 | 62 | ), |
| 61 | - static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) use ($lc) { |
|
| 63 | + static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) use ($lc) |
|
| 64 | + { |
|
| 62 | 65 | // from the current `foo` scope |
| 63 | 66 | self::assertInstanceOf(FileLogger::class, $logger); |
| 64 | 67 | |
| 65 | - for ($i = 0; $i < 10; $i++) { |
|
| 68 | + for ($i = 0; $i < 10; $i++) |
|
| 69 | + { |
|
| 66 | 70 | // because of proxy |
| 67 | 71 | self::assertNotInstanceOf(FileLogger::class, $carrier->getLogger()); |
| 68 | 72 | self::assertSame('file', $carrier->logger->getName()); |
@@ -79,7 +83,8 @@ discard block |
||
| 79 | 83 | $root = new Container(); |
| 80 | 84 | $root->getBinder('http')->bindSingleton(LoggerInterface::class, KVLogger::class); |
| 81 | 85 | |
| 82 | - $root->runScope(new Scope(), static function (Container $c1) { |
|
| 86 | + $root->runScope(new Scope(), static function (Container $c1) |
|
| 87 | + { |
|
| 83 | 88 | $c1->runScope( |
| 84 | 89 | new Scope(name: 'http'), |
| 85 | 90 | static function ( |
@@ -106,10 +111,12 @@ discard block |
||
| 106 | 111 | $root = new Container(); |
| 107 | 112 | $root->getBinder('foo')->bind(LoggerInterface::class, KVLogger::class); |
| 108 | 113 | |
| 109 | - $root->runScope(new Scope(), static function (Container $c1) { |
|
| 114 | + $root->runScope(new Scope(), static function (Container $c1) |
|
| 115 | + { |
|
| 110 | 116 | $c1->runScope( |
| 111 | 117 | new Scope(name: 'foo'), |
| 112 | - static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) { |
|
| 118 | + static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) |
|
| 119 | + { |
|
| 113 | 120 | // from the current `foo` scope |
| 114 | 121 | self::assertInstanceOf(KVLogger::class, $logger); |
| 115 | 122 | |
@@ -130,7 +137,8 @@ discard block |
||
| 130 | 137 | ->bind( |
| 131 | 138 | ContextInterface::class, |
| 132 | 139 | new \Spiral\Core\Config\Injectable( |
| 133 | - new class implements InjectorInterface { |
|
| 140 | + new class implements InjectorInterface |
|
| 141 | + { |
|
| 134 | 142 | public function createInjection(\ReflectionClass $class, mixed $context = null): Context |
| 135 | 143 | { |
| 136 | 144 | return new Context($context); |
@@ -139,8 +147,10 @@ discard block |
||
| 139 | 147 | ) |
| 140 | 148 | ); |
| 141 | 149 | |
| 142 | - $root->runScope(new Scope(), static function (Container $c1) { |
|
| 143 | - $c1->runScope(new Scope(name: 'foo'), static function (Container $c, ContextInterface $param) { |
|
| 150 | + $root->runScope(new Scope(), static function (Container $c1) |
|
| 151 | + { |
|
| 152 | + $c1->runScope(new Scope(name: 'foo'), static function (Container $c, ContextInterface $param) |
|
| 153 | + { |
|
| 144 | 154 | self::assertInstanceOf(ReflectionParameter::class, $param->value); |
| 145 | 155 | self::assertSame('param', $param->value->getName()); |
| 146 | 156 | |
@@ -171,7 +181,8 @@ discard block |
||
| 171 | 181 | ->bind( |
| 172 | 182 | ContextInterface::class, |
| 173 | 183 | new \Spiral\Core\Config\Injectable( |
| 174 | - new class implements InjectorInterface { |
|
| 184 | + new class implements InjectorInterface |
|
| 185 | + { |
|
| 175 | 186 | public function createInjection(\ReflectionClass $class, mixed $context = null): Context |
| 176 | 187 | { |
| 177 | 188 | return new Context($context); |
@@ -181,15 +192,19 @@ discard block |
||
| 181 | 192 | ); |
| 182 | 193 | |
| 183 | 194 | FiberHelper::runFiberSequence( |
| 184 | - static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $ctx) { |
|
| 185 | - for ($i = 0; $i < 10; $i++) { |
|
| 195 | + static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $ctx) |
|
| 196 | + { |
|
| 197 | + for ($i = 0; $i < 10; $i++) |
|
| 198 | + { |
|
| 186 | 199 | self::assertInstanceOf(ReflectionParameter::class, $ctx->getValue(), 'Context injected'); |
| 187 | 200 | self::assertSame('ctx', $ctx->getValue()->getName()); |
| 188 | 201 | \Fiber::suspend(); |
| 189 | 202 | } |
| 190 | 203 | }), |
| 191 | - static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $context) { |
|
| 192 | - for ($i = 0; $i < 10; $i++) { |
|
| 204 | + static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $context) |
|
| 205 | + { |
|
| 206 | + for ($i = 0; $i < 10; $i++) |
|
| 207 | + { |
|
| 193 | 208 | self::assertInstanceOf(ReflectionParameter::class, $context->getValue(), 'Context injected'); |
| 194 | 209 | self::assertSame('context', $context->getValue()->getName()); |
| 195 | 210 | \Fiber::suspend(); |
@@ -205,8 +220,10 @@ discard block |
||
| 205 | 220 | |
| 206 | 221 | $root->runScope( |
| 207 | 222 | new Scope(), |
| 208 | - static function (#[Proxy] ContainerInterface $cp) use ($root) { |
|
| 209 | - $root->runScope(new Scope(name: 'http'), static function (ContainerInterface $c) use ($cp) { |
|
| 223 | + static function (#[Proxy] ContainerInterface $cp) use ($root) |
|
| 224 | + { |
|
| 225 | + $root->runScope(new Scope(name: 'http'), static function (ContainerInterface $c) use ($cp) |
|
| 226 | + { |
|
| 210 | 227 | self::assertNotSame($c, $cp); |
| 211 | 228 | self::assertSame($c, $cp->get(ContainerInterface::class)); |
| 212 | 229 | self::assertInstanceOf(KVLogger::class, $cp->get(LoggerInterface::class)); |
@@ -23,10 +23,10 @@ discard block |
||
| 23 | 23 | $root = new Container(); |
| 24 | 24 | $root->bind(LoggerInterface::class, KVLogger::class); |
| 25 | 25 | |
| 26 | - $root->runScope(new Scope(), static function (Container $c1) { |
|
| 26 | + $root->runScope(new Scope(), static function (Container $c1){ |
|
| 27 | 27 | $c1->bind(LoggerInterface::class, FileLogger::class); |
| 28 | 28 | |
| 29 | - $c1->runScope(new Scope(), static function (LoggerCarrier $carrier, LoggerInterface $logger) { |
|
| 29 | + $c1->runScope(new Scope(), static function (LoggerCarrier $carrier, LoggerInterface $logger){ |
|
| 30 | 30 | // from the $root container |
| 31 | 31 | self::assertInstanceOf(KVLogger::class, $carrier->logger); |
| 32 | 32 | // from the $c1 container |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | $root = new Container(); |
| 41 | 41 | $root->bind(LoggerInterface::class, KVLogger::class); |
| 42 | 42 | |
| 43 | - $root->runScope(new Scope(), static function (Container $c1) { |
|
| 43 | + $root->runScope(new Scope(), static function (Container $c1){ |
|
| 44 | 44 | $c1->bind(LoggerInterface::class, FileLogger::class); |
| 45 | 45 | |
| 46 | 46 | self::assertInstanceOf( |
@@ -23,10 +23,12 @@ discard block |
||
| 23 | 23 | $root = new Container(); |
| 24 | 24 | $root->bind(LoggerInterface::class, KVLogger::class); |
| 25 | 25 | |
| 26 | - $root->runScope(new Scope(), static function (Container $c1) { |
|
| 26 | + $root->runScope(new Scope(), static function (Container $c1) |
|
| 27 | + { |
|
| 27 | 28 | $c1->bind(LoggerInterface::class, FileLogger::class); |
| 28 | 29 | |
| 29 | - $c1->runScope(new Scope(), static function (LoggerCarrier $carrier, LoggerInterface $logger) { |
|
| 30 | + $c1->runScope(new Scope(), static function (LoggerCarrier $carrier, LoggerInterface $logger) |
|
| 31 | + { |
|
| 30 | 32 | // from the $root container |
| 31 | 33 | self::assertInstanceOf(KVLogger::class, $carrier->logger); |
| 32 | 34 | // from the $c1 container |
@@ -40,7 +42,8 @@ discard block |
||
| 40 | 42 | $root = new Container(); |
| 41 | 43 | $root->bind(LoggerInterface::class, KVLogger::class); |
| 42 | 44 | |
| 43 | - $root->runScope(new Scope(), static function (Container $c1) { |
|
| 45 | + $root->runScope(new Scope(), static function (Container $c1) |
|
| 46 | + { |
|
| 44 | 47 | $c1->bind(LoggerInterface::class, FileLogger::class); |
| 45 | 48 | |
| 46 | 49 | self::assertInstanceOf( |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | public static function create( |
| 24 | 24 | \ReflectionClass $type, |
| 25 | - \Stringable|string|null $context, |
|
| 25 | + \Stringable | string | null $context, |
|
| 26 | 26 | \Spiral\Core\Attribute\Proxy $attribute, |
| 27 | 27 | ): object { |
| 28 | 28 | $interface = $type->getName(); |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | $attribute->proxyOverloads ? '[magic-calls]' : '', |
| 38 | 38 | ); |
| 39 | 39 | |
| 40 | - if (!\array_key_exists($cacheKey, self::$cache)) { |
|
| 40 | + if (!\array_key_exists($cacheKey, self::$cache)){ |
|
| 41 | 41 | $n = 0; |
| 42 | - do { |
|
| 42 | + do{ |
|
| 43 | 43 | /** @var class-string<TClass> $className */ |
| 44 | 44 | $className = \sprintf( |
| 45 | 45 | '%s\%s SCOPED PROXY%s', |
@@ -47,9 +47,9 @@ discard block |
||
| 47 | 47 | $type->getShortName(), |
| 48 | 48 | $n++ > 0 ? " {$n}" : '' |
| 49 | 49 | ); |
| 50 | - } while (\class_exists($className)); |
|
| 50 | + }while (\class_exists($className)); |
|
| 51 | 51 | |
| 52 | - try { |
|
| 52 | + try{ |
|
| 53 | 53 | $classString = ProxyClassRenderer::renderClass( |
| 54 | 54 | $type, |
| 55 | 55 | $className, |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | ); |
| 59 | 59 | |
| 60 | 60 | eval($classString); |
| 61 | - } catch (\Throwable $e) { |
|
| 61 | + }catch (\Throwable $e){ |
|
| 62 | 62 | throw new \Error("Unable to create proxy for `{$interface}`: {$e->getMessage()}", 0, $e); |
| 63 | 63 | } |
| 64 | 64 | |
@@ -67,12 +67,12 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | // Store in cache without context |
| 69 | 69 | self::$cache[$cacheKey] = $instance; |
| 70 | - } else { |
|
| 70 | + }else{ |
|
| 71 | 71 | /** @var TClass $instance */ |
| 72 | 72 | $instance = self::$cache[$cacheKey]; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if ($context !== null || $attachContainer) { |
|
| 75 | + if ($context !== null || $attachContainer){ |
|
| 76 | 76 | $instance = clone $instance; |
| 77 | 77 | (static function () use ($instance, $context, $attachContainer): void { |
| 78 | 78 | // Set the Current Context |
@@ -37,9 +37,11 @@ discard block |
||
| 37 | 37 | $attribute->proxyOverloads ? '[magic-calls]' : '', |
| 38 | 38 | ); |
| 39 | 39 | |
| 40 | - if (!\array_key_exists($cacheKey, self::$cache)) { |
|
| 40 | + if (!\array_key_exists($cacheKey, self::$cache)) |
|
| 41 | + { |
|
| 41 | 42 | $n = 0; |
| 42 | - do { |
|
| 43 | + do |
|
| 44 | + { |
|
| 43 | 45 | /** @var class-string<TClass> $className */ |
| 44 | 46 | $className = \sprintf( |
| 45 | 47 | '%s\%s SCOPED PROXY%s', |
@@ -49,7 +51,8 @@ discard block |
||
| 49 | 51 | ); |
| 50 | 52 | } while (\class_exists($className)); |
| 51 | 53 | |
| 52 | - try { |
|
| 54 | + try |
|
| 55 | + { |
|
| 53 | 56 | $classString = ProxyClassRenderer::renderClass( |
| 54 | 57 | $type, |
| 55 | 58 | $className, |
@@ -58,7 +61,9 @@ discard block |
||
| 58 | 61 | ); |
| 59 | 62 | |
| 60 | 63 | eval($classString); |
| 61 | - } catch (\Throwable $e) { |
|
| 64 | + } |
|
| 65 | + catch (\Throwable $e) |
|
| 66 | + { |
|
| 62 | 67 | throw new \Error("Unable to create proxy for `{$interface}`: {$e->getMessage()}", 0, $e); |
| 63 | 68 | } |
| 64 | 69 | |
@@ -67,12 +72,15 @@ discard block |
||
| 67 | 72 | |
| 68 | 73 | // Store in cache without context |
| 69 | 74 | self::$cache[$cacheKey] = $instance; |
| 70 | - } else { |
|
| 75 | + } |
|
| 76 | + else |
|
| 77 | + { |
|
| 71 | 78 | /** @var TClass $instance */ |
| 72 | 79 | $instance = self::$cache[$cacheKey]; |
| 73 | 80 | } |
| 74 | 81 | |
| 75 | - if ($context !== null || $attachContainer) { |
|
| 82 | + if ($context !== null || $attachContainer) |
|
| 83 | + { |
|
| 76 | 84 | $instance = clone $instance; |
| 77 | 85 | (static function () use ($instance, $context, $attachContainer): void { |
| 78 | 86 | // Set the Current Context |
@@ -12,6 +12,6 @@ |
||
| 12 | 12 | trait ProxyTrait |
| 13 | 13 | { |
| 14 | 14 | private static string $__container_proxy_alias; |
| 15 | - private \Stringable|string|null $__container_proxy_context = null; |
|
| 15 | + private \Stringable | string | null $__container_proxy_context = null; |
|
| 16 | 16 | private ?ContainerInterface $__container_proxy_container = null; |
| 17 | 17 | } |
@@ -15,16 +15,16 @@ |
||
| 15 | 15 | { |
| 16 | 16 | public static function resolve( |
| 17 | 17 | string $alias, |
| 18 | - \Stringable|string|null $context = null, |
|
| 18 | + \Stringable | string | null $context = null, |
|
| 19 | 19 | ?ContainerInterface $c = null |
| 20 | 20 | ): object { |
| 21 | 21 | $c ??= ContainerScope::getContainer() ?? throw new ContainerException('Proxy is out of scope.'); |
| 22 | 22 | |
| 23 | - try { |
|
| 23 | + try{ |
|
| 24 | 24 | $result = $c->get($alias, $context) ?? throw new ContainerException( |
| 25 | 25 | 'Resolved `null` from the container.', |
| 26 | 26 | ); |
| 27 | - } catch (\Throwable $e) { |
|
| 27 | + }catch (\Throwable $e){ |
|
| 28 | 28 | throw new ContainerException( |
| 29 | 29 | \sprintf('Unable to resolve `%s` in a Proxy.', $alias), |
| 30 | 30 | previous: $e, |
@@ -20,11 +20,14 @@ |
||
| 20 | 20 | ): object { |
| 21 | 21 | $c ??= ContainerScope::getContainer() ?? throw new ContainerException('Proxy is out of scope.'); |
| 22 | 22 | |
| 23 | - try { |
|
| 23 | + try |
|
| 24 | + { |
|
| 24 | 25 | $result = $c->get($alias, $context) ?? throw new ContainerException( |
| 25 | 26 | 'Resolved `null` from the container.', |
| 26 | 27 | ); |
| 27 | - } catch (\Throwable $e) { |
|
| 28 | + } |
|
| 29 | + catch (\Throwable $e) |
|
| 30 | + { |
|
| 28 | 31 | throw new ContainerException( |
| 29 | 32 | \sprintf('Unable to resolve `%s` in a Proxy.', $alias), |
| 30 | 33 | previous: $e, |
@@ -31,6 +31,6 @@ |
||
| 31 | 31 | public bool $proxyOverloads = false; |
| 32 | 32 | |
| 33 | 33 | public function __construct( |
| 34 | - ) { |
|
| 34 | + ){ |
|
| 35 | 35 | } |
| 36 | 36 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | self::expectExceptionMessageMatches('/Call to undefined method/i'); |
| 51 | 51 | |
| 52 | - $root->invoke(static function (#[Proxy] EmptyInterface $proxy) { |
|
| 52 | + $root->invoke(static function (#[Proxy] EmptyInterface $proxy){ |
|
| 53 | 53 | $proxy->bar(name: 'foo'); // Possible to run |
| 54 | 54 | }); |
| 55 | 55 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | $proxy = $$var; |
| 94 | 94 | self::assertSame(['foo', 'bar', 'baz', 69], $proxy->extraVariadic('foo', 'bar', 'baz', 69)); |
| 95 | 95 | self::assertSame( |
| 96 | - ['foo' => 'foo','zap' => 'bar', 'gas' => 69], |
|
| 96 | + ['foo' => 'foo', 'zap' => 'bar', 'gas' => 69], |
|
| 97 | 97 | $proxy->extraVariadic(foo: 'foo', zap: 'bar', gas: 69), |
| 98 | 98 | ); |
| 99 | 99 | }); |
@@ -32,7 +32,8 @@ discard block |
||
| 32 | 32 | $root->invoke(static function ( |
| 33 | 33 | #[Proxy] MockInterface $mock, |
| 34 | 34 | #[Proxy(/*proxyOverloads: true*/)] EmptyInterface $empty, |
| 35 | - ) use ($var) { |
|
| 35 | + ) use ($var) |
|
| 36 | + { |
|
| 36 | 37 | /** @var MockInterfaceImpl $proxy */ |
| 37 | 38 | $proxy = $$var; |
| 38 | 39 | $proxy->bar(name: 'foo'); // Possible to run |
@@ -49,7 +50,8 @@ discard block |
||
| 49 | 50 | |
| 50 | 51 | self::expectExceptionMessageMatches('/Call to undefined method/i'); |
| 51 | 52 | |
| 52 | - $root->invoke(static function (#[Proxy] EmptyInterface $proxy) { |
|
| 53 | + $root->invoke(static function (#[Proxy] EmptyInterface $proxy) |
|
| 54 | + { |
|
| 53 | 55 | $proxy->bar(name: 'foo'); // Possible to run |
| 54 | 56 | }); |
| 55 | 57 | } |
@@ -66,7 +68,8 @@ discard block |
||
| 66 | 68 | $root->invoke(static function ( |
| 67 | 69 | #[Proxy] MockInterface $mock, |
| 68 | 70 | #[Proxy(/*proxyOverloads: true*/)] EmptyInterface $empty, |
| 69 | - ) use ($var) { |
|
| 71 | + ) use ($var) |
|
| 72 | + { |
|
| 70 | 73 | /** @var MockInterfaceImpl $proxy */ |
| 71 | 74 | $proxy = $$var; |
| 72 | 75 | self::assertSame(['foo', 'bar', 'baz', 69], $proxy->extra('foo', 'bar', 'baz', 69)); |
@@ -88,7 +91,8 @@ discard block |
||
| 88 | 91 | $root->invoke(static function ( |
| 89 | 92 | #[Proxy] MockInterface $mock, |
| 90 | 93 | #[Proxy(/*proxyOverloads: true*/)] EmptyInterface $empty, |
| 91 | - ) use ($var) { |
|
| 94 | + ) use ($var) |
|
| 95 | + { |
|
| 92 | 96 | /** @var MockInterfaceImpl $proxy */ |
| 93 | 97 | $proxy = $$var; |
| 94 | 98 | self::assertSame(['foo', 'bar', 'baz', 69], $proxy->extraVariadic('foo', 'bar', 'baz', 69)); |
@@ -112,7 +116,8 @@ discard block |
||
| 112 | 116 | $root->bindSingleton(MockInterface::class, Stub\MockInterfaceImpl::class); |
| 113 | 117 | $root->bindSingleton(EmptyInterface::class, Stub\MockInterfaceImpl::class); |
| 114 | 118 | |
| 115 | - $root->invoke(static function (#[Proxy] MockInterface $mock, #[Proxy] EmptyInterface $empty) use ($var) { |
|
| 119 | + $root->invoke(static function (#[Proxy] MockInterface $mock, #[Proxy] EmptyInterface $empty) use ($var) |
|
| 120 | + { |
|
| 116 | 121 | /** @var MockInterfaceImpl $proxy */ |
| 117 | 122 | $proxy = $$var; |
| 118 | 123 | $str = 'bar'; |
@@ -134,7 +139,8 @@ discard block |
||
| 134 | 139 | $root->bindSingleton(MockInterface::class, Stub\MockInterfaceImpl::class); |
| 135 | 140 | $root->bindSingleton(EmptyInterface::class, Stub\MockInterfaceImpl::class); |
| 136 | 141 | |
| 137 | - $root->invoke(static function (#[Proxy] MockInterface $mock, #[Proxy] EmptyInterface $empty) use ($var) { |
|
| 142 | + $root->invoke(static function (#[Proxy] MockInterface $mock, #[Proxy] EmptyInterface $empty) use ($var) |
|
| 143 | + { |
|
| 138 | 144 | /** @var MockInterfaceImpl $proxy */ |
| 139 | 145 | $proxy = $$var; |
| 140 | 146 | |
@@ -159,7 +165,8 @@ discard block |
||
| 159 | 165 | $root->bindSingleton(MockInterface::class, Stub\MockInterfaceImpl::class); |
| 160 | 166 | $root->bindSingleton(EmptyInterface::class, Stub\MockInterfaceImpl::class); |
| 161 | 167 | |
| 162 | - $root->invoke(static function (#[Proxy] MockInterface $mock, #[Proxy] EmptyInterface $empty) use ($var) { |
|
| 168 | + $root->invoke(static function (#[Proxy] MockInterface $mock, #[Proxy] EmptyInterface $empty) use ($var) |
|
| 169 | + { |
|
| 163 | 170 | /** @var MockInterfaceImpl $proxy */ |
| 164 | 171 | $proxy = $$var; |
| 165 | 172 | $str1 = 'bar'; |