Skip to content

Commit

Permalink
Apply styles
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Dec 11, 2024
1 parent 653f3ac commit b857503
Show file tree
Hide file tree
Showing 91 changed files with 409 additions and 475 deletions.
4 changes: 1 addition & 3 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

return \Spiral\CodeStyle\Builder::create()
->include(__DIR__ . '/src')
->include(__DIR__ . '/tests')
->exclude(__DIR__ . '/tests/generated')
->exclude(__DIR__ . '/tests/app/GRPC')
->include(__DIR__ . '/tests/src')
->include(__FILE__)
->cache('./runtime/php-cs-fixer.cache')
->allowRisky()
Expand Down
4 changes: 2 additions & 2 deletions src/Bootloader/CacheBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function defineDependencies(): array
public function defineSingletons(): array
{
return [
FactoryInterface::class => static fn (
FactoryInterface::class => static fn(
RPCInterface $rpc,
SerializerInterface $serializer,
): FactoryInterface => new Factory($rpc, $serializer),
Expand All @@ -39,7 +39,7 @@ public function defineBindings(): array
return [
StorageInterface::class =>
/** @param non-empty-string $driver */
static fn (
static fn(
FactoryInterface $factory,
string $driver,
): StorageInterface => $factory->select($driver),
Expand Down
25 changes: 12 additions & 13 deletions src/Bootloader/CentrifugoBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ final class CentrifugoBootloader extends Bootloader
{
public function __construct(
private readonly ConfiguratorInterface $config,
) {
}
) {}

public function defineSingletons(): array
{
Expand All @@ -42,17 +41,6 @@ public function defineSingletons(): array
];
}

private function initConfig(): void
{
$this->config->setDefaults(
CentrifugoConfig::CONFIG,
[
'services' => [],
'interceptors' => [],
],
);
}

public function init(BroadcastingBootloader $broadcasting): void
{
$this->initConfig();
Expand All @@ -64,6 +52,17 @@ public function boot(AbstractKernel $kernel): void
$kernel->addDispatcher(Dispatcher::class);
}

private function initConfig(): void
{
$this->config->setDefaults(
CentrifugoConfig::CONFIG,
[
'services' => [],
'interceptors' => [],
],
);
}

private function initInterceptorRegistry(
CentrifugoConfig $config,
ContainerInterface $container,
Expand Down
40 changes: 20 additions & 20 deletions src/Bootloader/GRPCBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,25 @@ public function boot(KernelInterface $kernel): void
$kernel->addDispatcher(Dispatcher::class);
}

/**
* @param Autowire|class-string<CoreInterceptorInterface>|CoreInterceptorInterface $interceptor
*/
public function addInterceptor(string|CoreInterceptorInterface|Autowire $interceptor): void
{
$this->config->modify(
GRPCConfig::CONFIG,
new Append('interceptors', null, $interceptor),
);
}

/**
* @param Autowire|class-string<GeneratorInterface>|GeneratorInterface $generator
*/
public function addGenerator(string|GeneratorInterface|Autowire $generator): void
{
$this->config->modify(GRPCConfig::CONFIG, new Append('generators', null, $generator));
}

private function initGrpcConfig(): void
{
$this->config->setDefaults(
Expand All @@ -95,25 +114,6 @@ private function initGrpcConfig(): void
);
}

/**
* @param Autowire|class-string<CoreInterceptorInterface>|CoreInterceptorInterface $interceptor
*/
public function addInterceptor(string|CoreInterceptorInterface|Autowire $interceptor): void
{
$this->config->modify(
GRPCConfig::CONFIG,
new Append('interceptors', null, $interceptor),
);
}

/**
* @param Autowire|class-string<GeneratorInterface>|GeneratorInterface $generator
*/
public function addGenerator(string|GeneratorInterface|Autowire $generator): void
{
$this->config->modify(GRPCConfig::CONFIG, new Append('generators', null, $generator));
}

/**
* @psalm-suppress DeprecatedInterface
*/
Expand Down Expand Up @@ -172,7 +172,7 @@ private function resolve(mixed $dependency, ContainerInterface $container, Facto
return match (true) {
\is_string($dependency) => $container->get($dependency),
$dependency instanceof Autowire => $dependency->resolve($factory),
default => $dependency
default => $dependency,
};
}
}
2 changes: 1 addition & 1 deletion src/Bootloader/HttpBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function defineSingletons(): array
ErrorHandlerInterface::class => LogErrorHandler::class,
PSR7Worker::class => PSR7WorkerInterface::class,

PSR7WorkerInterface::class => static fn (
PSR7WorkerInterface::class => static fn(
WorkerInterface $worker,
ServerRequestFactoryInterface $requests,
StreamFactoryInterface $streams,
Expand Down
2 changes: 1 addition & 1 deletion src/Bootloader/MetricsBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function defineDependencies(): array
public function defineSingletons(): array
{
return [
MetricsInterface::class => static fn (RPCInterface $rpc): MetricsInterface => new Metrics($rpc),
MetricsInterface::class => static fn(RPCInterface $rpc): MetricsInterface => new Metrics($rpc),
];
}
}
6 changes: 3 additions & 3 deletions src/Bootloader/RoadRunnerBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class RoadRunnerBootloader extends Bootloader
public function defineSingletons(): array
{
return [
EnvironmentInterface::class => static fn (
EnvironmentInterface::class => static fn(
GlobalEnvironmentInterface $env,
): EnvironmentInterface => new Environment($env->getAll()),

Expand All @@ -31,11 +31,11 @@ public function defineSingletons(): array
RPC::class => RPCInterface::class,
RPCInterface::class =>
/** @psalm-suppress ArgumentTypeCoercion */
static fn (
static fn(
EnvironmentInterface $env,
): RPCInterface => new RPC(Relay::create($env->getRPCAddress())),

WorkerInterface::class => static fn (
WorkerInterface::class => static fn(
EnvironmentInterface $env,
): WorkerInterface => Worker::createFromEnvironment($env),

Expand Down
3 changes: 1 addition & 2 deletions src/Bootloader/ScaffolderBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ final class ScaffolderBootloader extends Bootloader
{
public function __construct(
private readonly ContainerInterface $container,
) {
}
) {}

public function defineDependencies(): array
{
Expand Down
3 changes: 1 addition & 2 deletions src/Bootloader/TcpBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ final class TcpBootloader extends Bootloader
{
public function __construct(
private readonly ConfiguratorInterface $config,
) {
}
) {}

public function defineDependencies(): array
{
Expand Down
3 changes: 1 addition & 2 deletions src/Centrifugo/Broadcast.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ final class Broadcast extends AbstractBroadcast
{
public function __construct(
private readonly CentrifugoApiInterface $api,
) {
}
) {}

public function publish(iterable|\Stringable|string $topics, iterable|\Stringable|string $messages): void
{
Expand Down
4 changes: 1 addition & 3 deletions src/Centrifugo/Exception/CentrifugoException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

namespace Spiral\RoadRunnerBridge\Centrifugo\Exception;

class CentrifugoException extends \RuntimeException
{
}
class CentrifugoException extends \RuntimeException {}
4 changes: 1 addition & 3 deletions src/Centrifugo/Exception/ConfigurationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

namespace Spiral\RoadRunnerBridge\Centrifugo\Exception;

final class ConfigurationException extends CentrifugoException
{
}
final class ConfigurationException extends CentrifugoException {}
8 changes: 4 additions & 4 deletions src/Centrifugo/Interceptor/InterceptorRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ public function register(
throw new ConfigurationException(\sprintf(
'The $type value must be one of the `%s`, `%s` values.',
self::INTERCEPTORS_FOR_ALL_SERVICES,
\implode('`, `', array_map(static fn (\UnitEnum $case) => $case->value, RequestType::cases()))
\implode('`, `', \array_map(static fn(\UnitEnum $case) => $case->value, RequestType::cases())),
));
}

/** @var CoreInterceptorInterface $object */
$object = match (true) {
$interceptor instanceof CoreInterceptorInterface,
$interceptor instanceof InterceptorInterface => $interceptor,
$interceptor instanceof InterceptorInterface => $interceptor,
$interceptor instanceof Autowire => $interceptor->resolve($this->factory),
default => $this->container->get($interceptor)
default => $this->container->get($interceptor),
};

$this->interceptors[$type][] = $object;
Expand All @@ -69,7 +69,7 @@ public function getInterceptors(string $type): array
{
return \array_merge(
$this->interceptors[self::INTERCEPTORS_FOR_ALL_SERVICES] ?? [],
$this->interceptors[$type] ?? []
$this->interceptors[$type] ?? [],
);
}
}
5 changes: 2 additions & 3 deletions src/Centrifugo/LogErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
final class LogErrorHandler implements ErrorHandlerInterface
{
public function __construct(
private readonly ExceptionReporterInterface $reporter
) {
}
private readonly ExceptionReporterInterface $reporter,
) {}

public function handle(RequestInterface $request, \Throwable $e): void
{
Expand Down
3 changes: 1 addition & 2 deletions src/Centrifugo/RequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ final class RequestHandler implements CoreInterface
{
public function __construct(
private readonly RegistryInterface $registry,
) {
}
) {}

public function callAction(string $controller, string $action, array $parameters = []): bool
{
Expand Down
3 changes: 2 additions & 1 deletion src/Centrifugo/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ final class Server
{
private readonly PipelineBuilderInterface $pipelineBuilder;
private readonly HandlerInterface $handler;

/** @var array<non-empty-string, HandlerInterface> */
private array $pipelines = [];

Expand Down Expand Up @@ -72,7 +73,7 @@ public function serve(CentrifugoWorkerInterface $worker): void
}
}

public function getHandler(RequestType $type,): HandlerInterface
public function getHandler(RequestType $type): HandlerInterface
{
/** @psalm-suppress PossiblyInvalidArgument */
return $this->pipelines[$type->value] ??= $this->pipelineBuilder
Expand Down
8 changes: 4 additions & 4 deletions src/Config/GRPCConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function getClientConfig(): GrpcClientConfig
// Map Client options
return match (true) {
!isset($this->config['client']) => new GrpcClientConfig(),
is_array($this->config['client']) => new GrpcClientConfig(
\is_array($this->config['client']) => new GrpcClientConfig(
interceptors: $this->config['client']['interceptors'] ?? [],
services: $this->config['client']['services'] ?? [],
),
Expand Down Expand Up @@ -76,22 +76,22 @@ public function getServicesBasePath(): ?string
*/
public function getServices(): array
{
return (array)($this->config['services'] ?? []);
return (array) ($this->config['services'] ?? []);
}

/**
* @return array<Autowire|class-string<InterceptorInterface>|class-string<CoreInterceptorInterface>>
*/
public function getInterceptors(): array
{
return (array)($this->config['interceptors'] ?? []);
return (array) ($this->config['interceptors'] ?? []);
}

/**
* @return array<Autowire|class-string<GeneratorInterface>|GeneratorInterface>
*/
public function getGenerators(): array
{
return (array)($this->config['generators'] ?? []);
return (array) ($this->config['generators'] ?? []);
}
}
5 changes: 2 additions & 3 deletions src/Config/QueueConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
final class QueueConfig
{
public function __construct(
private readonly array $pipelines
) {
}
private readonly array $pipelines,
) {}

/**
* @return array<non-empty-string, TPipeline> $pipelines
Expand Down
2 changes: 1 addition & 1 deletion src/Config/TcpConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ public function getInterceptors(): array

public function isDebugMode(): bool
{
return (bool)$this->config['debug'];
return (bool) $this->config['debug'];
}
}
8 changes: 4 additions & 4 deletions src/Console/Command/GRPC/GenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function perform(
DirectoriesInterface $dirs,
GRPCConfig $config,
ProtoFilesRepositoryInterface $repository,
GeneratorRegistryInterface $generatorRegistry
GeneratorRegistryInterface $generatorRegistry,
): int {
$binaryPath = $config->getBinaryPath();

Expand All @@ -53,7 +53,7 @@ public function perform(
$this->getNamespace($kernel, $config->getNamespace()),
$files,
new ProtocCommandBuilder($files, $config, $binaryPath),
new CommandExecutor()
new CommandExecutor(),
);

$compiled = [];
Expand Down Expand Up @@ -85,7 +85,7 @@ public function perform(
"<fg=green>•</fg=green> %s%s%s\n",
Color::LIGHT_WHITE,
$files->relativePath($file, $dirs->get('root')),
Color::RESET
Color::RESET,
);

$compiled[] = $file;
Expand All @@ -97,7 +97,7 @@ public function perform(
$generator->run(
$compiled,
$this->getPath($kernel, $config->getGeneratedPath()),
$this->getNamespace($kernel, $config->getNamespace())
$this->getNamespace($kernel, $config->getNamespace()),
);
}

Expand Down
Loading

0 comments on commit b857503

Please sign in to comment.