@@ 18-33 (lines=16) @@ | ||
15 | if ($node instanceof Node) { |
|
16 | $r = $node->getType() . '('; |
|
17 | ||
18 | foreach ($node->getSubNodeNames() as $key) { |
|
19 | $r .= "\n " . $key . ': '; |
|
20 | ||
21 | $value = $node->$key; |
|
22 | if (null === $value) { |
|
23 | $r .= 'null'; |
|
24 | } elseif (false === $value) { |
|
25 | $r .= 'false'; |
|
26 | } elseif (true === $value) { |
|
27 | $r .= 'true'; |
|
28 | } elseif (is_scalar($value)) { |
|
29 | $r .= $value; |
|
30 | } else { |
|
31 | $r .= str_replace("\n", "\n ", $this->dump($value)); |
|
32 | } |
|
33 | } |
|
34 | } elseif (is_array($node)) { |
|
35 | $r = 'array('; |
|
36 | ||
@@ 37-51 (lines=15) @@ | ||
34 | } elseif (is_array($node)) { |
|
35 | $r = 'array('; |
|
36 | ||
37 | foreach ($node as $key => $value) { |
|
38 | $r .= "\n " . $key . ': '; |
|
39 | ||
40 | if (null === $value) { |
|
41 | $r .= 'null'; |
|
42 | } elseif (false === $value) { |
|
43 | $r .= 'false'; |
|
44 | } elseif (true === $value) { |
|
45 | $r .= 'true'; |
|
46 | } elseif (is_scalar($value)) { |
|
47 | $r .= $value; |
|
48 | } else { |
|
49 | $r .= str_replace("\n", "\n ", $this->dump($value)); |
|
50 | } |
|
51 | } |
|
52 | } else { |
|
53 | throw new \InvalidArgumentException('Can only dump nodes and arrays.'); |
|
54 | } |