| Conditions | 5 |
| Paths | 4 |
| Total Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 44 | public function beforeTraverse(array $nodes): array |
||
| 45 | { |
||
| 46 | // Merge if code is namespaced |
||
| 47 | if (isset($nodes[0]) && $nodes[0] instanceof Namespace_) { |
||
| 48 | if ($this->namespaceName) { |
||
| 49 | if ((string)$nodes[0]->name == '') { |
||
| 50 | $nodes[0]->name = new Name($this->namespaceName); |
||
| 51 | } else { |
||
| 52 | $nodes[0]->name = Name::concat($this->namespaceName, $nodes[0]->name); |
||
| 53 | } |
||
| 54 | } |
||
| 55 | return $nodes; |
||
| 56 | } |
||
| 57 | |||
| 58 | // Else create new node |
||
| 59 | return [ |
||
| 60 | new Namespace_( |
||
| 61 | new Name($this->namespaceName), |
||
| 62 | $nodes |
||
| 63 | ) |
||
| 64 | ]; |
||
| 65 | } |
||
| 66 | } |
||
| 67 |