Passed
Push — 1.x ( 382435...54d325 )
by Ulises Jeremias
02:15
created

PreOrder::visit()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 1
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
1
<?php namespace Mbh\Tree\Visitor;
2
3
use Mbh\Tree\Interfaces\Node as NodeInterface;
4
use Mbh\Tree\Visitor;
5
6
class PreOrder extends Visitor
7
{
8
    public function visit(NodeInterface $node)
9
    {
10
        $nodes = [$node];
11
12
        foreach ($node->getChildren() as $child) {
13
            $nodes = array_merge(
14
                $nodes,
15
                $child->accept($this)
0 ignored issues
show
Bug introduced by
Are you sure the usage of $child->accept($this) targeting Mbh\Tree\Interfaces\Node::accept() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Bug introduced by
$child->accept($this) of type void is incompatible with the type null|array expected by parameter $array2 of array_merge(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

15
                /** @scrutinizer ignore-type */ $child->accept($this)
Loading history...
16
            );
17
        }
18
19
        return $nodes;
20
    }
21
}
22