@@ -18,7 +18,7 @@ |
||
18 | 18 | |
19 | 19 | public function __construct( |
20 | 20 | private readonly TranslatorInterface $translator |
21 | - ) { |
|
21 | + ){ |
|
22 | 22 | $this->locales = $translator->getCatalogueManager()->getLocales(); |
23 | 23 | } |
24 | 24 |
@@ -11,7 +11,7 @@ |
||
11 | 11 | { |
12 | 12 | public function __construct( |
13 | 13 | private readonly MemoryInterface $memory |
14 | - ) { |
|
14 | + ){ |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | public function setLocales(?array $locales): void |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | use Spiral\Core\Container\Autowire; |
7 | 7 | use Spiral\Router\RouterInterface; |
8 | 8 | |
9 | -if (!\function_exists('bind')) { |
|
9 | +if (!\function_exists('bind')){ |
|
10 | 10 | /** |
11 | 11 | * Shortcut to container Autowire definition. |
12 | 12 | * |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | } |
22 | 22 | } |
23 | 23 | |
24 | -if (!\function_exists('route')) { |
|
24 | +if (!\function_exists('route')){ |
|
25 | 25 | /** |
26 | 26 | * Generate the URL to a named route. |
27 | 27 | * |
@@ -6,7 +6,8 @@ discard block |
||
6 | 6 | use Spiral\Core\Container\Autowire; |
7 | 7 | use Spiral\Router\RouterInterface; |
8 | 8 | |
9 | -if (!\function_exists('bind')) { |
|
9 | +if (!\function_exists('bind')) |
|
10 | +{ |
|
10 | 11 | /** |
11 | 12 | * Shortcut to container Autowire definition. |
12 | 13 | * |
@@ -21,7 +22,8 @@ discard block |
||
21 | 22 | } |
22 | 23 | } |
23 | 24 | |
24 | -if (!\function_exists('route')) { |
|
25 | +if (!\function_exists('route')) |
|
26 | +{ |
|
25 | 27 | /** |
26 | 28 | * Generate the URL to a named route. |
27 | 29 | * |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | private readonly PermissionsInterface $permissions, |
21 | 21 | private readonly ContainerInterface $container, |
22 | 22 | private array $roles = [] |
23 | - ) { |
|
23 | + ){ |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | public function allows(string $permission, array $context = []): bool |
30 | 30 | { |
31 | 31 | $allows = false; |
32 | - foreach ($this->getRoles() as $role) { |
|
33 | - if (!$this->permissions->hasRole($role)) { |
|
32 | + foreach ($this->getRoles() as $role){ |
|
33 | + if (!$this->permissions->hasRole($role)){ |
|
34 | 34 | continue; |
35 | 35 | } |
36 | 36 | |
@@ -70,13 +70,13 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function getActor(): ActorInterface |
72 | 72 | { |
73 | - if (!\is_null($this->actor)) { |
|
73 | + if (!\is_null($this->actor)){ |
|
74 | 74 | return $this->actor; |
75 | 75 | } |
76 | 76 | |
77 | - try { |
|
77 | + try{ |
|
78 | 78 | return $this->container->get(ActorInterface::class); |
79 | - } catch (NotFoundExceptionInterface $e) { |
|
79 | + }catch (NotFoundExceptionInterface $e){ |
|
80 | 80 | throw new ScopeException('Unable to resolve Actor from the scope', $e->getCode(), $e); |
81 | 81 | } |
82 | 82 | } |
@@ -29,8 +29,10 @@ discard block |
||
29 | 29 | public function allows(string $permission, array $context = []): bool |
30 | 30 | { |
31 | 31 | $allows = false; |
32 | - foreach ($this->getRoles() as $role) { |
|
33 | - if (!$this->permissions->hasRole($role)) { |
|
32 | + foreach ($this->getRoles() as $role) |
|
33 | + { |
|
34 | + if (!$this->permissions->hasRole($role)) |
|
35 | + { |
|
34 | 36 | continue; |
35 | 37 | } |
36 | 38 | |
@@ -70,13 +72,17 @@ discard block |
||
70 | 72 | */ |
71 | 73 | public function getActor(): ActorInterface |
72 | 74 | { |
73 | - if (!\is_null($this->actor)) { |
|
75 | + if (!\is_null($this->actor)) |
|
76 | + { |
|
74 | 77 | return $this->actor; |
75 | 78 | } |
76 | 79 | |
77 | - try { |
|
80 | + try |
|
81 | + { |
|
78 | 82 | return $this->container->get(ActorInterface::class); |
79 | - } catch (NotFoundExceptionInterface $e) { |
|
83 | + } |
|
84 | + catch (NotFoundExceptionInterface $e) |
|
85 | + { |
|
80 | 86 | throw new ScopeException('Unable to resolve Actor from the scope', $e->getCode(), $e); |
81 | 87 | } |
82 | 88 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | public function populate(StateInterface $state): void |
25 | 25 | { |
26 | - if ($this->request === null) { |
|
26 | + if ($this->request === null){ |
|
27 | 27 | return; |
28 | 28 | } |
29 | 29 | |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | |
33 | 33 | $state->setVariable('headers', $this->request->getHeaders()); |
34 | 34 | |
35 | - if ($this->request->getQueryParams() !== []) { |
|
35 | + if ($this->request->getQueryParams() !== []){ |
|
36 | 36 | $state->setVariable('query', $this->request->getQueryParams()); |
37 | 37 | } |
38 | 38 | |
39 | - if ($this->request->getParsedBody() !== null) { |
|
39 | + if ($this->request->getParsedBody() !== null){ |
|
40 | 40 | $state->setVariable('data', $this->request->getParsedBody()); |
41 | 41 | } |
42 | 42 | } |
@@ -23,7 +23,8 @@ discard block |
||
23 | 23 | |
24 | 24 | public function populate(StateInterface $state): void |
25 | 25 | { |
26 | - if ($this->request === null) { |
|
26 | + if ($this->request === null) |
|
27 | + { |
|
27 | 28 | return; |
28 | 29 | } |
29 | 30 | |
@@ -32,11 +33,13 @@ discard block |
||
32 | 33 | |
33 | 34 | $state->setVariable('headers', $this->request->getHeaders()); |
34 | 35 | |
35 | - if ($this->request->getQueryParams() !== []) { |
|
36 | + if ($this->request->getQueryParams() !== []) |
|
37 | + { |
|
36 | 38 | $state->setVariable('query', $this->request->getQueryParams()); |
37 | 39 | } |
38 | 40 | |
39 | - if ($this->request->getParsedBody() !== null) { |
|
41 | + if ($this->request->getParsedBody() !== null) |
|
42 | + { |
|
40 | 43 | $state->setVariable('data', $this->request->getParsedBody()); |
41 | 44 | } |
42 | 45 | } |
@@ -15,14 +15,14 @@ |
||
15 | 15 | public function __construct( |
16 | 16 | private readonly ContainerInterface $container, |
17 | 17 | private readonly EnvironmentInterface $env |
18 | - ) { |
|
18 | + ){ |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | public function populate(StateInterface $state): void |
22 | 22 | { |
23 | 23 | $state->setTag('php', \phpversion()); |
24 | 24 | |
25 | - if ($this->container->has(DispatcherInterface::class)) { |
|
25 | + if ($this->container->has(DispatcherInterface::class)){ |
|
26 | 26 | $state->setTag('dispatcher', $this->container->get(DispatcherInterface::class)::class); |
27 | 27 | } |
28 | 28 |
@@ -22,7 +22,8 @@ |
||
22 | 22 | { |
23 | 23 | $state->setTag('php', \phpversion()); |
24 | 24 | |
25 | - if ($this->container->has(DispatcherInterface::class)) { |
|
25 | + if ($this->container->has(DispatcherInterface::class)) |
|
26 | + { |
|
26 | 27 | $state->setTag('dispatcher', $this->container->get(DispatcherInterface::class)::class); |
27 | 28 | } |
28 | 29 |
@@ -11,7 +11,7 @@ |
||
11 | 11 | { |
12 | 12 | public function __construct( |
13 | 13 | private FileSnapshot $fileSnapshot, |
14 | - ) { |
|
14 | + ){ |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | public function report(\Throwable $exception): void |
@@ -27,8 +27,10 @@ discard block |
||
27 | 27 | { |
28 | 28 | $grid = $this->table(['Name:', 'Verbs:', 'Pattern:', 'Target:', 'Group:']); |
29 | 29 | |
30 | - foreach ($router->getRoutes() as $name => $route) { |
|
31 | - if ($route instanceof Route) { |
|
30 | + foreach ($router->getRoutes() as $name => $route) |
|
31 | + { |
|
32 | + if ($route instanceof Route) |
|
33 | + { |
|
32 | 34 | $grid->addRow( |
33 | 35 | [ |
34 | 36 | $name, |
@@ -52,8 +54,10 @@ discard block |
||
52 | 54 | private function getRouteGroups(GroupRegistry $registry, string $routeName): array |
53 | 55 | { |
54 | 56 | $groups = []; |
55 | - foreach ($registry as $groupName => $group) { |
|
56 | - if ($group->hasRoute($routeName)) { |
|
57 | + foreach ($registry as $groupName => $group) |
|
58 | + { |
|
59 | + if ($group->hasRoute($routeName)) |
|
60 | + { |
|
57 | 61 | $groups[] = $groupName; |
58 | 62 | } |
59 | 63 | } |
@@ -63,12 +67,14 @@ discard block |
||
63 | 67 | |
64 | 68 | private function getVerbs(Route $route): string |
65 | 69 | { |
66 | - if ($route->getVerbs() === Route::VERBS) { |
|
70 | + if ($route->getVerbs() === Route::VERBS) |
|
71 | + { |
|
67 | 72 | return '*'; |
68 | 73 | } |
69 | 74 | |
70 | 75 | $result = []; |
71 | - foreach ($route->getVerbs() as $verb) { |
|
76 | + foreach ($route->getVerbs() as $verb) |
|
77 | + { |
|
72 | 78 | $result[] = match (\strtolower($verb)) { |
73 | 79 | 'get' => '<fg=green>GET</>', |
74 | 80 | 'post' => '<fg=blue>POST</>', |
@@ -103,7 +109,8 @@ discard block |
||
103 | 109 | private function getTarget(Route $route, KernelInterface $kernel): string |
104 | 110 | { |
105 | 111 | $target = $this->getValue($route, 'target'); |
106 | - switch (true) { |
|
112 | + switch (true) |
|
113 | + { |
|
107 | 114 | case $target instanceof \Closure: |
108 | 115 | $reflection = new \ReflectionFunction($target); |
109 | 116 | |
@@ -128,7 +135,8 @@ discard block |
||
128 | 135 | |
129 | 136 | case $target instanceof Group: |
130 | 137 | $result = []; |
131 | - foreach ($this->getValue($target, 'controllers') as $alias => $class) { |
|
138 | + foreach ($this->getValue($target, 'controllers') as $alias => $class) |
|
139 | + { |
|
132 | 140 | $result[] = \sprintf('%s => %s', $alias, $this->relativeClass($class, $kernel)); |
133 | 141 | } |
134 | 142 | |
@@ -147,10 +155,13 @@ discard block |
||
147 | 155 | |
148 | 156 | private function getValue(object $object, string $property): mixed |
149 | 157 | { |
150 | - try { |
|
158 | + try |
|
159 | + { |
|
151 | 160 | $r = new \ReflectionObject($object); |
152 | 161 | $prop = $r->getProperty($property); |
153 | - } catch (\Throwable $e) { |
|
162 | + } |
|
163 | + catch (\Throwable $e) |
|
164 | + { |
|
154 | 165 | return $e->getMessage(); |
155 | 166 | } |
156 | 167 | |
@@ -161,7 +172,8 @@ discard block |
||
161 | 172 | { |
162 | 173 | $r = new \ReflectionObject($kernel); |
163 | 174 | |
164 | - if (\str_starts_with($class, $r->getNamespaceName())) { |
|
175 | + if (\str_starts_with($class, $r->getNamespaceName())) |
|
176 | + { |
|
165 | 177 | return \substr($class, \strlen($r->getNamespaceName()) + 1); |
166 | 178 | } |
167 | 179 |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | { |
28 | 28 | $grid = $this->table(['Name:', 'Verbs:', 'Pattern:', 'Target:', 'Group:']); |
29 | 29 | |
30 | - foreach ($router->getRoutes() as $name => $route) { |
|
31 | - if ($route instanceof Route) { |
|
30 | + foreach ($router->getRoutes() as $name => $route){ |
|
31 | + if ($route instanceof Route){ |
|
32 | 32 | $grid->addRow( |
33 | 33 | [ |
34 | 34 | $name, |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | private function getRouteGroups(GroupRegistry $registry, string $routeName): array |
53 | 53 | { |
54 | 54 | $groups = []; |
55 | - foreach ($registry as $groupName => $group) { |
|
56 | - if ($group->hasRoute($routeName)) { |
|
55 | + foreach ($registry as $groupName => $group){ |
|
56 | + if ($group->hasRoute($routeName)){ |
|
57 | 57 | $groups[] = $groupName; |
58 | 58 | } |
59 | 59 | } |
@@ -63,12 +63,12 @@ discard block |
||
63 | 63 | |
64 | 64 | private function getVerbs(Route $route): string |
65 | 65 | { |
66 | - if ($route->getVerbs() === Route::VERBS) { |
|
66 | + if ($route->getVerbs() === Route::VERBS){ |
|
67 | 67 | return '*'; |
68 | 68 | } |
69 | 69 | |
70 | 70 | $result = []; |
71 | - foreach ($route->getVerbs() as $verb) { |
|
71 | + foreach ($route->getVerbs() as $verb){ |
|
72 | 72 | $result[] = match (\strtolower($verb)) { |
73 | 73 | 'get' => '<fg=green>GET</>', |
74 | 74 | 'post' => '<fg=blue>POST</>', |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $pattern = \preg_replace_callback( |
96 | 96 | '/<([^>]*)>/', |
97 | 97 | static fn ($m) => \sprintf('<fg=magenta>%s</>', $m[0]), |
98 | - !empty($prefix) ? $prefix . '/' . \trim($pattern, '/') : $pattern |
|
98 | + !empty($prefix) ? $prefix.'/'.\trim($pattern, '/') : $pattern |
|
99 | 99 | ); |
100 | 100 | |
101 | 101 | return $pattern; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | private function getTarget(Route $route, KernelInterface $kernel): string |
109 | 109 | { |
110 | 110 | $target = $this->getValue($route, 'target'); |
111 | - switch (true) { |
|
111 | + switch (true){ |
|
112 | 112 | case $target instanceof \Closure: |
113 | 113 | $reflection = new \ReflectionFunction($target); |
114 | 114 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | |
134 | 134 | case $target instanceof Group: |
135 | 135 | $result = []; |
136 | - foreach ($this->getValue($target, 'controllers') as $alias => $class) { |
|
136 | + foreach ($this->getValue($target, 'controllers') as $alias => $class){ |
|
137 | 137 | $result[] = \sprintf('%s => %s', $alias, $this->relativeClass($class, $kernel)); |
138 | 138 | } |
139 | 139 | |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | |
153 | 153 | private function getValue(object $object, string $property): mixed |
154 | 154 | { |
155 | - try { |
|
155 | + try{ |
|
156 | 156 | $r = new \ReflectionObject($object); |
157 | 157 | $prop = $r->getProperty($property); |
158 | - } catch (\Throwable $e) { |
|
158 | + }catch (\Throwable $e){ |
|
159 | 159 | return $e->getMessage(); |
160 | 160 | } |
161 | 161 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | { |
167 | 167 | $r = new \ReflectionObject($kernel); |
168 | 168 | |
169 | - if (\str_starts_with($class, $r->getNamespaceName())) { |
|
169 | + if (\str_starts_with($class, $r->getNamespaceName())){ |
|
170 | 170 | return \substr($class, \strlen($r->getNamespaceName()) + 1); |
171 | 171 | } |
172 | 172 |
@@ -37,10 +37,10 @@ discard block |
||
37 | 37 | FilesInterface $files, |
38 | 38 | DirectoriesInterface $directories |
39 | 39 | ): int { |
40 | - switch ($this->argument('type')) { |
|
40 | + switch ($this->argument('type')){ |
|
41 | 41 | case 'replace': |
42 | 42 | case 'follow': |
43 | - if ($this->isDirectory()) { |
|
43 | + if ($this->isDirectory()){ |
|
44 | 44 | $this->sprintf( |
45 | 45 | '<fg=cyan>•</fg=cyan> publish directory <comment>%s</comment> to <comment>%s</comment>', |
46 | 46 | $this->getSource($files), |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $this->getMergeMode(), |
54 | 54 | $this->getFileMode() |
55 | 55 | ); |
56 | - } else { |
|
56 | + }else{ |
|
57 | 57 | $this->sprintf( |
58 | 58 | '<fg=cyan>•</fg=cyan> publish file <comment>%s</comment> to <comment>%s</comment>', |
59 | 59 | $this->getSource($files), |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | private function getSource(FilesInterface $files): ?string |
92 | 92 | { |
93 | - if (!$this->isDirectory()) { |
|
93 | + if (!$this->isDirectory()){ |
|
94 | 94 | return $files->normalizePath($this->argument('source')); |
95 | 95 | } |
96 | 96 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | private function getTarget(FilesInterface $files, DirectoriesInterface $directories): ?string |
101 | 101 | { |
102 | 102 | $target = $this->argument('target'); |
103 | - foreach ($directories->getAll() as $alias => $value) { |
|
103 | + foreach ($directories->getAll() as $alias => $value){ |
|
104 | 104 | $target = \str_replace(\sprintf('@%s', $alias), $value, $target); |
105 | 105 | } |
106 | 106 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | { |
112 | 112 | return match (true) { |
113 | 113 | $this->argument('type') === 'ensure' => true, |
114 | - \str_contains((string) $this->argument('source'), '*') => true, |
|
114 | + \str_contains((string)$this->argument('source'), '*') => true, |
|
115 | 115 | default => \is_dir($this->argument('source')) |
116 | 116 | }; |
117 | 117 | } |
@@ -37,10 +37,12 @@ discard block |
||
37 | 37 | FilesInterface $files, |
38 | 38 | DirectoriesInterface $directories |
39 | 39 | ): int { |
40 | - switch ($this->argument('type')) { |
|
40 | + switch ($this->argument('type')) |
|
41 | + { |
|
41 | 42 | case 'replace': |
42 | 43 | case 'follow': |
43 | - if ($this->isDirectory()) { |
|
44 | + if ($this->isDirectory()) |
|
45 | + { |
|
44 | 46 | $this->sprintf( |
45 | 47 | '<fg=cyan>•</fg=cyan> publish directory <comment>%s</comment> to <comment>%s</comment>', |
46 | 48 | $this->getSource($files), |
@@ -53,7 +55,9 @@ discard block |
||
53 | 55 | $this->getMergeMode(), |
54 | 56 | $this->getFileMode() |
55 | 57 | ); |
56 | - } else { |
|
58 | + } |
|
59 | + else |
|
60 | + { |
|
57 | 61 | $this->sprintf( |
58 | 62 | '<fg=cyan>•</fg=cyan> publish file <comment>%s</comment> to <comment>%s</comment>', |
59 | 63 | $this->getSource($files), |
@@ -90,7 +94,8 @@ discard block |
||
90 | 94 | |
91 | 95 | private function getSource(FilesInterface $files): ?string |
92 | 96 | { |
93 | - if (!$this->isDirectory()) { |
|
97 | + if (!$this->isDirectory()) |
|
98 | + { |
|
94 | 99 | return $files->normalizePath($this->argument('source')); |
95 | 100 | } |
96 | 101 | |
@@ -100,7 +105,8 @@ discard block |
||
100 | 105 | private function getTarget(FilesInterface $files, DirectoriesInterface $directories): ?string |
101 | 106 | { |
102 | 107 | $target = $this->argument('target'); |
103 | - foreach ($directories->getAll() as $alias => $value) { |
|
108 | + foreach ($directories->getAll() as $alias => $value) |
|
109 | + { |
|
104 | 110 | $target = \str_replace(\sprintf('@%s', $alias), $value, $target); |
105 | 111 | } |
106 | 112 |
@@ -128,7 +128,7 @@ |
||
128 | 128 | private function getFileMode(): int |
129 | 129 | { |
130 | 130 | return match ($this->argument('mode')) { |
131 | - 'readonly' => FilesInterface::READONLY, |
|
131 | + 'readonly' => FilesInterface::readonly, |
|
132 | 132 | 'runtime' => FilesInterface::RUNTIME, |
133 | 133 | default => FilesInterface::RUNTIME, |
134 | 134 | }; |