Failed Conditions
Push — develop ( 97d950...17c62d )
by Maxime
19:32
created

PublishCommand::getOptions()   A

Complexity

Conditions 1
Paths 1

Duplication

Lines 0
Ratio 0 %

Size

Total Lines 6
Code Lines 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 6
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of Rocketeer
5
 *
6
 * (c) Maxime Fabre <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 */
12
13
namespace Rocketeer\Console\Commands\Plugins;
14
15
use Rocketeer\Console\Commands\AbstractCommand;
16
use Rocketeer\Services\Ignition\PluginsIgniter;
17
use Symfony\Component\Console\Input\InputArgument;
18
use Symfony\Component\Console\Input\InputOption;
19
20
/**
21
 * Publishes the configuration of a plugin.
22
 */
23
class PublishCommand extends AbstractCommand
24
{
25
    /**
26
     * The default name.
27
     *
28
     * @var string
29
     */
30
    protected $name = 'plugins:config';
31
32
    /**
33
     * The console command description.
34
     *
35
     * @var string
36
     */
37
    protected $description = 'Publishes the configuration of a plugin';
38
39
    /**
40
     * Whether the command's task should be built
41
     * into a pipeline or run straight.
42
     *
43
     * @var bool
44
     */
45
    protected $straight = true;
46
47
    /**
48
     * [email protected]}
49
     */
50
    public function fire()
51
    {
52
        $this->container->add('command', $this);
53
54
        $publisher = new PluginsIgniter($this->container);
55
        $publisher->setForce($this->option('force'));
0 ignored issues
show
Documentation introduced by Maxime Fabre
$this->option('force') is of type string|array, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
56
        $publisher->publish($this->argument('package'));
0 ignored issues
show
Bug introduced by Maxime Fabre
It seems like $this->argument('package') targeting Rocketeer\Console\Comman...ractCommand::argument() can also be of type array; however, Rocketeer\Services\Ignit...uginsIgniter::publish() does only seem to accept string|array<integer,string>|null, 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...
57
    }
58
59
    /**
60
     * Get the console command arguments.
61
     *
62
     * @return string[][]
63
     */
64
    protected function getArguments()
65
    {
66
        return [
67
            ['package', InputArgument::IS_ARRAY, 'The package to publish the configuration for'],
68
        ];
69
    }
70
71
    /**
72
     * @return array
73
     */
74
    protected function getOptions()
75
    {
76
        return [
77
            ['force', 'F', InputOption::VALUE_NONE, 'Force overwriting already published configurations'],
78
        ];
79
    }
80
}
81