helick /
local-server
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Helick\LocalServer\Subcommands; |
||||
| 4 | |||||
| 5 | use Symfony\Component\Console\Input\InputInterface; |
||||
| 6 | use Symfony\Component\Console\Output\OutputInterface; |
||||
| 7 | |||||
| 8 | final class CliSubcommand extends Subcommand |
||||
| 9 | { |
||||
| 10 | /** |
||||
| 11 | * The process' command string. |
||||
| 12 | * |
||||
| 13 | * @var string |
||||
| 14 | */ |
||||
| 15 | const COMMAND = 'docker-compose exec -T -u nobody php vendor/bin/wp %s'; |
||||
| 16 | |||||
| 17 | /** |
||||
| 18 | * Invoke the subcommand. |
||||
| 19 | * |
||||
| 20 | * @param InputInterface $input |
||||
| 21 | * @param OutputInterface $output |
||||
| 22 | * |
||||
| 23 | * @return void |
||||
| 24 | */ |
||||
| 25 | public function __invoke(InputInterface $input, OutputInterface $output): void |
||||
| 26 | { |
||||
| 27 | $options = $input->getArgument('options'); |
||||
| 28 | |||||
| 29 | if (!$this->hasUrlOption($options)) { |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 30 | $options[] = sprintf('--url=http://%s.localtest.me/', basename(getcwd())); |
||||
| 31 | } |
||||
| 32 | |||||
| 33 | $this->runProcess(sprintf(static::COMMAND, implode(' ', $options))); |
||||
|
0 ignored issues
–
show
It seems like
$options can also be of type null and string; however, parameter $pieces of implode() does only seem to accept array, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 34 | } |
||||
| 35 | |||||
| 36 | /** |
||||
| 37 | * @param array $options |
||||
| 38 | * |
||||
| 39 | * @return bool |
||||
| 40 | */ |
||||
| 41 | protected function hasUrlOption(array $options): bool |
||||
| 42 | { |
||||
| 43 | foreach ($options as $option) { |
||||
| 44 | if (strpos($option, '--url=') === 0) { |
||||
| 45 | return true; |
||||
| 46 | } |
||||
| 47 | } |
||||
| 48 | |||||
| 49 | return false; |
||||
| 50 | } |
||||
| 51 | } |
||||
| 52 |