RemoCommands::run()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 9.568
c 0
b 0
f 0
cc 3
nc 4
nop 3
1
<?php
2
3
namespace Consolidation\SiteProcess\Remo;
4
5
use Consolidation\SiteProcess\SiteProcess;
6
7
use Consolidation\SiteAlias\SiteAliasManagerAwareInterface;
8
use Consolidation\SiteAlias\SiteAliasManagerAwareTrait;
9
use Consolidation\SiteAlias\SiteAliasManager;
10
11
class RemoCommands extends \Robo\Tasks
12
{
13
    use SiteAliasManagerAwareTrait;
14
15
    /**
16
     * Run a command identified by a site alias
17
     *
18
     * @command run
19
     */
20
    public function run($aliasName, array $args, $options = ['foo' => 'bar'])
0 ignored issues
show
Unused Code introduced by
The parameter $options is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
21
    {
22
        // The site alias manager has not been added to the DI container yet.
23
        if (!$this->hasSiteAliasManager()) {
24
            // TODO: Provide some way to initialize the alias file loaders, so
25
            // that there is some way to specify where alias files may be
26
            // loaded from.
27
            $manager = new SiteAliasManager();
28
            // $manager->setRoot($root);
29
            $this->setSiteAliasManager($manager);
30
        }
31
32
        // In theory this might do something once we get an alias manager.
33
        $siteAlias = $this->siteAliasManager()->get($aliasName);
34
        if (!$siteAlias) {
35
            throw new \Exception("Alias name $aliasName not found.");
36
        }
37
        $process = new SiteProcess($siteAlias, $args);
0 ignored issues
show
Bug introduced by
The call to SiteProcess::__construct() misses a required argument $args.

This check looks for function calls that miss required arguments.

Loading history...
Documentation introduced by
$args is of type array, but the function expects a object<Consolidation\Sit...ort\TransportInterface>.

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...
38
        $process->setRealtimeOutput($this->io());
0 ignored issues
show
Deprecated Code introduced by
The method Robo\Common\IO::io() has been deprecated with message: Use a style injector instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
39
        $process->setTty($this->input()->isInteractive());
40
        $process->mustRun($process->showRealtime());
41
    }
42
}
43