| Conditions | 9 |
| Paths | 14 |
| Total Lines | 36 |
| Code Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | public function enterNode(Node $node) |
||
| 31 | { |
||
| 32 | if ($node instanceof Node\Stmt\Class_) { |
||
| 33 | $extends = ''; |
||
| 34 | $interfaces = []; |
||
| 35 | |||
| 36 | if ($node->extends) { |
||
| 37 | $extends = array((string)$node->extends); |
||
| 38 | } |
||
| 39 | |||
| 40 | if ($node->implements) { |
||
|
|
|||
| 41 | foreach ($node->implements as $interface) { |
||
| 42 | $interfaces[] = (string)$interface; |
||
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | $this->classes[(string)$node->namespacedName] = [ |
||
| 47 | 'extends' => $extends, |
||
| 48 | 'interfaces' => $interfaces, |
||
| 49 | ]; |
||
| 50 | } elseif ($node instanceof Node\Stmt\Trait_) { |
||
| 51 | $this->traits[(string)$node->namespacedName] = array(); |
||
| 52 | } elseif ($node instanceof Node\Stmt\Interface_) { |
||
| 53 | $extends = array(); |
||
| 54 | foreach ($node->extends as $ancestor) { |
||
| 55 | $extends[] = (string)$ancestor; |
||
| 56 | } |
||
| 57 | $this->interfaces[(string)$node->namespacedName] = [ |
||
| 58 | 'extends' => $extends, |
||
| 59 | ]; |
||
| 60 | } |
||
| 61 | if (!$node instanceof Node\Stmt\Namespace_) { |
||
| 62 | //break out of traversal as we only need highlevel information here! |
||
| 63 | return NodeTraverser::DONT_TRAVERSE_CHILDREN; |
||
| 64 | } |
||
| 65 | } |
||
| 66 | |||
| 82 |
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.