@@ -27,7 +27,7 @@ |
||
27 | 27 | |
28 | 28 | public function __construct( |
29 | 29 | private readonly ConfiguratorInterface $config |
30 | - ) { |
|
30 | + ){ |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | public function registerDriverAlias(string $driverClass, string $alias): void |
@@ -26,5 +26,5 @@ |
||
26 | 26 | * @param MessagesList $messages |
27 | 27 | * @throws BroadcastException |
28 | 28 | */ |
29 | - public function publish(iterable|string|\Stringable $topics, iterable|string $messages): void; |
|
29 | + public function publish(iterable | string | \Stringable $topics, iterable | string $messages): void; |
|
30 | 30 | } |
@@ -22,20 +22,20 @@ discard block |
||
22 | 22 | private readonly ResponseFactoryInterface $responseFactory, |
23 | 23 | private readonly ?string $authorizationPath = null, |
24 | 24 | private readonly ?EventDispatcherInterface $dispatcher = null |
25 | - ) { |
|
25 | + ){ |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | public function process( |
29 | 29 | ServerRequestInterface $request, |
30 | 30 | RequestHandlerInterface $handler |
31 | 31 | ): ResponseInterface { |
32 | - if ($request->getUri()->getPath() !== $this->authorizationPath) { |
|
32 | + if ($request->getUri()->getPath() !== $this->authorizationPath){ |
|
33 | 33 | return $handler->handle($request); |
34 | 34 | } |
35 | 35 | |
36 | - if ($this->broadcast instanceof GuardInterface) { |
|
36 | + if ($this->broadcast instanceof GuardInterface){ |
|
37 | 37 | $status = $this->broadcast->authorize($request); |
38 | - } else { |
|
38 | + }else{ |
|
39 | 39 | $status = new AuthorizationStatus( |
40 | 40 | success: true, |
41 | 41 | topics: null |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | |
45 | 45 | $this->dispatcher?->dispatch(new Authorized($status, $request)); |
46 | 46 | |
47 | - if ($status->response !== null) { |
|
47 | + if ($status->response !== null){ |
|
48 | 48 | return $status->response; |
49 | 49 | } |
50 | 50 | |
51 | - if (!$status->success) { |
|
51 | + if (!$status->success){ |
|
52 | 52 | return $this->responseFactory->createResponse(403); |
53 | 53 | } |
54 | 54 |
@@ -29,13 +29,17 @@ discard block |
||
29 | 29 | ServerRequestInterface $request, |
30 | 30 | RequestHandlerInterface $handler |
31 | 31 | ): ResponseInterface { |
32 | - if ($request->getUri()->getPath() !== $this->authorizationPath) { |
|
32 | + if ($request->getUri()->getPath() !== $this->authorizationPath) |
|
33 | + { |
|
33 | 34 | return $handler->handle($request); |
34 | 35 | } |
35 | 36 | |
36 | - if ($this->broadcast instanceof GuardInterface) { |
|
37 | + if ($this->broadcast instanceof GuardInterface) |
|
38 | + { |
|
37 | 39 | $status = $this->broadcast->authorize($request); |
38 | - } else { |
|
40 | + } |
|
41 | + else |
|
42 | + { |
|
39 | 43 | $status = new AuthorizationStatus( |
40 | 44 | success: true, |
41 | 45 | topics: null |
@@ -44,11 +48,13 @@ discard block |
||
44 | 48 | |
45 | 49 | $this->dispatcher?->dispatch(new Authorized($status, $request)); |
46 | 50 | |
47 | - if ($status->response !== null) { |
|
51 | + if ($status->response !== null) |
|
52 | + { |
|
48 | 53 | return $status->response; |
49 | 54 | } |
50 | 55 | |
51 | - if (!$status->success) { |
|
56 | + if (!$status->success) |
|
57 | + { |
|
52 | 58 | return $this->responseFactory->createResponse(403); |
53 | 59 | } |
54 | 60 |
@@ -13,10 +13,10 @@ |
||
13 | 13 | */ |
14 | 14 | public function __construct( |
15 | 15 | public readonly bool $success, |
16 | - public readonly ?array $topics, |
|
16 | + public readonly ? array $topics, |
|
17 | 17 | public readonly array $attributes = [], |
18 | 18 | public readonly ?ResponseInterface $response = null |
19 | - ) { |
|
19 | + ){ |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -26,7 +26,7 @@ |
||
26 | 26 | public function get(array $values): array |
27 | 27 | { |
28 | 28 | $output = []; |
29 | - foreach ($values as $key => $value) { |
|
29 | + foreach ($values as $key => $value){ |
|
30 | 30 | $output[$key] = self::TYPE_DEFAULTS[\gettype($value)] ?? null; |
31 | 31 | } |
32 | 32 |
@@ -26,7 +26,8 @@ |
||
26 | 26 | public function get(array $values): array |
27 | 27 | { |
28 | 28 | $output = []; |
29 | - foreach ($values as $key => $value) { |
|
29 | + foreach ($values as $key => $value) |
|
30 | + { |
|
30 | 31 | $output[$key] = self::TYPE_DEFAULTS[\gettype($value)] ?? null; |
31 | 32 | } |
32 | 33 |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | public function getAnnotation(mixed $value): string |
28 | 28 | { |
29 | - if (\is_array($value)) { |
|
29 | + if (\is_array($value)){ |
|
30 | 30 | return $this->arrayAnnotationString($value); |
31 | 31 | } |
32 | 32 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | private function arrayAnnotationString(array $value): string |
42 | 42 | { |
43 | 43 | $types = []; |
44 | - foreach ($value as $item) { |
|
44 | + foreach ($value as $item){ |
|
45 | 45 | $types[] = \gettype($item); |
46 | 46 | } |
47 | 47 | $types = \array_unique($types); |
@@ -26,7 +26,8 @@ discard block |
||
26 | 26 | |
27 | 27 | public function getAnnotation(mixed $value): string |
28 | 28 | { |
29 | - if (\is_array($value)) { |
|
29 | + if (\is_array($value)) |
|
30 | + { |
|
30 | 31 | return $this->arrayAnnotationString($value); |
31 | 32 | } |
32 | 33 | |
@@ -41,7 +42,8 @@ discard block |
||
41 | 42 | private function arrayAnnotationString(array $value): string |
42 | 43 | { |
43 | 44 | $types = []; |
44 | - foreach ($value as $item) { |
|
45 | + foreach ($value as $item) |
|
46 | + { |
|
45 | 47 | $types[] = \gettype($item); |
46 | 48 | } |
47 | 49 | $types = \array_unique($types); |
@@ -23,22 +23,22 @@ |
||
23 | 23 | |
24 | 24 | public function loadEnvVariables(DirectoriesInterface $dirs, EnvironmentInterface $env): void |
25 | 25 | { |
26 | - if ($this->init) { |
|
26 | + if ($this->init){ |
|
27 | 27 | return; |
28 | 28 | } |
29 | 29 | |
30 | 30 | $this->init = true; |
31 | 31 | |
32 | - $dotenvPath = $env->get('DOTENV_PATH', $dirs->get('root') . '.env'); |
|
32 | + $dotenvPath = $env->get('DOTENV_PATH', $dirs->get('root').'.env'); |
|
33 | 33 | |
34 | - if (!\file_exists($dotenvPath)) { |
|
34 | + if (!\file_exists($dotenvPath)){ |
|
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | 38 | $path = \dirname($dotenvPath); |
39 | 39 | $file = \basename($dotenvPath); |
40 | 40 | |
41 | - foreach (Dotenv::createImmutable($path, $file)->load() as $key => $value) { |
|
41 | + foreach (Dotenv::createImmutable($path, $file)->load() as $key => $value){ |
|
42 | 42 | $env->set($key, $value); |
43 | 43 | } |
44 | 44 | } |
@@ -23,7 +23,8 @@ discard block |
||
23 | 23 | |
24 | 24 | public function loadEnvVariables(DirectoriesInterface $dirs, EnvironmentInterface $env): void |
25 | 25 | { |
26 | - if ($this->init) { |
|
26 | + if ($this->init) |
|
27 | + { |
|
27 | 28 | return; |
28 | 29 | } |
29 | 30 | |
@@ -31,14 +32,16 @@ discard block |
||
31 | 32 | |
32 | 33 | $dotenvPath = $env->get('DOTENV_PATH', $dirs->get('root') . '.env'); |
33 | 34 | |
34 | - if (!\file_exists($dotenvPath)) { |
|
35 | + if (!\file_exists($dotenvPath)) |
|
36 | + { |
|
35 | 37 | return; |
36 | 38 | } |
37 | 39 | |
38 | 40 | $path = \dirname($dotenvPath); |
39 | 41 | $file = \basename($dotenvPath); |
40 | 42 | |
41 | - foreach (Dotenv::createImmutable($path, $file)->load() as $key => $value) { |
|
43 | + foreach (Dotenv::createImmutable($path, $file)->load() as $key => $value) |
|
44 | + { |
|
42 | 45 | $env->set($key, $value); |
43 | 46 | } |
44 | 47 | } |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | public function getDirectives(): array |
25 | 25 | { |
26 | 26 | $directives = []; |
27 | - foreach ($this->config['directives'] as $directive) { |
|
28 | - if (\is_object($directive) && !$directive instanceof Autowire) { |
|
27 | + foreach ($this->config['directives'] as $directive){ |
|
28 | + if (\is_object($directive) && !$directive instanceof Autowire){ |
|
29 | 29 | $directives[] = $directive; |
30 | 30 | continue; |
31 | 31 | } |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | public function getProcessors(): array |
43 | 43 | { |
44 | 44 | $processors = []; |
45 | - foreach ($this->config['processors'] as $processor) { |
|
46 | - if (is_object($processor) && !$processor instanceof Autowire) { |
|
45 | + foreach ($this->config['processors'] as $processor){ |
|
46 | + if (is_object($processor) && !$processor instanceof Autowire){ |
|
47 | 47 | $processors[] = $processor; |
48 | 48 | continue; |
49 | 49 | } |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | public function getVisitors(int $stage): array |
58 | 58 | { |
59 | 59 | $visitors = []; |
60 | - foreach ($this->config['visitors'][$stage] ?? [] as $visitor) { |
|
61 | - if (\is_object($visitor) && !$visitor instanceof Autowire) { |
|
60 | + foreach ($this->config['visitors'][$stage] ?? [] as $visitor){ |
|
61 | + if (\is_object($visitor) && !$visitor instanceof Autowire){ |
|
62 | 62 | $visitors[] = $visitor; |
63 | 63 | continue; |
64 | 64 | } |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | */ |
75 | 75 | private function wire(mixed $item): Autowire |
76 | 76 | { |
77 | - if ($item instanceof Autowire) { |
|
77 | + if ($item instanceof Autowire){ |
|
78 | 78 | return $item; |
79 | 79 | } |
80 | 80 | |
81 | - if (\is_string($item)) { |
|
81 | + if (\is_string($item)){ |
|
82 | 82 | return new Autowire($item); |
83 | 83 | } |
84 | 84 |
@@ -24,8 +24,10 @@ discard block |
||
24 | 24 | public function getDirectives(): array |
25 | 25 | { |
26 | 26 | $directives = []; |
27 | - foreach ($this->config['directives'] as $directive) { |
|
28 | - if (\is_object($directive) && !$directive instanceof Autowire) { |
|
27 | + foreach ($this->config['directives'] as $directive) |
|
28 | + { |
|
29 | + if (\is_object($directive) && !$directive instanceof Autowire) |
|
30 | + { |
|
29 | 31 | $directives[] = $directive; |
30 | 32 | continue; |
31 | 33 | } |
@@ -42,8 +44,10 @@ discard block |
||
42 | 44 | public function getProcessors(): array |
43 | 45 | { |
44 | 46 | $processors = []; |
45 | - foreach ($this->config['processors'] as $processor) { |
|
46 | - if (is_object($processor) && !$processor instanceof Autowire) { |
|
47 | + foreach ($this->config['processors'] as $processor) |
|
48 | + { |
|
49 | + if (is_object($processor) && !$processor instanceof Autowire) |
|
50 | + { |
|
47 | 51 | $processors[] = $processor; |
48 | 52 | continue; |
49 | 53 | } |
@@ -57,8 +61,10 @@ discard block |
||
57 | 61 | public function getVisitors(int $stage): array |
58 | 62 | { |
59 | 63 | $visitors = []; |
60 | - foreach ($this->config['visitors'][$stage] ?? [] as $visitor) { |
|
61 | - if (\is_object($visitor) && !$visitor instanceof Autowire) { |
|
64 | + foreach ($this->config['visitors'][$stage] ?? [] as $visitor) |
|
65 | + { |
|
66 | + if (\is_object($visitor) && !$visitor instanceof Autowire) |
|
67 | + { |
|
62 | 68 | $visitors[] = $visitor; |
63 | 69 | continue; |
64 | 70 | } |
@@ -74,11 +80,13 @@ discard block |
||
74 | 80 | */ |
75 | 81 | private function wire(mixed $item): Autowire |
76 | 82 | { |
77 | - if ($item instanceof Autowire) { |
|
83 | + if ($item instanceof Autowire) |
|
84 | + { |
|
78 | 85 | return $item; |
79 | 86 | } |
80 | 87 | |
81 | - if (\is_string($item)) { |
|
88 | + if (\is_string($item)) |
|
89 | + { |
|
82 | 90 | return new Autowire($item); |
83 | 91 | } |
84 | 92 |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | { |
17 | 17 | public function __construct( |
18 | 18 | private readonly ContainerInterface $container |
19 | - ) { |
|
19 | + ){ |
|
20 | 20 | parent::__construct(); |
21 | 21 | } |
22 | 22 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function renderRoute(Directive $directive): string |
27 | 27 | { |
28 | - if (\count($directive->values) < 1) { |
|
28 | + if (\count($directive->values) < 1){ |
|
29 | 29 | throw new DirectiveException( |
30 | 30 | 'Unable to call @route directive, at least 1 value is required', |
31 | 31 | $directive->getContext() |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | { |
46 | 46 | $vars = []; |
47 | 47 | $restore = []; |
48 | - foreach ($params as $key => $value) { |
|
49 | - if (\is_string($value) && \preg_match('#\{.*\}#', $value)) { |
|
48 | + foreach ($params as $key => $value){ |
|
49 | + if (\is_string($value) && \preg_match('#\{.*\}#', $value)){ |
|
50 | 50 | $restore[\sprintf('__%s__', $key)] = $value; |
51 | 51 | $value = \sprintf('__%s__', $key); |
52 | 52 | } |
@@ -54,12 +54,12 @@ discard block |
||
54 | 54 | $vars[$key] = $value; |
55 | 55 | } |
56 | 56 | |
57 | - try { |
|
57 | + try{ |
|
58 | 58 | return \strtr( |
59 | 59 | $this->container->get(RouterInterface::class)->uri($route, $vars)->__toString(), |
60 | 60 | $restore |
61 | 61 | ); |
62 | - } catch (UndefinedRouteException $e) { |
|
62 | + }catch (UndefinedRouteException $e){ |
|
63 | 63 | throw new RouterException("No such route {$route}", $e->getCode(), $e); |
64 | 64 | } |
65 | 65 | } |
@@ -25,7 +25,8 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function renderRoute(Directive $directive): string |
27 | 27 | { |
28 | - if (\count($directive->values) < 1) { |
|
28 | + if (\count($directive->values) < 1) |
|
29 | + { |
|
29 | 30 | throw new DirectiveException( |
30 | 31 | 'Unable to call @route directive, at least 1 value is required', |
31 | 32 | $directive->getContext() |
@@ -45,8 +46,10 @@ discard block |
||
45 | 46 | { |
46 | 47 | $vars = []; |
47 | 48 | $restore = []; |
48 | - foreach ($params as $key => $value) { |
|
49 | - if (\is_string($value) && \preg_match('#\{.*\}#', $value)) { |
|
49 | + foreach ($params as $key => $value) |
|
50 | + { |
|
51 | + if (\is_string($value) && \preg_match('#\{.*\}#', $value)) |
|
52 | + { |
|
50 | 53 | $restore[\sprintf('__%s__', $key)] = $value; |
51 | 54 | $value = \sprintf('__%s__', $key); |
52 | 55 | } |
@@ -54,12 +57,15 @@ discard block |
||
54 | 57 | $vars[$key] = $value; |
55 | 58 | } |
56 | 59 | |
57 | - try { |
|
60 | + try |
|
61 | + { |
|
58 | 62 | return \strtr( |
59 | 63 | $this->container->get(RouterInterface::class)->uri($route, $vars)->__toString(), |
60 | 64 | $restore |
61 | 65 | ); |
62 | - } catch (UndefinedRouteException $e) { |
|
66 | + } |
|
67 | + catch (UndefinedRouteException $e) |
|
68 | + { |
|
63 | 69 | throw new RouterException("No such route {$route}", $e->getCode(), $e); |
64 | 70 | } |
65 | 71 | } |