Completed
Pull Request — master (#293)
by Дмитрий
04:59 queued 01:09
created

UnreachableVisitor::leaveBlock()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author Patsura Dmitry https://github.com/ovr <[email protected]>
4
 */
5
6
namespace PHPSA\ControlFlow\Visitor;
7
8
use PHPSA\ControlFlow\Block;
9
10
class UnreachableVisitor extends AbstractVisitor
11
{
12
    /**
13
     * @param Block $block
14
     */
15
    public function enterBlock(Block $block)
16
    {
17
        $childrens = $block->getChildrens();
18
        if ($childrens) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $childrens of type PHPSA\ControlFlow\Node\AbstractNode[] is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
19
            foreach ($childrens as $children) {
20
                if ($children->willExit() && count($childrens) > 1) {
21
                    echo 'Unreacheable block ' . $block->getId() . PHP_EOL;
22
                }
23
            }
24
        }
25
    }
26
27
    /**
28
     * @param Block $block
29
     */
30
    public function leaveBlock(Block $block)
31
    {
32
    }
33
}
34