@@ -18,22 +18,27 @@ discard block |
||
18 | 18 | |
19 | 19 | public function init(Container $container, AbstractKernel $kernel): void |
20 | 20 | { |
21 | - $kernel->booting(static function (AbstractKernel $kernel) use ($container) { |
|
21 | + $kernel->booting(static function (AbstractKernel $kernel) use ($container) |
|
22 | + { |
|
22 | 23 | $container->bind('hij', 'foo'); |
23 | 24 | |
24 | - $kernel->booting(static function () use ($container) { |
|
25 | + $kernel->booting(static function () use ($container) |
|
26 | + { |
|
25 | 27 | $container->bind('ijk', 'foo'); |
26 | 28 | }); |
27 | 29 | }); |
28 | 30 | |
29 | - $kernel->booted(function (AbstractKernel $kernel) use ($container) { |
|
31 | + $kernel->booted(function (AbstractKernel $kernel) use ($container) |
|
32 | + { |
|
30 | 33 | $container->bind('jkl', 'foo'); |
31 | 34 | |
32 | - $kernel->booting(function () use ($container) { |
|
35 | + $kernel->booting(function () use ($container) |
|
36 | + { |
|
33 | 37 | $container->bind('klm', 'foo'); |
34 | 38 | }); |
35 | 39 | |
36 | - $kernel->booted(function () use ($container) { |
|
40 | + $kernel->booted(function () use ($container) |
|
41 | + { |
|
37 | 42 | $container->bind('lmn', 'foo'); |
38 | 43 | }); |
39 | 44 | }); |
@@ -44,11 +49,13 @@ discard block |
||
44 | 49 | public function boot(ConfigurationBootloader $configuration, AbstractKernel $kernel, Container $container): void |
45 | 50 | { |
46 | 51 | // won't be executed |
47 | - $kernel->booting(function (AbstractKernel $kernel) use ($container) { |
|
52 | + $kernel->booting(function (AbstractKernel $kernel) use ($container) |
|
53 | + { |
|
48 | 54 | $container->bind('ghi', 'foo'); |
49 | 55 | }); |
50 | 56 | |
51 | - $kernel->booted(function (AbstractKernel $kernel) use ($container) { |
|
57 | + $kernel->booted(function (AbstractKernel $kernel) use ($container) |
|
58 | + { |
|
52 | 59 | $container->bind('mno', 'foo'); |
53 | 60 | }); |
54 | 61 |
@@ -22,7 +22,7 @@ |
||
22 | 22 | */ |
23 | 23 | public function register(string $class): void |
24 | 24 | { |
25 | - if ($this->isBooted($class)) { |
|
25 | + if ($this->isBooted($class)){ |
|
26 | 26 | throw new BootloaderAlreadyBootedException($class); |
27 | 27 | } |
28 | 28 |
@@ -22,7 +22,8 @@ |
||
22 | 22 | */ |
23 | 23 | public function register(string $class): void |
24 | 24 | { |
25 | - if ($this->isBooted($class)) { |
|
25 | + if ($this->isBooted($class)) |
|
26 | + { |
|
26 | 27 | throw new BootloaderAlreadyBootedException($class); |
27 | 28 | } |
28 | 29 |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | use Spiral\Core\ContainerScope; |
10 | 10 | use Spiral\Core\Exception\ScopeException; |
11 | 11 | |
12 | -if (!function_exists('spiral')) { |
|
12 | +if (!function_exists('spiral')){ |
|
13 | 13 | /** |
14 | 14 | * Resolve given alias in current IoC scope. |
15 | 15 | * |
@@ -22,19 +22,19 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function spiral(string $alias): mixed |
24 | 24 | { |
25 | - if (ContainerScope::getContainer() === null) { |
|
25 | + if (ContainerScope::getContainer() === null){ |
|
26 | 26 | throw new ScopeException('Container scope was not set.'); |
27 | 27 | } |
28 | 28 | |
29 | - try { |
|
29 | + try{ |
|
30 | 30 | return ContainerScope::getContainer()->get($alias); |
31 | - } catch (ContainerExceptionInterface $e) { |
|
31 | + }catch (ContainerExceptionInterface $e){ |
|
32 | 32 | throw new ScopeException($e->getMessage(), $e->getCode(), $e); |
33 | 33 | } |
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
37 | -if (!function_exists('directory')) { |
|
37 | +if (!function_exists('directory')){ |
|
38 | 38 | /** |
39 | 39 | * Get directory alias value. Uses application core from the current global scope. |
40 | 40 | * |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | -if (!function_exists('env')) { |
|
53 | +if (!function_exists('env')){ |
|
54 | 54 | /** |
55 | 55 | * Gets the value of an environment variable. Uses application core from the current global scope. |
56 | 56 | * |
@@ -9,7 +9,8 @@ discard block |
||
9 | 9 | use Spiral\Core\ContainerScope; |
10 | 10 | use Spiral\Core\Exception\ScopeException; |
11 | 11 | |
12 | -if (!function_exists('spiral')) { |
|
12 | +if (!function_exists('spiral')) |
|
13 | +{ |
|
13 | 14 | /** |
14 | 15 | * Resolve given alias in current IoC scope. |
15 | 16 | * |
@@ -22,19 +23,24 @@ discard block |
||
22 | 23 | */ |
23 | 24 | function spiral(string $alias): mixed |
24 | 25 | { |
25 | - if (ContainerScope::getContainer() === null) { |
|
26 | + if (ContainerScope::getContainer() === null) |
|
27 | + { |
|
26 | 28 | throw new ScopeException('Container scope was not set.'); |
27 | 29 | } |
28 | 30 | |
29 | - try { |
|
31 | + try |
|
32 | + { |
|
30 | 33 | return ContainerScope::getContainer()->get($alias); |
31 | - } catch (ContainerExceptionInterface $e) { |
|
34 | + } |
|
35 | + catch (ContainerExceptionInterface $e) |
|
36 | + { |
|
32 | 37 | throw new ScopeException($e->getMessage(), $e->getCode(), $e); |
33 | 38 | } |
34 | 39 | } |
35 | 40 | } |
36 | 41 | |
37 | -if (!function_exists('directory')) { |
|
42 | +if (!function_exists('directory')) |
|
43 | +{ |
|
38 | 44 | /** |
39 | 45 | * Get directory alias value. Uses application core from the current global scope. |
40 | 46 | * |
@@ -50,7 +56,8 @@ discard block |
||
50 | 56 | } |
51 | 57 | } |
52 | 58 | |
53 | -if (!function_exists('env')) { |
|
59 | +if (!function_exists('env')) |
|
60 | +{ |
|
54 | 61 | /** |
55 | 62 | * Gets the value of an environment variable. Uses application core from the current global scope. |
56 | 63 | * |
@@ -31,7 +31,8 @@ discard block |
||
31 | 31 | |
32 | 32 | public function getID(): string |
33 | 33 | { |
34 | - if (empty($this->id)) { |
|
34 | + if (empty($this->id)) |
|
35 | + { |
|
35 | 36 | $this->id = \md5(\serialize($this->values)); |
36 | 37 | } |
37 | 38 | |
@@ -40,7 +41,8 @@ discard block |
||
40 | 41 | |
41 | 42 | public function set(string $name, mixed $value): self |
42 | 43 | { |
43 | - if (\array_key_exists($name, $this->values) && !$this->overwrite) { |
|
44 | + if (\array_key_exists($name, $this->values) && !$this->overwrite) |
|
45 | + { |
|
44 | 46 | return $this; |
45 | 47 | } |
46 | 48 | |
@@ -54,7 +56,8 @@ discard block |
||
54 | 56 | |
55 | 57 | public function get(string $name, mixed $default = null): mixed |
56 | 58 | { |
57 | - if (isset($this->values[$name])) { |
|
59 | + if (isset($this->values[$name])) |
|
60 | + { |
|
58 | 61 | return $this->normalize($this->values[$name]); |
59 | 62 | } |
60 | 63 | |
@@ -68,7 +71,8 @@ discard block |
||
68 | 71 | { |
69 | 72 | $result = []; |
70 | 73 | |
71 | - foreach ($this->values as $key => $value) { |
|
74 | + foreach ($this->values as $key => $value) |
|
75 | + { |
|
72 | 76 | $result[$key] = $this->normalize($value); |
73 | 77 | } |
74 | 78 | |
@@ -77,12 +81,14 @@ discard block |
||
77 | 81 | |
78 | 82 | protected function normalize(mixed $value): mixed |
79 | 83 | { |
80 | - if (!\is_string($value)) { |
|
84 | + if (!\is_string($value)) |
|
85 | + { |
|
81 | 86 | return $value; |
82 | 87 | } |
83 | 88 | |
84 | 89 | $alias = \strtolower($value); |
85 | - if (isset(self::VALUE_MAP[$alias])) { |
|
90 | + if (isset(self::VALUE_MAP[$alias])) |
|
91 | + { |
|
86 | 92 | return self::VALUE_MAP[$alias]; |
87 | 93 | } |
88 | 94 |
@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | public function __construct( |
26 | 26 | array $values = [], |
27 | 27 | private readonly bool $overwrite = false, |
28 | - ) { |
|
28 | + ){ |
|
29 | 29 | $this->values = $values + $_ENV + $_SERVER; |
30 | 30 | } |
31 | 31 | |
32 | 32 | public function getID(): string |
33 | 33 | { |
34 | - if (empty($this->id)) { |
|
34 | + if (empty($this->id)){ |
|
35 | 35 | $this->id = \md5(\serialize($this->values)); |
36 | 36 | } |
37 | 37 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | public function set(string $name, mixed $value): self |
42 | 42 | { |
43 | - if (\array_key_exists($name, $this->values) && !$this->overwrite) { |
|
43 | + if (\array_key_exists($name, $this->values) && !$this->overwrite){ |
|
44 | 44 | return $this; |
45 | 45 | } |
46 | 46 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | public function get(string $name, mixed $default = null): mixed |
56 | 56 | { |
57 | - if (isset($this->values[$name])) { |
|
57 | + if (isset($this->values[$name])){ |
|
58 | 58 | return $this->normalize($this->values[$name]); |
59 | 59 | } |
60 | 60 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | { |
69 | 69 | $result = []; |
70 | 70 | |
71 | - foreach ($this->values as $key => $value) { |
|
71 | + foreach ($this->values as $key => $value){ |
|
72 | 72 | $result[$key] = $this->normalize($value); |
73 | 73 | } |
74 | 74 | |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | |
78 | 78 | protected function normalize(mixed $value): mixed |
79 | 79 | { |
80 | - if (!\is_string($value)) { |
|
80 | + if (!\is_string($value)){ |
|
81 | 81 | return $value; |
82 | 82 | } |
83 | 83 | |
84 | 84 | $alias = \strtolower($value); |
85 | - if (isset(self::VALUE_MAP[$alias])) { |
|
85 | + if (isset(self::VALUE_MAP[$alias])){ |
|
86 | 86 | return self::VALUE_MAP[$alias]; |
87 | 87 | } |
88 | 88 |
@@ -26,7 +26,7 @@ |
||
26 | 26 | { |
27 | 27 | $this->dispatcher?->dispatch(new Finalizing($this)); |
28 | 28 | |
29 | - foreach ($this->finalizers as $finalizer) { |
|
29 | + foreach ($this->finalizers as $finalizer){ |
|
30 | 30 | \call_user_func($finalizer, $terminate); |
31 | 31 | } |
32 | 32 | } |
@@ -26,7 +26,8 @@ |
||
26 | 26 | { |
27 | 27 | $this->dispatcher?->dispatch(new Finalizing($this)); |
28 | 28 | |
29 | - foreach ($this->finalizers as $finalizer) { |
|
29 | + foreach ($this->finalizers as $finalizer) |
|
30 | + { |
|
30 | 31 | \call_user_func($finalizer, $terminate); |
31 | 32 | } |
32 | 33 | } |
@@ -43,14 +43,14 @@ |
||
43 | 43 | ? $class::DESCRIPTION |
44 | 44 | : '', |
45 | 45 | false, |
46 | - function () use ($class): SymfonyCommand { |
|
46 | + function () use ($class) : SymfonyCommand { |
|
47 | 47 | /** @var SpiralCommand $command */ |
48 | 48 | $command = $this->container->get($class); |
49 | 49 | |
50 | 50 | $command->setContainer($this->container); |
51 | 51 | $command->setInterceptors($this->interceptors); |
52 | 52 | |
53 | - if ($this->dispatcher !== null && $command instanceof EventDispatcherAwareInterface) { |
|
53 | + if ($this->dispatcher !== null && $command instanceof EventDispatcherAwareInterface){ |
|
54 | 54 | $command->setEventDispatcher($this->dispatcher); |
55 | 55 | } |
56 | 56 |
@@ -50,7 +50,8 @@ |
||
50 | 50 | $command->setContainer($this->container); |
51 | 51 | $command->setInterceptors($this->interceptors); |
52 | 52 | |
53 | - if ($this->dispatcher !== null && $command instanceof EventDispatcherAwareInterface) { |
|
53 | + if ($this->dispatcher !== null && $command instanceof EventDispatcherAwareInterface) |
|
54 | + { |
|
54 | 55 | $command->setEventDispatcher($this->dispatcher); |
55 | 56 | } |
56 | 57 |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | protected function warning(string $string): void |
136 | 136 | { |
137 | - if (!$this->output->getFormatter()->hasStyle('warning')) { |
|
137 | + if (!$this->output->getFormatter()->hasStyle('warning')){ |
|
138 | 138 | $style = new OutputFormatterStyle('yellow'); |
139 | 139 | $this->output->getFormatter()->setStyle('warning', $style); |
140 | 140 | } |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | $stringLines = explode("\n", wordwrap($string, 300)); |
152 | 152 | |
153 | 153 | $this->comment(\str_repeat('*', $length)); |
154 | - foreach ($stringLines as $line) { |
|
155 | - $this->comment('* ' . $line . ' *'); |
|
154 | + foreach ($stringLines as $line){ |
|
155 | + $this->comment('* '.$line.' *'); |
|
156 | 156 | } |
157 | 157 | $this->comment(\str_repeat('*', $length)); |
158 | 158 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * |
199 | 199 | * @throws \InvalidArgumentException When unknown output type is given |
200 | 200 | */ |
201 | - protected function write(string|iterable $messages, bool $newline = false): void |
|
201 | + protected function write(string | iterable $messages, bool $newline = false): void |
|
202 | 202 | { |
203 | 203 | $this->output->write(messages: $messages, newline: $newline); |
204 | 204 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * |
211 | 211 | * @throws \InvalidArgumentException When unknown output type is given |
212 | 212 | */ |
213 | - protected function writeln(string|iterable $messages): void |
|
213 | + protected function writeln(string | iterable $messages): void |
|
214 | 214 | { |
215 | 215 | $this->output->writeln(messages: $messages); |
216 | 216 | } |
@@ -134,7 +134,8 @@ discard block |
||
134 | 134 | */ |
135 | 135 | protected function warning(string $string): void |
136 | 136 | { |
137 | - if (!$this->output->getFormatter()->hasStyle('warning')) { |
|
137 | + if (!$this->output->getFormatter()->hasStyle('warning')) |
|
138 | + { |
|
138 | 139 | $style = new OutputFormatterStyle('yellow'); |
139 | 140 | $this->output->getFormatter()->setStyle('warning', $style); |
140 | 141 | } |
@@ -151,7 +152,8 @@ discard block |
||
151 | 152 | $stringLines = explode("\n", wordwrap($string, 300)); |
152 | 153 | |
153 | 154 | $this->comment(\str_repeat('*', $length)); |
154 | - foreach ($stringLines as $line) { |
|
155 | + foreach ($stringLines as $line) |
|
156 | + { |
|
155 | 157 | $this->comment('* ' . $line . ' *'); |
156 | 158 | } |
157 | 159 | $this->comment(\str_repeat('*', $length)); |
@@ -33,8 +33,10 @@ |
||
33 | 33 | public function locateCommands(): array |
34 | 34 | { |
35 | 35 | $commands = []; |
36 | - foreach ($this->commands as $command) { |
|
37 | - if ($command instanceof SymfonyCommand) { |
|
36 | + foreach ($this->commands as $command) |
|
37 | + { |
|
38 | + if ($command instanceof SymfonyCommand) |
|
39 | + { |
|
38 | 40 | $commands[] = $command; |
39 | 41 | continue; |
40 | 42 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | private readonly array $commands, |
24 | 24 | array $interceptors = [], |
25 | 25 | ContainerInterface $container = new Container(), |
26 | - ) { |
|
26 | + ){ |
|
27 | 27 | $this->interceptors = $interceptors; |
28 | 28 | $this->container = $container; |
29 | 29 | } |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | public function locateCommands(): array |
35 | 35 | { |
36 | 36 | $commands = []; |
37 | - foreach ($this->commands as $command) { |
|
38 | - if ($command instanceof SymfonyCommand) { |
|
37 | + foreach ($this->commands as $command){ |
|
38 | + if ($command instanceof SymfonyCommand){ |
|
39 | 39 | $commands[] = $command; |
40 | 40 | continue; |
41 | 41 | } |
@@ -31,18 +31,21 @@ |
||
31 | 31 | public function execute(ContainerInterface $container, OutputInterface $output): void |
32 | 32 | { |
33 | 33 | $function = $this->function; |
34 | - if (\is_string($function) && \str_contains($function, ':')) { |
|
34 | + if (\is_string($function) && \str_contains($function, ':')) |
|
35 | + { |
|
35 | 36 | $function = \explode(':', \str_replace('::', ':', $function)); |
36 | 37 | } |
37 | 38 | |
38 | - if (\is_array($function) && isset($function[0]) && !\is_object($function[0])) { |
|
39 | + if (\is_array($function) && isset($function[0]) && !\is_object($function[0])) |
|
40 | + { |
|
39 | 41 | $function[0] = $container->get($function[0]); |
40 | 42 | } |
41 | 43 | |
42 | 44 | /** @var ResolverInterface $resolver */ |
43 | 45 | $resolver = $container->get(ResolverInterface::class); |
44 | 46 | |
45 | - if (\is_array($function)) { |
|
47 | + if (\is_array($function)) |
|
48 | + { |
|
46 | 49 | $reflection = new \ReflectionMethod($function[0], $function[1]); |
47 | 50 | $reflection->invokeArgs($function[0], $resolver->resolveArguments($reflection, [ |
48 | 51 | 'output' => $output, |
@@ -20,10 +20,10 @@ discard block |
||
20 | 20 | * @param string|callable|array<class-string, string> $function |
21 | 21 | */ |
22 | 22 | public function __construct( |
23 | - string|array|callable $function, |
|
23 | + string | array | callable $function, |
|
24 | 24 | string $header = '', |
25 | 25 | string $footer = '', |
26 | - ) { |
|
26 | + ){ |
|
27 | 27 | $this->function = $function; |
28 | 28 | parent::__construct($header, $footer); |
29 | 29 | } |
@@ -31,18 +31,18 @@ discard block |
||
31 | 31 | public function execute(ContainerInterface $container, OutputInterface $output): void |
32 | 32 | { |
33 | 33 | $function = $this->function; |
34 | - if (\is_string($function) && \str_contains($function, ':')) { |
|
34 | + if (\is_string($function) && \str_contains($function, ':')){ |
|
35 | 35 | $function = \explode(':', \str_replace('::', ':', $function)); |
36 | 36 | } |
37 | 37 | |
38 | - if (\is_array($function) && isset($function[0]) && !\is_object($function[0])) { |
|
38 | + if (\is_array($function) && isset($function[0]) && !\is_object($function[0])){ |
|
39 | 39 | $function[0] = $container->get($function[0]); |
40 | 40 | } |
41 | 41 | |
42 | 42 | /** @var ResolverInterface $resolver */ |
43 | 43 | $resolver = $container->get(ResolverInterface::class); |
44 | 44 | |
45 | - if (\is_array($function)) { |
|
45 | + if (\is_array($function)){ |
|
46 | 46 | $reflection = new \ReflectionMethod($function[0], $function[1]); |
47 | 47 | $reflection->invokeArgs($function[0], $resolver->resolveArguments($reflection, [ |
48 | 48 | 'output' => $output, |