@@ -16,6 +16,6 @@ |
||
| 16 | 16 | public readonly array $arguments = [], |
| 17 | 17 | /** @var InputOption[] */ |
| 18 | 18 | public readonly array $options = [], |
| 19 | - ) { |
|
| 19 | + ){ |
|
| 20 | 20 | } |
| 21 | 21 | } |
@@ -23,8 +23,8 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | $name = $this->parseName($signature); |
| 25 | 25 | |
| 26 | - if (\preg_match_all('/\{\s*(.*?)\s*\}/', $signature, $matches)) { |
|
| 27 | - if (\count($matches[1])) { |
|
| 26 | + if (\preg_match_all('/\{\s*(.*?)\s*\}/', $signature, $matches)){ |
|
| 27 | + if (\count($matches[1])){ |
|
| 28 | 28 | return new Result($name, ...$this->parseParameters($matches[1])); |
| 29 | 29 | } |
| 30 | 30 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | private function parseName(string $signature): string |
| 41 | 41 | { |
| 42 | - if (!\preg_match('/\S+/', $signature, $matches)) { |
|
| 42 | + if (!\preg_match('/\S+/', $signature, $matches)){ |
|
| 43 | 43 | throw new InvalidArgumentException('Unable to determine command name from signature.'); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -56,10 +56,10 @@ discard block |
||
| 56 | 56 | $arguments = []; |
| 57 | 57 | $options = []; |
| 58 | 58 | |
| 59 | - foreach ($tokens as $token) { |
|
| 60 | - if (\preg_match('/-{2,}(.*)/', $token, $matches)) { |
|
| 59 | + foreach ($tokens as $token){ |
|
| 60 | + if (\preg_match('/-{2,}(.*)/', $token, $matches)){ |
|
| 61 | 61 | $options[] = $this->parseOption($matches[1]); |
| 62 | - } else { |
|
| 62 | + }else{ |
|
| 63 | 63 | $arguments[] = $this->parseArgument($token); |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | $matches = \preg_split('/\s*\|\s*/', $token, 2); |
| 123 | 123 | $shortcut = null; |
| 124 | 124 | |
| 125 | - if (isset($matches[1])) { |
|
| 125 | + if (isset($matches[1])){ |
|
| 126 | 126 | [$shortcut, $token] = $matches; |
| 127 | 127 | } |
| 128 | 128 | |
@@ -23,8 +23,10 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | $name = $this->parseName($signature); |
| 25 | 25 | |
| 26 | - if (\preg_match_all('/\{\s*(.*?)\s*\}/', $signature, $matches)) { |
|
| 27 | - if (\count($matches[1])) { |
|
| 26 | + if (\preg_match_all('/\{\s*(.*?)\s*\}/', $signature, $matches)) |
|
| 27 | + { |
|
| 28 | + if (\count($matches[1])) |
|
| 29 | + { |
|
| 28 | 30 | return new Result($name, ...$this->parseParameters($matches[1])); |
| 29 | 31 | } |
| 30 | 32 | } |
@@ -39,7 +41,8 @@ discard block |
||
| 39 | 41 | */ |
| 40 | 42 | private function parseName(string $signature): string |
| 41 | 43 | { |
| 42 | - if (!\preg_match('/\S+/', $signature, $matches)) { |
|
| 44 | + if (!\preg_match('/\S+/', $signature, $matches)) |
|
| 45 | + { |
|
| 43 | 46 | throw new InvalidArgumentException('Unable to determine command name from signature.'); |
| 44 | 47 | } |
| 45 | 48 | |
@@ -56,10 +59,14 @@ discard block |
||
| 56 | 59 | $arguments = []; |
| 57 | 60 | $options = []; |
| 58 | 61 | |
| 59 | - foreach ($tokens as $token) { |
|
| 60 | - if (\preg_match('/-{2,}(.*)/', $token, $matches)) { |
|
| 62 | + foreach ($tokens as $token) |
|
| 63 | + { |
|
| 64 | + if (\preg_match('/-{2,}(.*)/', $token, $matches)) |
|
| 65 | + { |
|
| 61 | 66 | $options[] = $this->parseOption($matches[1]); |
| 62 | - } else { |
|
| 67 | + } |
|
| 68 | + else |
|
| 69 | + { |
|
| 63 | 70 | $arguments[] = $this->parseArgument($token); |
| 64 | 71 | } |
| 65 | 72 | } |
@@ -122,7 +129,8 @@ discard block |
||
| 122 | 129 | $matches = \preg_split('/\s*\|\s*/', $token, 2); |
| 123 | 130 | $shortcut = null; |
| 124 | 131 | |
| 125 | - if (isset($matches[1])) { |
|
| 132 | + if (isset($matches[1])) |
|
| 133 | + { |
|
| 126 | 134 | [$shortcut, $token] = $matches; |
| 127 | 135 | } |
| 128 | 136 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | public function __construct( |
| 16 | 16 | private readonly InputInterface $input, |
| 17 | 17 | private readonly array $overwrite |
| 18 | - ) { |
|
| 18 | + ){ |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | public function getFirstArgument(): ?string |
@@ -23,14 +23,14 @@ discard block |
||
| 23 | 23 | return $this->overwrite['firstArgument'] ?? $this->input->getFirstArgument(); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - public function hasParameterOption(string|array $values, bool $onlyParams = false): bool |
|
| 26 | + public function hasParameterOption(string | array $values, bool $onlyParams = false): bool |
|
| 27 | 27 | { |
| 28 | 28 | return $this->input->hasParameterOption($values, $onlyParams); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | public function getParameterOption( |
| 32 | - string|array $values, |
|
| 33 | - string|bool|int|float|array|null $default = false, |
|
| 32 | + string | array $values, |
|
| 33 | + string | bool | int | float | array | null $default = false, |
|
| 34 | 34 | bool $onlyParams = false |
| 35 | 35 | ): mixed { |
| 36 | 36 | return $this->input->getParameterOption($values, $default, $onlyParams); |
@@ -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; |
@@ -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): void |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | public function addConfigureSequence( |
| 98 | - string|array|\Closure $sequence, |
|
| 98 | + string | array | \Closure $sequence, |
|
| 99 | 99 | string $header, |
| 100 | 100 | string $footer = '', |
| 101 | 101 | array $options = [] |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | public function addUpdateSequence( |
| 107 | - string|array|\Closure $sequence, |
|
| 107 | + string | array | \Closure $sequence, |
|
| 108 | 108 | string $header, |
| 109 | 109 | string $footer = '', |
| 110 | 110 | array $options = [] |
@@ -114,12 +114,12 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | public function addSequence( |
| 116 | 116 | string $name, |
| 117 | - string|array|\Closure $sequence, |
|
| 117 | + string | array | \Closure $sequence, |
|
| 118 | 118 | string $header, |
| 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 | $this->config->modify( |
| 124 | 124 | ConsoleConfig::CONFIG, |
| 125 | 125 | new Append('sequences', $name, []) |
@@ -128,13 +128,13 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | $this->config->modify( |
| 130 | 130 | ConsoleConfig::CONFIG, |
| 131 | - $this->sequence('sequences.' . $name, $sequence, $header, $footer, $options) |
|
| 131 | + $this->sequence('sequences.'.$name, $sequence, $header, $footer, $options) |
|
| 132 | 132 | ); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | private function sequence( |
| 136 | 136 | string $target, |
| 137 | - string|array|callable $sequence, |
|
| 137 | + string | array | callable $sequence, |
|
| 138 | 138 | string $header, |
| 139 | 139 | string $footer, |
| 140 | 140 | array $options |
@@ -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, []) |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | public function getLocaleDirectory(string $locale): string |
| 79 | 79 | { |
| 80 | - return $this->getLocalesDirectory() . $locale . '/'; |
|
| 80 | + return $this->getLocalesDirectory().$locale.'/'; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -86,11 +86,11 @@ discard block |
||
| 86 | 86 | public function resolveDomain(string $bundle): string |
| 87 | 87 | { |
| 88 | 88 | $bundle = \strtolower(\str_replace(['/', '\\'], '-', $bundle)); |
| 89 | - $domains = (array) ($this->config['domains'] ?? []); |
|
| 89 | + $domains = (array)($this->config['domains'] ?? []); |
|
| 90 | 90 | |
| 91 | - foreach ($domains as $domain => $patterns) { |
|
| 92 | - foreach ($patterns as $pattern) { |
|
| 93 | - if ($this->matcher->matches($bundle, $pattern)) { |
|
| 91 | + foreach ($domains as $domain => $patterns){ |
|
| 92 | + foreach ($patterns as $pattern){ |
|
| 93 | + if ($this->matcher->matches($bundle, $pattern)){ |
|
| 94 | 94 | return $domain; |
| 95 | 95 | } |
| 96 | 96 | } |
@@ -88,9 +88,12 @@ |
||
| 88 | 88 | $bundle = \strtolower(\str_replace(['/', '\\'], '-', $bundle)); |
| 89 | 89 | $domains = (array) ($this->config['domains'] ?? []); |
| 90 | 90 | |
| 91 | - foreach ($domains as $domain => $patterns) { |
|
| 92 | - foreach ($patterns as $pattern) { |
|
| 93 | - if ($this->matcher->matches($bundle, $pattern)) { |
|
| 91 | + foreach ($domains as $domain => $patterns) |
|
| 92 | + { |
|
| 93 | + foreach ($patterns as $pattern) |
|
| 94 | + { |
|
| 95 | + if ($this->matcher->matches($bundle, $pattern)) |
|
| 96 | + { |
|
| 94 | 97 | return $domain; |
| 95 | 98 | } |
| 96 | 99 | } |