@@ -16,13 +16,13 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | public function __construct( |
| 18 | 18 | private readonly array $configurators = [] |
| 19 | - ) { |
|
| 19 | + ){ |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | public function configure(Command $command, \ReflectionClass $reflection): void |
| 23 | 23 | { |
| 24 | - foreach ($this->configurators as $configurator) { |
|
| 25 | - if ($configurator->canConfigure($command, $reflection)) { |
|
| 24 | + foreach ($this->configurators as $configurator){ |
|
| 25 | + if ($configurator->canConfigure($command, $reflection)){ |
|
| 26 | 26 | $configurator->configure($command, $reflection); |
| 27 | 27 | return; |
| 28 | 28 | } |
@@ -21,8 +21,10 @@ |
||
| 21 | 21 | |
| 22 | 22 | public function configure(Command $command, \ReflectionClass $reflection): void |
| 23 | 23 | { |
| 24 | - foreach ($this->configurators as $configurator) { |
|
| 25 | - if ($configurator->canConfigure($command, $reflection)) { |
|
| 24 | + foreach ($this->configurators as $configurator) |
|
| 25 | + { |
|
| 26 | + if ($configurator->canConfigure($command, $reflection)) |
|
| 27 | + { |
|
| 26 | 28 | $configurator->configure($command, $reflection); |
| 27 | 29 | return; |
| 28 | 30 | } |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | { |
| 15 | 15 | public function __construct( |
| 16 | 16 | private readonly Parser $parser |
| 17 | - ) { |
|
| 17 | + ){ |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | public function canConfigure(Command $command, \ReflectionClass $reflection): bool |
@@ -24,15 +24,15 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | public function configure(Command $command, \ReflectionClass $reflection): void |
| 26 | 26 | { |
| 27 | - $result = $this->parser->parse((string) $reflection->getConstant('SIGNATURE')); |
|
| 27 | + $result = $this->parser->parse((string)$reflection->getConstant('SIGNATURE')); |
|
| 28 | 28 | |
| 29 | 29 | $command->setName($result->name); |
| 30 | 30 | |
| 31 | - foreach ($result->options as $option) { |
|
| 31 | + foreach ($result->options as $option){ |
|
| 32 | 32 | $command->getDefinition()->addOption($option); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - foreach ($result->arguments as $argument) { |
|
| 35 | + foreach ($result->arguments as $argument){ |
|
| 36 | 36 | $command->getDefinition()->addArgument($argument); |
| 37 | 37 | } |
| 38 | 38 | } |
@@ -28,11 +28,13 @@ |
||
| 28 | 28 | |
| 29 | 29 | $command->setName($result->name); |
| 30 | 30 | |
| 31 | - foreach ($result->options as $option) { |
|
| 31 | + foreach ($result->options as $option) |
|
| 32 | + { |
|
| 32 | 33 | $command->getDefinition()->addOption($option); |
| 33 | 34 | } |
| 34 | 35 | |
| 35 | - foreach ($result->arguments as $argument) { |
|
| 36 | + foreach ($result->arguments as $argument) |
|
| 37 | + { |
|
| 36 | 38 | $command->getDefinition()->addArgument($argument); |
| 37 | 39 | } |
| 38 | 40 | } |
@@ -16,15 +16,15 @@ discard block |
||
| 16 | 16 | { |
| 17 | 17 | public function __construct( |
| 18 | 18 | protected readonly ReaderInterface $reader |
| 19 | - ) { |
|
| 19 | + ){ |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | public function promptMissedArguments(Command $command, InputInterface $input, OutputInterface $output): void |
| 23 | 23 | { |
| 24 | 24 | $io = new SymfonyStyle($input, $output); |
| 25 | 25 | |
| 26 | - foreach ($command->getDefinition()->getArguments() as $argument) { |
|
| 27 | - if ($argument->isRequired() && $input->getArgument($argument->getName()) === null) { |
|
| 26 | + foreach ($command->getDefinition()->getArguments() as $argument){ |
|
| 27 | + if ($argument->isRequired() && $input->getArgument($argument->getName()) === null){ |
|
| 28 | 28 | $input->setArgument( |
| 29 | 29 | $argument->getName(), |
| 30 | 30 | $io->ask($this->getQuestion($command, $argument)) |
@@ -37,25 +37,25 @@ discard block |
||
| 37 | 37 | { |
| 38 | 38 | $reflection = new \ReflectionClass($command); |
| 39 | 39 | |
| 40 | - foreach ($this->reader->getClassMetadata($reflection, Question::class) as $question) { |
|
| 41 | - if ($question->argument === null) { |
|
| 40 | + foreach ($this->reader->getClassMetadata($reflection, Question::class) as $question){ |
|
| 41 | + if ($question->argument === null){ |
|
| 42 | 42 | throw new ConsoleException( |
| 43 | 43 | 'When using a `Question` attribute on a console command class, the argument parameter is required.' |
| 44 | 44 | ); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - if ($argument->getName() === $question->argument) { |
|
| 47 | + if ($argument->getName() === $question->argument){ |
|
| 48 | 48 | return $question->question; |
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - foreach ($reflection->getProperties() as $property) { |
|
| 52 | + foreach ($reflection->getProperties() as $property){ |
|
| 53 | 53 | $question = $this->reader->firstPropertyMetadata($property, Question::class); |
| 54 | - if ($question === null) { |
|
| 54 | + if ($question === null){ |
|
| 55 | 55 | continue; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - if ($argument->getName() === ($question->argument ?? $property->getName())) { |
|
| 58 | + if ($argument->getName() === ($question->argument ?? $property->getName())){ |
|
| 59 | 59 | return $question->question; |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -23,8 +23,10 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | $io = new SymfonyStyle($input, $output); |
| 25 | 25 | |
| 26 | - foreach ($command->getDefinition()->getArguments() as $argument) { |
|
| 27 | - if ($argument->isRequired() && $input->getArgument($argument->getName()) === null) { |
|
| 26 | + foreach ($command->getDefinition()->getArguments() as $argument) |
|
| 27 | + { |
|
| 28 | + if ($argument->isRequired() && $input->getArgument($argument->getName()) === null) |
|
| 29 | + { |
|
| 28 | 30 | $input->setArgument( |
| 29 | 31 | $argument->getName(), |
| 30 | 32 | $io->ask($this->getQuestion($command, $argument)) |
@@ -37,25 +39,31 @@ discard block |
||
| 37 | 39 | { |
| 38 | 40 | $reflection = new \ReflectionClass($command); |
| 39 | 41 | |
| 40 | - foreach ($this->reader->getClassMetadata($reflection, Question::class) as $question) { |
|
| 41 | - if ($question->argument === null) { |
|
| 42 | + foreach ($this->reader->getClassMetadata($reflection, Question::class) as $question) |
|
| 43 | + { |
|
| 44 | + if ($question->argument === null) |
|
| 45 | + { |
|
| 42 | 46 | throw new ConsoleException( |
| 43 | 47 | 'When using a `Question` attribute on a console command class, the argument parameter is required.' |
| 44 | 48 | ); |
| 45 | 49 | } |
| 46 | 50 | |
| 47 | - if ($argument->getName() === $question->argument) { |
|
| 51 | + if ($argument->getName() === $question->argument) |
|
| 52 | + { |
|
| 48 | 53 | return $question->question; |
| 49 | 54 | } |
| 50 | 55 | } |
| 51 | 56 | |
| 52 | - foreach ($reflection->getProperties() as $property) { |
|
| 57 | + foreach ($reflection->getProperties() as $property) |
|
| 58 | + { |
|
| 53 | 59 | $question = $this->reader->firstPropertyMetadata($property, Question::class); |
| 54 | - if ($question === null) { |
|
| 60 | + if ($question === null) |
|
| 61 | + { |
|
| 55 | 62 | continue; |
| 56 | 63 | } |
| 57 | 64 | |
| 58 | - if ($argument->getName() === ($question->argument ?? $property->getName())) { |
|
| 65 | + if ($argument->getName() === ($question->argument ?? $property->getName())) |
|
| 66 | + { |
|
| 59 | 67 | return $question->question; |
| 60 | 68 | } |
| 61 | 69 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | protected function execute(InputInterface $input, OutputInterface $output): int |
| 77 | 77 | { |
| 78 | - if ($this->container === null) { |
|
| 78 | + if ($this->container === null){ |
|
| 79 | 79 | throw new ScopeException('Container is not set'); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | $core = $this->buildCore(); |
| 85 | 85 | |
| 86 | - try { |
|
| 86 | + try{ |
|
| 87 | 87 | [$this->input, $this->output] = [$this->prepareInput($input), $this->prepareOutput($input, $output)]; |
| 88 | 88 | |
| 89 | 89 | $this->eventDispatcher?->dispatch(new CommandStarting($this, $this->input, $this->output)); |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $this->eventDispatcher?->dispatch(new CommandFinished($this, $code, $this->input, $this->output)); |
| 99 | 99 | |
| 100 | 100 | return $code; |
| 101 | - } finally { |
|
| 101 | + }finally{ |
|
| 102 | 102 | [$this->input, $this->output] = [null, null]; |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | $interceptableCore = new InterceptableCore($core, $this->eventDispatcher); |
| 111 | 111 | |
| 112 | - foreach ($this->interceptors as $interceptor) { |
|
| 112 | + foreach ($this->interceptors as $interceptor){ |
|
| 113 | 113 | $interceptableCore->addInterceptor($this->container->get($interceptor)); |
| 114 | 114 | } |
| 115 | 115 | $interceptableCore->addInterceptor($this->container->get(AttributeInterceptor::class)); |
@@ -75,7 +75,8 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | protected function execute(InputInterface $input, OutputInterface $output): int |
| 77 | 77 | { |
| 78 | - if ($this->container === null) { |
|
| 78 | + if ($this->container === null) |
|
| 79 | + { |
|
| 79 | 80 | throw new ScopeException('Container is not set'); |
| 80 | 81 | } |
| 81 | 82 | |
@@ -83,7 +84,8 @@ discard block |
||
| 83 | 84 | |
| 84 | 85 | $core = $this->buildCore(); |
| 85 | 86 | |
| 86 | - try { |
|
| 87 | + try |
|
| 88 | + { |
|
| 87 | 89 | [$this->input, $this->output] = [$this->prepareInput($input), $this->prepareOutput($input, $output)]; |
| 88 | 90 | |
| 89 | 91 | $this->eventDispatcher?->dispatch(new CommandStarting($this, $this->input, $this->output)); |
@@ -98,7 +100,9 @@ discard block |
||
| 98 | 100 | $this->eventDispatcher?->dispatch(new CommandFinished($this, $code, $this->input, $this->output)); |
| 99 | 101 | |
| 100 | 102 | return $code; |
| 101 | - } finally { |
|
| 103 | + } |
|
| 104 | + finally |
|
| 105 | + { |
|
| 102 | 106 | [$this->input, $this->output] = [null, null]; |
| 103 | 107 | } |
| 104 | 108 | } |
@@ -109,7 +113,8 @@ discard block |
||
| 109 | 113 | |
| 110 | 114 | $interceptableCore = new InterceptableCore($core, $this->eventDispatcher); |
| 111 | 115 | |
| 112 | - foreach ($this->interceptors as $interceptor) { |
|
| 116 | + foreach ($this->interceptors as $interceptor) |
|
| 117 | + { |
|
| 113 | 118 | $interceptableCore->addInterceptor($this->container->get($interceptor)); |
| 114 | 119 | } |
| 115 | 120 | $interceptableCore->addInterceptor($this->container->get(AttributeInterceptor::class)); |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | { |
| 15 | 15 | public function __construct( |
| 16 | 16 | private readonly Parser $parser |
| 17 | - ) { |
|
| 17 | + ){ |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | public function process(string $controller, string $action, array $parameters, CoreInterface $core): int |