Completed
Push — 4.0 ( 268f2c...88f012 )
by Hideki
05:48 queued 10s
created

src/Eccube/Command/ComposerRequireCommand.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
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.ec-cube.co.jp/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Eccube\Command;
15
16
use Eccube\Service\Composer\ComposerApiService;
17
use Symfony\Component\Console\Command\Command;
18
use Symfony\Component\Console\Input\InputArgument;
19
use Symfony\Component\Console\Input\InputInterface;
20
use Symfony\Component\Console\Output\OutputInterface;
21
22
class ComposerRequireCommand extends Command
23
{
24
    protected static $defaultName = 'eccube:composer:require';
25
26
    /**
27
     * @var ComposerApiService
28
     */
29
    private $composerService;
30
31
    public function __construct(ComposerApiService $composerService)
32
    {
33
        parent::__construct();
34
        $this->composerService = $composerService;
35
    }
36
37
    protected function configure()
38
    {
39
        $this->addArgument('package', InputArgument::REQUIRED)
40
            ->addArgument('version', InputArgument::OPTIONAL);
41
    }
42
43
    protected function execute(InputInterface $input, OutputInterface $output)
44
    {
45
        $packageName = $input->getArgument('package');
46
        if ($input->getArgument('version')) {
47
            $packageName .= ':'.$input->getArgument('version');
48
        }
49
        $this->composerService->execRequire($packageName, $output);
0 ignored issues
show
It seems like $packageName defined by $input->getArgument('package') on line 45 can also be of type array<integer,string> or null; however, Eccube\Service\Composer\...iService::execRequire() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
50
    }
51
}
52