Skip to content

Commit

Permalink
Merge pull request #1127: rename context scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk authored Sep 2, 2024
2 parents 7767a37 + 5e5b1bb commit 569ade3
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/Core/tests/Attribute/ScopeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
}
24 changes: 12 additions & 12 deletions src/Core/tests/Scope/ProxyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) use
self::assertSame($lc, $carrier);
\Fiber::suspend();
}
}
},
),
static fn() => $root->runScope(
new Scope(
Expand All @@ -73,7 +73,7 @@ static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) use
self::assertSame($lc, $carrier);
\Fiber::suspend();
}
}
},
),
);
}
Expand All @@ -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);
Expand All @@ -100,7 +100,7 @@ static function (
// because of proxy
self::assertSame('kv', $carrier->logger->getName());
self::assertNotSame($carrier2->logger, $carrier->logger, 'Different contexts');
}
},
);
});
}
Expand All @@ -122,7 +122,7 @@ static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) {

// because of proxy
self::assertSame('kv', $carrier->logger->getName());
}
},
);
});
}
Expand All @@ -139,8 +139,8 @@ public function createInjection(\ReflectionClass $class, mixed $context = null):
{
return new Context($context);
}
}
)
},
),
);

$root->runScope(new Scope(), static function (Container $c1) {
Expand All @@ -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());
Expand All @@ -180,8 +180,8 @@ public function createInjection(\ReflectionClass $class, mixed $context = null):
{
return new Context($context);
}
}
)
},
),
);

FiberHelper::runFiberSequence(
Expand Down Expand Up @@ -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));
});
}
},
);
}

Expand Down Expand Up @@ -292,7 +292,7 @@ public function __toString(): string
}
});
self::assertSame('Bar', $proxy->getName());
}
},
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Core/tests/Scope/UseCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
}
14 changes: 7 additions & 7 deletions src/Framework/Framework/Spiral.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
2 changes: 1 addition & 1 deletion src/Http/src/Request/InputManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
* @method mixed attribute(string $name, mixed $default = null)
*/
#[Singleton]
#[Scope('http.request')]
#[Scope('http-request')]
final class InputManager
{
/**
Expand Down
2 changes: 1 addition & 1 deletion src/Router/src/CoreHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit 569ade3

Please sign in to comment.