InOrder   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 7
dl 0
loc 15
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A visit() 0 13 3
1
<?php namespace Mbh\Tree\Visitor;
2
3
use Mbh\Tree\Interfaces\Node as NodeInterface;
4
use Mbh\Tree\Visitor;
5
6
class InOrder extends Visitor
7
{
8
    public function visit(NodeInterface $node)
9
    {
10
        if ($node->isLeaf()) {
11
            return [$node];
12
        }
13
14
        $yield = [];
15
16
        foreach ($node->getChildren() as $child) {
17
            $yield = array_merge($yield, $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

17
            $yield = array_merge($yield, /** @scrutinizer ignore-type */ $child->accept($this));
Loading history...
18
        }
19
20
        return $yield;
21
    }
22
}
23