From c7f6d7d071f3bbed63ef8b7d76b43c18f59980ea Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 30 Aug 2024 16:16:26 +0400 Subject: [PATCH 1/2] Rename context scopes --- src/Framework/Framework/Spiral.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Framework/Framework/Spiral.php b/src/Framework/Framework/Spiral.php index 63d873e45..0a6b455eb 100644 --- a/src/Framework/Framework/Spiral.php +++ b/src/Framework/Framework/Spiral.php @@ -10,17 +10,17 @@ enum Spiral: string { case Http = 'http'; - case HttpRequest = 'http.request'; + case HttpRequest = 'http-request'; case Queue = 'queue'; - case QueueTask = 'queue.task'; + case QueueTask = 'queue-task'; case Temporal = 'temporal'; - case TemporalActivity = 'temporal.activity'; + case TemporalActivity = 'temporal-activity'; case Grpc = 'grpc'; - case GrpcRequest = 'grpc.request'; + case GrpcRequest = 'grpc-request'; case Centrifugo = 'centrifugo'; - case CentrifugoRequest = 'centrifugo.request'; + case CentrifugoRequest = 'centrifugo-request'; case Tcp = 'tcp'; - case TcpRequest = 'tcp.request'; + case TcpRequest = 'tcp-request'; case Console = 'console'; - case ConsoleCommand = 'console.command'; + case ConsoleCommand = 'console-command'; } From 5e5b1bba57b823734921d9245da757b4e331082e Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 30 Aug 2024 16:37:22 +0400 Subject: [PATCH 2/2] Fix tests --- src/Core/tests/Attribute/ScopeTest.php | 2 +- src/Core/tests/Scope/ProxyTest.php | 24 +++++++++---------- src/Core/tests/Scope/UseCaseTest.php | 2 +- src/Http/src/Request/InputManager.php | 2 +- src/Router/src/CoreHandler.php | 2 +- .../Http/PaginationBootloaderTest.php | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Core/tests/Attribute/ScopeTest.php b/src/Core/tests/Attribute/ScopeTest.php index f88e3247f..4d2227ac4 100644 --- a/src/Core/tests/Attribute/ScopeTest.php +++ b/src/Core/tests/Attribute/ScopeTest.php @@ -23,7 +23,7 @@ public function testScope(string|\BackedEnum $name, string $expected): void public static function scopeNameDataProvider(): \Traversable { yield ['foo', 'foo']; - yield [Spiral::HttpRequest, 'http.request']; + yield [Spiral::HttpRequest, 'http-request']; yield [ScopeEnum::A, 'a']; } } diff --git a/src/Core/tests/Scope/ProxyTest.php b/src/Core/tests/Scope/ProxyTest.php index 2665220cf..08e3d317f 100644 --- a/src/Core/tests/Scope/ProxyTest.php +++ b/src/Core/tests/Scope/ProxyTest.php @@ -53,7 +53,7 @@ static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) use self::assertSame($lc, $carrier); \Fiber::suspend(); } - } + }, ), static fn() => $root->runScope( new Scope( @@ -73,7 +73,7 @@ static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) use self::assertSame($lc, $carrier); \Fiber::suspend(); } - } + }, ), ); } @@ -89,7 +89,7 @@ public function testResolveSameDependencyFromDifferentScopesSingleton(): void static function ( ScopedProxyLoggerCarrier $carrier, ScopedProxyLoggerCarrier $carrier2, - LoggerInterface $logger + LoggerInterface $logger, ) { // from the current `foo` scope self::assertInstanceOf(KVLogger::class, $logger); @@ -100,7 +100,7 @@ static function ( // because of proxy self::assertSame('kv', $carrier->logger->getName()); self::assertNotSame($carrier2->logger, $carrier->logger, 'Different contexts'); - } + }, ); }); } @@ -122,7 +122,7 @@ static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) { // because of proxy self::assertSame('kv', $carrier->logger->getName()); - } + }, ); }); } @@ -139,8 +139,8 @@ public function createInjection(\ReflectionClass $class, mixed $context = null): { return new Context($context); } - } - ) + }, + ), ); $root->runScope(new Scope(), static function (Container $c1) { @@ -160,7 +160,7 @@ public function createInjection(\ReflectionClass $class, mixed $context = null): self::assertInstanceOf( ReflectionParameter::class, $proxy->getContext()->getValue(), - 'Context was injected' + 'Context was injected', ); /** @see ScopedProxyStdClass::$context */ self::assertSame('context', $proxy->getContext()->getValue()->getName()); @@ -180,8 +180,8 @@ public function createInjection(\ReflectionClass $class, mixed $context = null): { return new Context($context); } - } - ) + }, + ), ); FiberHelper::runFiberSequence( @@ -216,7 +216,7 @@ static function (#[Proxy] ContainerInterface $cp) use ($root) { self::assertInstanceOf(KVLogger::class, $cp->get(LoggerInterface::class)); self::assertSame($cp->get(LoggerInterface::class), $cp->get(LoggerInterface::class)); }); - } + }, ); } @@ -292,7 +292,7 @@ public function __toString(): string } }); self::assertSame('Bar', $proxy->getName()); - } + }, ); } diff --git a/src/Core/tests/Scope/UseCaseTest.php b/src/Core/tests/Scope/UseCaseTest.php index 1943a5857..fcafabd7b 100644 --- a/src/Core/tests/Scope/UseCaseTest.php +++ b/src/Core/tests/Scope/UseCaseTest.php @@ -406,7 +406,7 @@ public function testHasInParentScopeWithScopeAttribute(): void public static function scopeEnumDataProvider(): \Traversable { - yield [Spiral::HttpRequest, 'http.request']; + yield [Spiral::HttpRequest, 'http-request']; yield [ScopeEnum::A, 'a']; } } diff --git a/src/Http/src/Request/InputManager.php b/src/Http/src/Request/InputManager.php index 66f2dd3fc..56338b13b 100644 --- a/src/Http/src/Request/InputManager.php +++ b/src/Http/src/Request/InputManager.php @@ -50,7 +50,7 @@ * @method mixed attribute(string $name, mixed $default = null) */ #[Singleton] -#[Scope('http.request')] +#[Scope('http-request')] final class InputManager { /** diff --git a/src/Router/src/CoreHandler.php b/src/Router/src/CoreHandler.php index ba000af2b..6a3bef760 100644 --- a/src/Router/src/CoreHandler.php +++ b/src/Router/src/CoreHandler.php @@ -110,7 +110,7 @@ public function handle(Request $request): Response */ $result = $this->scope->runScope( new Scope( - name: 'http.request', + name: 'http-request', bindings: [Request::class => $request, Response::class => $response, $controller => $controller], ), fn (): mixed => $this->tracer->trace( diff --git a/tests/Framework/Bootloader/Http/PaginationBootloaderTest.php b/tests/Framework/Bootloader/Http/PaginationBootloaderTest.php index 5147677a8..dfd36098d 100644 --- a/tests/Framework/Bootloader/Http/PaginationBootloaderTest.php +++ b/tests/Framework/Bootloader/Http/PaginationBootloaderTest.php @@ -24,7 +24,7 @@ public function testPaginationProviderInterfaceBindingInRootScope(): void { \set_error_handler(static function (int $errno, string $error): void { self::assertSame(\sprintf( - 'Using `%s` outside of the `http.request` scope is deprecated and will be impossible in version 4.0.', + 'Using `%s` outside of the `http-request` scope is deprecated and will be impossible in version 4.0.', PaginationProviderInterface::class ), $error); });