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

UnreachableVisitor   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 24
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
B enterBlock() 0 11 5
A leaveBlock() 0 3 1
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