@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | private readonly array $commands, |
| 23 | 23 | array $interceptors = [], |
| 24 | 24 | ContainerInterface $container = new Container() |
| 25 | - ) { |
|
| 25 | + ){ |
|
| 26 | 26 | $this->interceptors = $interceptors; |
| 27 | 27 | $this->container = $container; |
| 28 | 28 | } |
@@ -33,8 +33,8 @@ discard block |
||
| 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 | + if ($command instanceof SymfonyCommand){ |
|
| 38 | 38 | $commands[] = $command; |
| 39 | 39 | continue; |
| 40 | 40 | } |
@@ -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 | } |
@@ -12,19 +12,19 @@ |
||
| 12 | 12 | public function __construct( |
| 13 | 13 | private readonly string $header, |
| 14 | 14 | private readonly string $footer |
| 15 | - ) { |
|
| 15 | + ){ |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | public function writeHeader(OutputInterface $output): void |
| 19 | 19 | { |
| 20 | - if (!empty($this->header)) { |
|
| 20 | + if (!empty($this->header)){ |
|
| 21 | 21 | $output->writeln($this->header); |
| 22 | 22 | } |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function writeFooter(OutputInterface $output): void |
| 26 | 26 | { |
| 27 | - if (!empty($this->footer)) { |
|
| 27 | + if (!empty($this->footer)){ |
|
| 28 | 28 | $output->writeln($this->footer); |
| 29 | 29 | } |
| 30 | 30 | } |
@@ -17,14 +17,16 @@ |
||
| 17 | 17 | |
| 18 | 18 | public function writeHeader(OutputInterface $output): void |
| 19 | 19 | { |
| 20 | - if (!empty($this->header)) { |
|
| 20 | + if (!empty($this->header)) |
|
| 21 | + { |
|
| 21 | 22 | $output->writeln($this->header); |
| 22 | 23 | } |
| 23 | 24 | } |
| 24 | 25 | |
| 25 | 26 | public function writeFooter(OutputInterface $output): void |
| 26 | 27 | { |
| 27 | - if (!empty($this->footer)) { |
|
| 28 | + if (!empty($this->footer)) |
|
| 29 | + { |
|
| 28 | 30 | $output->writeln($this->footer); |
| 29 | 31 | } |
| 30 | 32 | } |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | private readonly array $options = [], |
| 19 | 19 | string $header = '', |
| 20 | 20 | string $footer = '' |
| 21 | - ) { |
|
| 21 | + ){ |
|
| 22 | 22 | parent::__construct($header, $footer); |
| 23 | 23 | } |
| 24 | 24 | |
@@ -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, |
@@ -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, |
@@ -23,17 +23,17 @@ |
||
| 23 | 23 | protected function runSequence(iterable $commands, ContainerInterface $container): int |
| 24 | 24 | { |
| 25 | 25 | $errors = 0; |
| 26 | - foreach ($commands as $sequence) { |
|
| 26 | + foreach ($commands as $sequence){ |
|
| 27 | 27 | $sequence->writeHeader($this->output); |
| 28 | 28 | |
| 29 | - try { |
|
| 29 | + try{ |
|
| 30 | 30 | $sequence->execute($container, $this->output); |
| 31 | 31 | $sequence->writeFooter($this->output); |
| 32 | - } catch (Throwable $e) { |
|
| 32 | + }catch (Throwable $e){ |
|
| 33 | 33 | $errors++; |
| 34 | 34 | $this->error((string)$e); |
| 35 | 35 | |
| 36 | - if (!$this->option('ignore') && $this->option('break')) { |
|
| 36 | + if (!$this->option('ignore') && $this->option('break')){ |
|
| 37 | 37 | $this->error('Aborting.'); |
| 38 | 38 | |
| 39 | 39 | return self::FAILURE; |
@@ -23,17 +23,22 @@ |
||
| 23 | 23 | protected function runSequence(iterable $commands, ContainerInterface $container): int |
| 24 | 24 | { |
| 25 | 25 | $errors = 0; |
| 26 | - foreach ($commands as $sequence) { |
|
| 26 | + foreach ($commands as $sequence) |
|
| 27 | + { |
|
| 27 | 28 | $sequence->writeHeader($this->output); |
| 28 | 29 | |
| 29 | - try { |
|
| 30 | + try |
|
| 31 | + { |
|
| 30 | 32 | $sequence->execute($container, $this->output); |
| 31 | 33 | $sequence->writeFooter($this->output); |
| 32 | - } catch (Throwable $e) { |
|
| 34 | + } |
|
| 35 | + catch (Throwable $e) |
|
| 36 | + { |
|
| 33 | 37 | $errors++; |
| 34 | 38 | $this->error((string)$e); |
| 35 | 39 | |
| 36 | - if (!$this->option('ignore') && $this->option('break')) { |
|
| 40 | + if (!$this->option('ignore') && $this->option('break')) |
|
| 41 | + { |
|
| 37 | 42 | $this->error('Aborting.'); |
| 38 | 43 | |
| 39 | 44 | return self::FAILURE; |
@@ -119,7 +119,8 @@ |
||
| 119 | 119 | string $footer = '', |
| 120 | 120 | array $options = [] |
| 121 | 121 | ): void { |
| 122 | - if (!isset($this->config->getConfig(ConsoleConfig::CONFIG)['sequences'][$name])) { |
|
| 122 | + if (!isset($this->config->getConfig(ConsoleConfig::CONFIG)['sequences'][$name])) |
|
| 123 | + { |
|
| 123 | 124 | $this->config->modify( |
| 124 | 125 | ConsoleConfig::CONFIG, |
| 125 | 126 | new Append('sequences', $name, []) |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | public function __construct( |
| 43 | 43 | private readonly ConfiguratorInterface $config |
| 44 | - ) { |
|
| 44 | + ){ |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | public function init(AbstractKernel $kernel, BinderInterface $binder): void |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | public function addConfigureSequence( |
| 103 | - string|array|\Closure $sequence, |
|
| 103 | + string | array | \Closure $sequence, |
|
| 104 | 104 | string $header, |
| 105 | 105 | string $footer = '', |
| 106 | 106 | array $options = [] |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | public function addUpdateSequence( |
| 112 | - string|array|\Closure $sequence, |
|
| 112 | + string | array | \Closure $sequence, |
|
| 113 | 113 | string $header, |
| 114 | 114 | string $footer = '', |
| 115 | 115 | array $options = [] |
@@ -119,12 +119,12 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | public function addSequence( |
| 121 | 121 | string $name, |
| 122 | - string|array|\Closure $sequence, |
|
| 122 | + string | array | \Closure $sequence, |
|
| 123 | 123 | string $header, |
| 124 | 124 | string $footer = '', |
| 125 | 125 | array $options = [] |
| 126 | 126 | ): void { |
| 127 | - if (!isset($this->config->getConfig(ConsoleConfig::CONFIG)['sequences'][$name])) { |
|
| 127 | + if (!isset($this->config->getConfig(ConsoleConfig::CONFIG)['sequences'][$name])){ |
|
| 128 | 128 | $this->config->modify( |
| 129 | 129 | ConsoleConfig::CONFIG, |
| 130 | 130 | new Append('sequences', $name, []) |
@@ -133,13 +133,13 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | $this->config->modify( |
| 135 | 135 | ConsoleConfig::CONFIG, |
| 136 | - $this->sequence('sequences.' . $name, $sequence, $header, $footer, $options) |
|
| 136 | + $this->sequence('sequences.'.$name, $sequence, $header, $footer, $options) |
|
| 137 | 137 | ); |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | private function sequence( |
| 141 | 141 | string $target, |
| 142 | - string|array|callable $sequence, |
|
| 142 | + string | array | callable $sequence, |
|
| 143 | 143 | string $header, |
| 144 | 144 | string $footer, |
| 145 | 145 | array $options |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | return match (true) { |
| 25 | 25 | $string === $pattern => true, |
| 26 | 26 | !$this->isPattern($pattern) => false, |
| 27 | - default => (bool) \preg_match($this->getRegex($pattern), $string) |
|
| 27 | + default => (bool)\preg_match($this->getRegex($pattern), $string) |
|
| 28 | 28 | }; |
| 29 | 29 | } |
| 30 | 30 | |
@@ -8,6 +8,6 @@ |
||
| 8 | 8 | { |
| 9 | 9 | public function __construct( |
| 10 | 10 | public readonly string $locale, |
| 11 | - ) { |
|
| 11 | + ){ |
|
| 12 | 12 | } |
| 13 | 13 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | use Spiral\Translator\Exception\TranslatorException; |
| 8 | 8 | use Spiral\Translator\TranslatorInterface; |
| 9 | 9 | |
| 10 | -if (!\function_exists('l')) { |
|
| 10 | +if (!\function_exists('l')){ |
|
| 11 | 11 | /** |
| 12 | 12 | * Translate message using default or specific bundle name. |
| 13 | 13 | * |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | /** @psalm-suppress InternalMethod */ |
| 24 | 24 | $container = ContainerScope::getContainer(); |
| 25 | - if ($container === null || !$container->has(TranslatorInterface::class)) { |
|
| 25 | + if ($container === null || !$container->has(TranslatorInterface::class)){ |
|
| 26 | 26 | throw new ScopeException( |
| 27 | 27 | '`TranslatorInterface` binding is missing or container scope is not set' |
| 28 | 28 | ); |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | -if (!\function_exists('p')) { |
|
| 38 | +if (!\function_exists('p')){ |
|
| 39 | 39 | /** |
| 40 | 40 | * Pluralize string using language pluralization options and specified numeric value. |
| 41 | 41 | * |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | { |
| 52 | 52 | /** @psalm-suppress InternalMethod */ |
| 53 | 53 | $container = ContainerScope::getContainer(); |
| 54 | - if (empty($container) || !$container->has(TranslatorInterface::class)) { |
|
| 54 | + if (empty($container) || !$container->has(TranslatorInterface::class)){ |
|
| 55 | 55 | throw new ScopeException( |
| 56 | 56 | '`TranslatorInterface` binding is missing or container scope is not set' |
| 57 | 57 | ); |
@@ -7,7 +7,8 @@ discard block |
||
| 7 | 7 | use Spiral\Translator\Exception\TranslatorException; |
| 8 | 8 | use Spiral\Translator\TranslatorInterface; |
| 9 | 9 | |
| 10 | -if (!\function_exists('l')) { |
|
| 10 | +if (!\function_exists('l')) |
|
| 11 | +{ |
|
| 11 | 12 | /** |
| 12 | 13 | * Translate message using default or specific bundle name. |
| 13 | 14 | * |
@@ -22,7 +23,8 @@ discard block |
||
| 22 | 23 | { |
| 23 | 24 | /** @psalm-suppress InternalMethod */ |
| 24 | 25 | $container = ContainerScope::getContainer(); |
| 25 | - if ($container === null || !$container->has(TranslatorInterface::class)) { |
|
| 26 | + if ($container === null || !$container->has(TranslatorInterface::class)) |
|
| 27 | + { |
|
| 26 | 28 | throw new ScopeException( |
| 27 | 29 | '`TranslatorInterface` binding is missing or container scope is not set' |
| 28 | 30 | ); |
@@ -35,7 +37,8 @@ discard block |
||
| 35 | 37 | } |
| 36 | 38 | } |
| 37 | 39 | |
| 38 | -if (!\function_exists('p')) { |
|
| 40 | +if (!\function_exists('p')) |
|
| 41 | +{ |
|
| 39 | 42 | /** |
| 40 | 43 | * Pluralize string using language pluralization options and specified numeric value. |
| 41 | 44 | * |
@@ -51,7 +54,8 @@ discard block |
||
| 51 | 54 | { |
| 52 | 55 | /** @psalm-suppress InternalMethod */ |
| 53 | 56 | $container = ContainerScope::getContainer(); |
| 54 | - if (empty($container) || !$container->has(TranslatorInterface::class)) { |
|
| 57 | + if (empty($container) || !$container->has(TranslatorInterface::class)) |
|
| 58 | + { |
|
| 55 | 59 | throw new ScopeException( |
| 56 | 60 | '`TranslatorInterface` binding is missing or container scope is not set' |
| 57 | 61 | ); |