GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

RunCommand::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
nc 1
nop 1
dl 0
loc 4
c 1
b 0
f 0
cc 1
rs 10
ccs 3
cts 3
cp 1
crap 1
1
<?php
2
/* (c) Anton Medvedev <[email protected]>
3
 *
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
8
namespace Deployer\Console;
9
10
use Deployer\Deployer;
11
use Deployer\Exception\Exception;
12
use Deployer\Task\Context;
13
use Deployer\Task\Task;
14
use Symfony\Component\Console\Command\Command;
15
use Symfony\Component\Console\Input\InputArgument;
16
use Symfony\Component\Console\Input\InputInterface as Input;
17
use Symfony\Component\Console\Input\InputOption as Option;
18
use Symfony\Component\Console\Output\OutputInterface as Output;
19
use function Deployer\run;
20
use function Deployer\write;
21
use function Deployer\writeln;
22
23
class RunCommand extends SelectCommand
24
{
25
    use CustomOption;
26
27 12
    public function __construct(Deployer $deployer)
28
    {
29 12
        parent::__construct('run', $deployer);
30 12
        $this->setDescription('Run any arbitrary command on hosts');
31 12
    }
32
33 12
    protected function configure()
34
    {
35 12
        parent::configure();
36 12
        $this->addArgument(
37 12
            'command-to-run',
38 12
            InputArgument::IS_ARRAY,
39 12
            'Command to run'
40
        );
41 12
        $this->addOption(
42 12
            'option',
43 12
            'o',
44 12
            Option::VALUE_REQUIRED | Option::VALUE_IS_ARRAY,
45 12
            'Set configuration option'
46
        );
47 12
    }
48
49
    protected function execute(Input $input, Output $output)
50
    {
51
        $this->deployer->input = $input;
52
        $this->deployer->output = $output;
53
54
        if ($output->getVerbosity() === Output::VERBOSITY_NORMAL) {
55
            $output->setVerbosity(Output::VERBOSITY_VERBOSE);
56
        }
57
58
        $command = implode(' ', $input->getArgument('command-to-run') ?? '');
0 ignored issues
show
Bug introduced by
It seems like $input->getArgument('command-to-run') ?? '' can also be of type 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 ignore-type  annotation

58
        $command = implode(' ', /** @scrutinizer ignore-type */ $input->getArgument('command-to-run') ?? '');
Loading history...
59
        $hosts = $this->selectHosts($input, $output);
60
        $this->applyOverrides($hosts, $input->getOption('option'));
0 ignored issues
show
Bug introduced by
It seems like $input->getOption('option') can also be of type boolean and null and string; however, parameter $options of Deployer\Console\RunCommand::applyOverrides() 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 ignore-type  annotation

60
        $this->applyOverrides($hosts, /** @scrutinizer ignore-type */ $input->getOption('option'));
Loading history...
61
62
        $task = new Task($command, function () use ($command, $hosts) {
0 ignored issues
show
Unused Code introduced by
The import $hosts is not used and could be removed.

This check looks for imports that have been defined, but are not used in the scope.

Loading history...
63
            run($command);
64
        });
65
66
        foreach ($hosts as $host) {
67
            try {
68
                $task->run(new Context($host, $input, $output));
69
            } catch (\Throwable $exception) {
70
                $this->deployer->messenger->renderException($exception, $host);
71
            }
72
        }
73
74
        return 0;
75
    }
76
}
77