@@ -66,11 +66,13 @@ discard block |
||
| 66 | 66 | $registry = $container->get(QueueRegistry::class); |
| 67 | 67 | $config = $container->get(QueueConfig::class); |
| 68 | 68 | |
| 69 | - foreach ($config->getRegistryHandlers() as $jobType => $handler) { |
|
| 69 | + foreach ($config->getRegistryHandlers() as $jobType => $handler) |
|
| 70 | + { |
|
| 70 | 71 | $registry->setHandler($jobType, $handler); |
| 71 | 72 | } |
| 72 | 73 | |
| 73 | - foreach ($config->getRegistrySerializers() as $jobType => $serializer) { |
|
| 74 | + foreach ($config->getRegistrySerializers() as $jobType => $serializer) |
|
| 75 | + { |
|
| 74 | 76 | $registry->setSerializer($jobType, $serializer); |
| 75 | 77 | } |
| 76 | 78 | }); |
@@ -128,10 +130,14 @@ discard block |
||
| 128 | 130 | ): Handler { |
| 129 | 131 | $core = new InterceptableCore($core, $dispatcher); |
| 130 | 132 | |
| 131 | - foreach ($config->getConsumeInterceptors() as $interceptor) { |
|
| 132 | - if (\is_string($interceptor)) { |
|
| 133 | + foreach ($config->getConsumeInterceptors() as $interceptor) |
|
| 134 | + { |
|
| 135 | + if (\is_string($interceptor)) |
|
| 136 | + { |
|
| 133 | 137 | $interceptor = $container->get($interceptor); |
| 134 | - } elseif ($interceptor instanceof Autowire) { |
|
| 138 | + } |
|
| 139 | + elseif ($interceptor instanceof Autowire) |
|
| 140 | + { |
|
| 135 | 141 | $interceptor = $interceptor->resolve($factory); |
| 136 | 142 | } |
| 137 | 143 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | public function __construct( |
| 49 | 49 | private readonly ConfiguratorInterface $config, |
| 50 | - ) { |
|
| 50 | + ){ |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | public function init( |
@@ -65,11 +65,11 @@ discard block |
||
| 65 | 65 | $registry = $container->get(QueueRegistry::class); |
| 66 | 66 | $config = $container->get(QueueConfig::class); |
| 67 | 67 | |
| 68 | - foreach ($config->getRegistryHandlers() as $jobType => $handler) { |
|
| 68 | + foreach ($config->getRegistryHandlers() as $jobType => $handler){ |
|
| 69 | 69 | $registry->setHandler($jobType, $handler); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - foreach ($config->getRegistrySerializers() as $jobType => $serializer) { |
|
| 72 | + foreach ($config->getRegistrySerializers() as $jobType => $serializer){ |
|
| 73 | 73 | $registry->setSerializer($jobType, $serializer); |
| 74 | 74 | } |
| 75 | 75 | }); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | /** |
| 79 | 79 | * @param class-string<CoreInterceptorInterface>|CoreInterceptorInterface|Autowire $interceptor |
| 80 | 80 | */ |
| 81 | - public function addConsumeInterceptor(string|CoreInterceptorInterface|Autowire $interceptor): void |
|
| 81 | + public function addConsumeInterceptor(string | CoreInterceptorInterface | Autowire $interceptor): void |
|
| 82 | 82 | { |
| 83 | 83 | $this->config->modify( |
| 84 | 84 | QueueConfig::CONFIG, |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | /** |
| 90 | 90 | * @param class-string<CoreInterceptorInterface>|CoreInterceptorInterface|Autowire $interceptor |
| 91 | 91 | */ |
| 92 | - public function addPushInterceptor(string|CoreInterceptorInterface|Autowire $interceptor): void |
|
| 92 | + public function addPushInterceptor(string | CoreInterceptorInterface | Autowire $interceptor): void |
|
| 93 | 93 | { |
| 94 | 94 | $this->config->modify( |
| 95 | 95 | QueueConfig::CONFIG, |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | ContainerInterface $container, |
| 115 | 115 | FactoryInterface $factory, |
| 116 | 116 | ContainerRegistry $registry, |
| 117 | - ) { |
|
| 117 | + ){ |
|
| 118 | 118 | return new QueueRegistry($container, $factory, $registry); |
| 119 | 119 | } |
| 120 | 120 | |
@@ -128,10 +128,10 @@ discard block |
||
| 128 | 128 | ): Handler { |
| 129 | 129 | $core = new InterceptableCore($core, $dispatcher); |
| 130 | 130 | |
| 131 | - foreach ($config->getConsumeInterceptors() as $interceptor) { |
|
| 132 | - if (\is_string($interceptor)) { |
|
| 131 | + foreach ($config->getConsumeInterceptors() as $interceptor){ |
|
| 132 | + if (\is_string($interceptor)){ |
|
| 133 | 133 | $interceptor = $container->get($interceptor); |
| 134 | - } elseif ($interceptor instanceof Autowire) { |
|
| 134 | + } elseif ($interceptor instanceof Autowire){ |
|
| 135 | 135 | $interceptor = $interceptor->resolve($factory); |
| 136 | 136 | } |
| 137 | 137 | |
@@ -18,24 +18,24 @@ |
||
| 18 | 18 | { |
| 19 | 19 | public function __construct( |
| 20 | 20 | private readonly QueueConnectionProviderInterface $queueManager |
| 21 | - ) { |
|
| 21 | + ){ |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | public function createInjection(ReflectionClass $class, string $context = null): QueueInterface |
| 25 | 25 | { |
| 26 | - try { |
|
| 27 | - if ($context === null) { |
|
| 26 | + try{ |
|
| 27 | + if ($context === null){ |
|
| 28 | 28 | $connection = $this->queueManager->getConnection(); |
| 29 | - } else { |
|
| 29 | + }else{ |
|
| 30 | 30 | // Get Queue by context |
| 31 | - try { |
|
| 31 | + try{ |
|
| 32 | 32 | $connection = $this->queueManager->getConnection($context); |
| 33 | - } catch (InvalidArgumentException) { |
|
| 33 | + }catch (InvalidArgumentException){ |
|
| 34 | 34 | // Case when context doesn't match to configured connections |
| 35 | 35 | return $this->queueManager->getConnection(); |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | - } catch (\Throwable $e) { |
|
| 38 | + }catch (\Throwable $e){ |
|
| 39 | 39 | throw new ContainerException(\sprintf("Can't inject the required queue. %s", $e->getMessage()), 0, $e); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -23,19 +23,28 @@ |
||
| 23 | 23 | |
| 24 | 24 | public function createInjection(ReflectionClass $class, string $context = null): QueueInterface |
| 25 | 25 | { |
| 26 | - try { |
|
| 27 | - if ($context === null) { |
|
| 26 | + try |
|
| 27 | + { |
|
| 28 | + if ($context === null) |
|
| 29 | + { |
|
| 28 | 30 | $connection = $this->queueManager->getConnection(); |
| 29 | - } else { |
|
| 31 | + } |
|
| 32 | + else |
|
| 33 | + { |
|
| 30 | 34 | // Get Queue by context |
| 31 | - try { |
|
| 35 | + try |
|
| 36 | + { |
|
| 32 | 37 | $connection = $this->queueManager->getConnection($context); |
| 33 | - } catch (InvalidArgumentException) { |
|
| 38 | + } |
|
| 39 | + catch (InvalidArgumentException) |
|
| 40 | + { |
|
| 34 | 41 | // Case when context doesn't match to configured connections |
| 35 | 42 | return $this->queueManager->getConnection(); |
| 36 | 43 | } |
| 37 | 44 | } |
| 38 | - } catch (\Throwable $e) { |
|
| 45 | + } |
|
| 46 | + catch (\Throwable $e) |
|
| 47 | + { |
|
| 39 | 48 | throw new ContainerException(\sprintf("Can't inject the required queue. %s", $e->getMessage()), 0, $e); |
| 40 | 49 | } |
| 41 | 50 | |
@@ -87,7 +87,7 @@ |
||
| 87 | 87 | $factory->shouldReceive('make')->andReturnUsing(function (string $name): QueueInterface { |
| 88 | 88 | $result = ['sync' => $this->defaultQueue, 'test' => $this->testQueue][$name] ?? null; |
| 89 | 89 | |
| 90 | - if ($result === null) { |
|
| 90 | + if ($result === null){ |
|
| 91 | 91 | throw new NotFoundException(); |
| 92 | 92 | } |
| 93 | 93 | return $result; |
@@ -87,7 +87,8 @@ |
||
| 87 | 87 | $factory->shouldReceive('make')->andReturnUsing(function (string $name): QueueInterface { |
| 88 | 88 | $result = ['sync' => $this->defaultQueue, 'test' => $this->testQueue][$name] ?? null; |
| 89 | 89 | |
| 90 | - if ($result === null) { |
|
| 90 | + if ($result === null) |
|
| 91 | + { |
|
| 91 | 92 | throw new NotFoundException(); |
| 92 | 93 | } |
| 93 | 94 | return $result; |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | public function __construct( |
| 44 | 44 | private readonly ConfiguratorInterface $config |
| 45 | - ) { |
|
| 45 | + ){ |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | public function init(AbstractKernel $kernel, EnvironmentInterface $env): void |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | ] |
| 58 | 58 | ); |
| 59 | 59 | |
| 60 | - $kernel->booting(function () { |
|
| 60 | + $kernel->booting(function (){ |
|
| 61 | 61 | $this->addTransport('cookie', $this->createDefaultCookieTransport()); |
| 62 | 62 | $this->addTransport('header', new HeaderTransport('X-Auth-Token')); |
| 63 | 63 | $this->addTokenStorage('session', SessionTokenStorage::class); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * @param non-empty-string $name |
| 71 | 71 | * @param Autowire|HttpTransportInterface|class-string<HttpTransportInterface> $transport |
| 72 | 72 | */ |
| 73 | - public function addTransport(string $name, Autowire|HttpTransportInterface|string $transport): void |
|
| 73 | + public function addTransport(string $name, Autowire | HttpTransportInterface | string $transport): void |
|
| 74 | 74 | { |
| 75 | 75 | $this->config->modify(AuthConfig::CONFIG, new Append('transports', $name, $transport)); |
| 76 | 76 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * @param non-empty-string $name |
| 82 | 82 | * @param Autowire|TokenStorageInterface|class-string<TokenStorageInterface> $storage |
| 83 | 83 | */ |
| 84 | - public function addTokenStorage(string $name, Autowire|TokenStorageInterface|string $storage): void |
|
| 84 | + public function addTokenStorage(string $name, Autowire | TokenStorageInterface | string $storage): void |
|
| 85 | 85 | { |
| 86 | 86 | $this->config->modify(AuthConfig::CONFIG, new Append('storages', $name, $storage)); |
| 87 | 87 | } |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | $registry = new TransportRegistry(); |
| 105 | 105 | $registry->setDefaultTransport($config->getDefaultTransport()); |
| 106 | 106 | |
| 107 | - foreach ($config->getTransports() as $name => $transport) { |
|
| 108 | - if ($transport instanceof Autowire) { |
|
| 107 | + foreach ($config->getTransports() as $name => $transport){ |
|
| 108 | + if ($transport instanceof Autowire){ |
|
| 109 | 109 | $transport = $transport->resolve($factory); |
| 110 | 110 | } |
| 111 | 111 | |
@@ -57,7 +57,8 @@ discard block |
||
| 57 | 57 | ] |
| 58 | 58 | ); |
| 59 | 59 | |
| 60 | - $kernel->booting(function () { |
|
| 60 | + $kernel->booting(function () |
|
| 61 | + { |
|
| 61 | 62 | $this->addTransport('cookie', $this->createDefaultCookieTransport()); |
| 62 | 63 | $this->addTransport('header', new HeaderTransport('X-Auth-Token')); |
| 63 | 64 | $this->addTokenStorage('session', SessionTokenStorage::class); |
@@ -104,8 +105,10 @@ discard block |
||
| 104 | 105 | $registry = new TransportRegistry(); |
| 105 | 106 | $registry->setDefaultTransport($config->getDefaultTransport()); |
| 106 | 107 | |
| 107 | - foreach ($config->getTransports() as $name => $transport) { |
|
| 108 | - if ($transport instanceof Autowire) { |
|
| 108 | + foreach ($config->getTransports() as $name => $transport) |
|
| 109 | + { |
|
| 110 | + if ($transport instanceof Autowire) |
|
| 111 | + { |
|
| 109 | 112 | $transport = $transport->resolve($factory); |
| 110 | 113 | } |
| 111 | 114 | |
@@ -39,9 +39,9 @@ |
||
| 39 | 39 | * @return TokenStorageInterface|class-string<TokenStorageInterface>|Autowire |
| 40 | 40 | * @throws InvalidArgumentException |
| 41 | 41 | */ |
| 42 | - public function getStorage(string $name): TokenStorageInterface|string|Autowire |
|
| 42 | + public function getStorage(string $name): TokenStorageInterface | string | Autowire |
|
| 43 | 43 | { |
| 44 | - if (!isset($this->config['storages'][$name])) { |
|
| 44 | + if (!isset($this->config['storages'][$name])){ |
|
| 45 | 45 | throw new InvalidArgumentException( |
| 46 | 46 | \sprintf('Token storage `%s` is not defined.', $name) |
| 47 | 47 | ); |
@@ -41,7 +41,8 @@ |
||
| 41 | 41 | */ |
| 42 | 42 | public function getStorage(string $name): TokenStorageInterface|string|Autowire |
| 43 | 43 | { |
| 44 | - if (!isset($this->config['storages'][$name])) { |
|
| 44 | + if (!isset($this->config['storages'][$name])) |
|
| 45 | + { |
|
| 45 | 46 | throw new InvalidArgumentException( |
| 46 | 47 | \sprintf('Token storage `%s` is not defined.', $name) |
| 47 | 48 | ); |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | TransportRegistry $transportRegistry, |
| 30 | 30 | ?EventDispatcherInterface $eventDispatcher = null, |
| 31 | 31 | ?string $storage = null |
| 32 | - ) { |
|
| 32 | + ){ |
|
| 33 | 33 | $this->authMiddleware = new AuthTransportMiddleware( |
| 34 | 34 | $transportName, |
| 35 | 35 | $scope, |
@@ -16,14 +16,14 @@ discard block |
||
| 16 | 16 | public function __construct( |
| 17 | 17 | private readonly AuthConfig $config, |
| 18 | 18 | private readonly FactoryInterface $factory |
| 19 | - ) { |
|
| 19 | + ){ |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | public function getStorage(?string $name = null): TokenStorageInterface |
| 23 | 23 | { |
| 24 | 24 | $name ??= $this->config->getDefaultStorage(); |
| 25 | 25 | |
| 26 | - if (isset($this->storages[$name])) { |
|
| 26 | + if (isset($this->storages[$name])){ |
|
| 27 | 27 | return $this->storages[$name]; |
| 28 | 28 | } |
| 29 | 29 | |
@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | { |
| 35 | 35 | $storage = $this->config->getStorage($name); |
| 36 | 36 | |
| 37 | - if ($storage instanceof TokenStorageInterface) { |
|
| 37 | + if ($storage instanceof TokenStorageInterface){ |
|
| 38 | 38 | return $storage; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - if ($storage instanceof Autowire) { |
|
| 41 | + if ($storage instanceof Autowire){ |
|
| 42 | 42 | return $storage->resolve($this->factory); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -23,7 +23,8 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | $name ??= $this->config->getDefaultStorage(); |
| 25 | 25 | |
| 26 | - if (isset($this->storages[$name])) { |
|
| 26 | + if (isset($this->storages[$name])) |
|
| 27 | + { |
|
| 27 | 28 | return $this->storages[$name]; |
| 28 | 29 | } |
| 29 | 30 | |
@@ -34,11 +35,13 @@ discard block |
||
| 34 | 35 | { |
| 35 | 36 | $storage = $this->config->getStorage($name); |
| 36 | 37 | |
| 37 | - if ($storage instanceof TokenStorageInterface) { |
|
| 38 | + if ($storage instanceof TokenStorageInterface) |
|
| 39 | + { |
|
| 38 | 40 | return $storage; |
| 39 | 41 | } |
| 40 | 42 | |
| 41 | - if ($storage instanceof Autowire) { |
|
| 43 | + if ($storage instanceof Autowire) |
|
| 44 | + { |
|
| 42 | 45 | return $storage->resolve($this->factory); |
| 43 | 46 | } |
| 44 | 47 | |
@@ -34,6 +34,6 @@ |
||
| 34 | 34 | new ServerRequest('GET', new Uri('/admin'), ['X-Auth-Token' => $token], 'php://input') |
| 35 | 35 | ); |
| 36 | 36 | |
| 37 | - $this->assertSame($token === 'ok' ? '/admin' : '/login', (string) $response->getBody()); |
|
| 37 | + $this->assertSame($token === 'ok' ? '/admin' : '/login', (string)$response->getBody()); |
|
| 38 | 38 | } |
| 39 | 39 | } |
@@ -75,7 +75,7 @@ |
||
| 75 | 75 | |
| 76 | 76 | $http->setHandler( |
| 77 | 77 | static function (ServerRequestInterface $request, ResponseInterface $response): void { |
| 78 | - if ($request->getAttribute('authContext')->getToken() === null) { |
|
| 78 | + if ($request->getAttribute('authContext')->getToken() === null){ |
|
| 79 | 79 | echo 'no token'; |
| 80 | 80 | } |
| 81 | 81 | } |
@@ -75,7 +75,8 @@ |
||
| 75 | 75 | |
| 76 | 76 | $http->setHandler( |
| 77 | 77 | static function (ServerRequestInterface $request, ResponseInterface $response): void { |
| 78 | - if ($request->getAttribute('authContext')->getToken() === null) { |
|
| 78 | + if ($request->getAttribute('authContext')->getToken() === null) |
|
| 79 | + { |
|
| 79 | 80 | echo 'no token'; |
| 80 | 81 | } |
| 81 | 82 | } |