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.
Passed
Push — master ( c538d5...8bac07 )
by Anton
02:32
created

src/Console/WorkerCommand.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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\Collection\PersistentCollection;
11
use Deployer\Deployer;
12
use Deployer\Exception\GracefulShutdownException;
13
use Deployer\Exception\NonFatalException;
14
use Deployer\Task\Context;
15
use Symfony\Component\Console\Input\InputArgument;
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Input\InputOption as Option;
18
use Symfony\Component\Console\Output\OutputInterface;
19
20
class WorkerCommand extends TaskCommand
21
{
22
    public function __construct(Deployer $deployer)
23
    {
24
        parent::__construct('worker', null, $deployer);
25
        $this->deployer = $deployer;
26
        $this->setHidden(true);
27
        $this->addArgument('worker-task', InputArgument::REQUIRED);
28
        $this->addArgument('worker-host', InputArgument::REQUIRED);
29
        $this->addArgument('worker-config', InputArgument::REQUIRED);
30
        $this->addArgument('original-task', InputArgument::REQUIRED);
31
        $this->addOption('decorated', null, Option::VALUE_NONE);
32
    }
33
34
    protected function execute(InputInterface $input, OutputInterface $output)
35
    {
36
        $output->setDecorated($input->getOption('decorated'));
37
        if (!$output->isDecorated()) {
38
            define('NO_ANSI', 'true');
39
        }
40
41
        $host = $this->deployer->hosts->get($input->getArgument('worker-host'));
42
        $task = $this->deployer->tasks->get($input->getArgument('worker-task'));
43
44
        $persistentCollection = new PersistentCollection($input->getArgument('worker-config'));
0 ignored issues
show
It seems like $input->getArgument('worker-config') targeting Symfony\Component\Consol...nterface::getArgument() can also be of type array<integer,string> or null; however, Deployer\Collection\Pers...llection::__construct() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
45
        $persistentCollection->load();
46
47
        $host->getConfig()->setCollection($persistentCollection);
48
        foreach ($persistentCollection as $name => $value) {
49
            $this->deployer->config->set($name, $value);
50
        }
51
52
        try {
53
            $task->run(new Context($host, $input, $output));
54
            $this->deployer->messenger->endOnHost($host);
55
56
            $persistentCollection->flush();
57
58
            return 0;
59
        } catch (GracefulShutdownException $e) {
60
            $this->deployer->messenger->renderException($e, $host);
61
            return GracefulShutdownException::EXIT_CODE;
62
        } catch (\Throwable $e) {
63
            $this->deployer->messenger->renderException($e, $host);
64
            return 255;
65
        }
66
    }
67
}
68