@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | public function add(NodeGeneric $child):NodeGeneric |
56 | 56 | { |
57 | - if ($this->value instanceof NodeGeneric && $this->value->isOneOf('Literal','LiteralFolded', 'Anchor')) { |
|
57 | + if ($this->value instanceof NodeGeneric && $this->value->isOneOf('Literal', 'LiteralFolded', 'Anchor')) { |
|
58 | 58 | return $this->value->add($child); |
59 | 59 | } else { |
60 | 60 | return parent::add($child); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | { |
85 | 85 | if (is_null($this->value) || $node instanceof Comment) { |
86 | 86 | return true; |
87 | - } elseif($this->value instanceof NodeGeneric) { |
|
87 | + } elseif ($this->value instanceof NodeGeneric) { |
|
88 | 88 | $current = $this->value; |
89 | 89 | } else { |
90 | 90 | $current = $this->value->current(); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | && !($child instanceof Directive) |
65 | 65 | && !($child instanceof Blank) |
66 | 66 | && !($child instanceof Docstart |
67 | - && is_null($child->value)) ) return true; |
|
67 | + && is_null($child->value))) return true; |
|
68 | 68 | } |
69 | 69 | return false; |
70 | 70 | } |
@@ -72,13 +72,13 @@ discard block |
||
72 | 72 | public function push($node) |
73 | 73 | { |
74 | 74 | $type = null; |
75 | - if ($node instanceof Item ) { |
|
75 | + if ($node instanceof Item) { |
|
76 | 76 | $type = self::SEQUENCE; |
77 | 77 | } elseif ($node instanceof Key) { |
78 | 78 | $type = self::MAPPING; |
79 | - } elseif ($node->isOneOf('SetKey','SetValue')) { |
|
79 | + } elseif ($node->isOneOf('SetKey', 'SetValue')) { |
|
80 | 80 | $type = self::SET; |
81 | - } elseif ($node instanceof Scalar){ |
|
81 | + } elseif ($node instanceof Scalar) { |
|
82 | 82 | $type = self::MULTILINE; |
83 | 83 | } |
84 | 84 | if (!is_null($type) && $this->checkTypeCoherence($type)) { |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | $output = trim($first->raw); |
142 | 142 | foreach ($list as $child) { |
143 | 143 | if ($child instanceof Scalar) { |
144 | - $separator = isset($output[-1]) && $output[-1] === "\n" ? '' : ' '; |
|
144 | + $separator = isset($output[-1]) && $output[-1] === "\n" ? '' : ' '; |
|
145 | 145 | $output .= $separator.trim($child->raw); |
146 | 146 | } elseif ($child instanceof Blank) { |
147 | 147 | $output .= "\n"; |
@@ -167,10 +167,10 @@ discard block |
||
167 | 167 | if ($child instanceof Comment) { |
168 | 168 | // $child->build(); |
169 | 169 | } else { |
170 | - if($child->value instanceof Comment) { |
|
170 | + if ($child->value instanceof Comment) { |
|
171 | 171 | // $child->value->build(); |
172 | 172 | // $child->value = null; |
173 | - } elseif($child->value instanceof NodeList) { |
|
173 | + } elseif ($child->value instanceof NodeList) { |
|
174 | 174 | $child->value = $child->value->filterComment(); |
175 | 175 | } |
176 | 176 | $out->push($child); |
@@ -11,9 +11,9 @@ |
||
11 | 11 | //documents to load |
12 | 12 | $files = ['examples/dummy.yml', 'examples/config.yml']; |
13 | 13 | |
14 | -foreach($files as $key => $fileName) |
|
14 | +foreach ($files as $key => $fileName) |
|
15 | 15 | { |
16 | - $yamlObjList[] = $yloader->load($fileName)->parse(); |
|
16 | + $yamlObjList[] = $yloader->load($fileName)->parse(); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | var_dump($yamlObjList); |
@@ -8,17 +8,17 @@ |
||
8 | 8 | * |
9 | 9 | * use as follows : "php examples/testing.php DEBUG_LEVEL YAML_FILENAME" |
10 | 10 | */ |
11 | -const JSON_OPTIONS = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_LINE_TERMINATORS | JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION | JSON_PARTIAL_OUTPUT_ON_ERROR; |
|
11 | +const JSON_OPTIONS = JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_LINE_TERMINATORS|JSON_UNESCAPED_UNICODE|JSON_PRESERVE_ZERO_FRACTION|JSON_PARTIAL_OUTPUT_ON_ERROR; |
|
12 | 12 | |
13 | 13 | $debug = (int) (isset($argv[1]) ? $argv[1] : null); |
14 | 14 | $file = (string) (isset($argv[2]) ? $argv[2] : null); |
15 | -echo memory_get_usage() . "\n"; |
|
15 | +echo memory_get_usage()."\n"; |
|
16 | 16 | /* USE CASE 1 |
17 | 17 | * load and parse if file exists |
18 | 18 | */ |
19 | -$content = file_get_contents($file);//var_dump($content); |
|
19 | +$content = file_get_contents($file); //var_dump($content); |
|
20 | 20 | $yaml = Yaml::parse($content, 0, $debug); |
21 | 21 | |
22 | -echo memory_get_usage() . "\n"; |
|
22 | +echo memory_get_usage()."\n"; |
|
23 | 23 | // var_dump($yaml); |
24 | 24 | var_dump(json_encode($yaml, JSON_OPTIONS)); |
25 | 25 | \ No newline at end of file |