Conditions | 7 |
Paths | 7 |
Total Lines | 34 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
17 | public function afterTraverse(array $nodes) |
||
18 | { |
||
19 | foreach ($nodes as &$node) { |
||
20 | |||
21 | if (!$node instanceof Node\Stmt\Expression) { |
||
22 | continue; |
||
23 | } |
||
24 | |||
25 | if (!$node->expr instanceof Node\Expr\FuncCall) { |
||
26 | continue; |
||
27 | } |
||
28 | |||
29 | if (!isset($node->expr->name)) { |
||
30 | continue; |
||
31 | } |
||
32 | |||
33 | if ($node->expr->name->parts[0] != 'define') { |
||
34 | continue; |
||
35 | } |
||
36 | |||
37 | $nameNode = $node->expr->args[0]->value; |
||
38 | $valueNode = $node->expr->args[1]->value; |
||
39 | |||
40 | if (!$valueNode instanceof Node\Expr\Array_) { |
||
41 | continue; |
||
42 | } |
||
43 | |||
44 | $constNode = new Node\Const_($nameNode->value, $valueNode); |
||
45 | |||
46 | $node = new Node\Stmt\Const_([$constNode]); |
||
47 | } |
||
48 | |||
49 | return $nodes; |
||
50 | } |
||
51 | } |
||
52 |