Completed
Push — master ( f06ad0...9cb85d )
by Nico
06:26
created

NodeVariable::getNode()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @license     http://opensource.org/licenses/mit-license.php MIT
7
 * @link        https://github.com/nicoSWD
8
 * @author      Nicolas Oelgart <[email protected]>
9
 */
10
namespace nicoSWD\Rules\TokenStream\Nodes;
11
12
use nicoSWD\Rules\Tokens\BaseToken;
13
14
final class NodeVariable extends BaseNode
15
{
16 90
    public function getNode(): BaseToken
17
    {
18 90
        $current = $this->tokenStream->getVariable(
19 90
            $this->getCurrentNode()->getValue()
20
        );
21 86
        $current->setStack($this->tokenStream->getStack());
22
23 86
        while ($this->hasMethodCall()) {
24 32
            $current = $this->getMethod($current)->call(...$this->getArguments());
0 ignored issues
show
Documentation introduced by
$this->getArguments() is of type object<nicoSWD\Rules\TokenStream\TokenCollection>, but the function expects a object<nicoSWD\Rules\Tokens\BaseToken>|null.

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...
25
        }
26
27 86
        return $current;
28
    }
29
}
30