| Conditions | 7 |
| Paths | 7 |
| Total Lines | 29 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 7.6383 |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | 8 | public static function isEqual(\PhpParser\Node $nodeA, \PhpParser\Node $nodeB) |
|
| 13 | { |
||
| 14 | 8 | if ($nodeA->getType() !== $nodeB->getType()) { |
|
| 15 | return false; |
||
| 16 | } |
||
| 17 | |||
| 18 | 8 | $subNodesA = $nodeA->getSubNodeNames(); |
|
| 19 | 8 | $subNodesB = $nodeB->getSubNodeNames(); |
|
| 20 | 8 | if ($subNodesA !== $subNodesB) { |
|
| 21 | return false; |
||
| 22 | } |
||
| 23 | |||
| 24 | 8 | foreach ($subNodesA as $key) { |
|
| 25 | 8 | $valueA = $nodeA->$key; |
|
| 26 | 8 | $valueB = $nodeB->$key; |
|
| 27 | 8 | $result = true; |
|
|
|
|||
| 28 | 8 | if ($valueA instanceof \PhpParser\Node && $valueB instanceof \PhpParser\Node) { |
|
| 29 | $result = self::isEqual($valueA, $valueB); |
||
| 30 | } else { |
||
| 31 | 8 | $result = $valueA === $valueB; |
|
| 32 | } |
||
| 33 | |||
| 34 | 8 | if ( ! $result) { |
|
| 35 | 8 | return false; |
|
| 36 | } |
||
| 37 | } |
||
| 38 | |||
| 39 | return true; |
||
| 40 | } |
||
| 41 | } |
||
| 42 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.