NamespaceParser::setUses()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Padawan\Parser;
4
5
use PhpParser\Node\Stmt\Namespace_;
6
use PhpParser\Node\Name;
7
use Padawan\Domain\Project\FQN;
8
use Padawan\Domain\Project\Node\Uses;
9
10
class NamespaceParser {
11
    public function parse(Namespace_ $node) {
12
        if ($node->name instanceof Name) {
13
            $fqn = new FQN($node->name->parts);
0 ignored issues
show
Documentation introduced by
$node->name->parts is of type array<integer,string>, but the function expects a string.

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...
14
            $this->uses->setFQCN($fqn);
15
        }
16
    }
17
    public function setUses(Uses $uses = null) {
18
        $this->uses = $uses;
19
    }
20
    private $uses;
21
}
22