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.

Issues (4)

src/Processor.php (1 issue)

Severity
1
<?php
2
/**
3
 * @author    jan huang <[email protected]>
4
 * @copyright 2017
5
 *
6
 * @see      https://www.github.com/janhuang
7
 * @see      http://www.fast-d.cn/
8
 */
9
10
namespace FastD;
11
12
use FastD\Process\ProcessManager;
13
use Symfony\Component\Console\Input\ArgvInput;
14
use Symfony\Component\Console\Input\InputInterface;
15
use Symfony\Component\Console\Output\OutputInterface;
16
17
/**
18
 * Class Processor.
19
 */
20
class Processor extends Console
21
{
22
    public function registerCommands()
23
    {
24
        $command = new ProcessManager();
25
26
        $this->add($command);
27
28
        $path = app()->getPath().'/config/process.php';
29
30
        if (file_exists($path)) {
31
            config()->set('processes', include $path);
32
        }
33
    }
34
35
    /**
36
     * @param InputInterface|null  $input
37
     * @param OutputInterface|null $output
38
     *
39
     * @return int
40
     *
41
     * @throws \Exception
42
     */
43
    public function run(InputInterface $input = null, OutputInterface $output = null)
0 ignored issues
show
run uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
44
    {
45
        $argv = $_SERVER['argv'];
46
        $script = array_shift($argv);
47
        array_unshift($argv, 'process');
48
        array_unshift($argv, $script);
49
50
        return parent::run(new ArgvInput($argv), $output);
51
    }
52
}
53