@@ -20,10 +20,10 @@ discard block |
||
20 | 20 | //public |
21 | 21 | /* @var null|string */ |
22 | 22 | public static $error; |
23 | - public const IGNORE_DIRECTIVES = 0b0001;//DONT include_directive |
|
24 | - public const IGNORE_COMMENTS = 0b0010;//DONT include_comments |
|
25 | - public const NO_PARSING_EXCEPTIONS = 0b0100;//DONT throw Exception on parsing errors |
|
26 | - public const NO_OBJECT_FOR_DATE = 0b1000;//DONT import date strings as dateTime Object |
|
23 | + public const IGNORE_DIRECTIVES = 0b0001; //DONT include_directive |
|
24 | + public const IGNORE_COMMENTS = 0b0010; //DONT include_comments |
|
25 | + public const NO_PARSING_EXCEPTIONS = 0b0100; //DONT throw Exception on parsing errors |
|
26 | + public const NO_OBJECT_FOR_DATE = 0b1000; //DONT import date strings as dateTime Object |
|
27 | 27 | |
28 | 28 | //private |
29 | 29 | /* @var null|array */ |
@@ -178,8 +178,8 @@ discard block |
||
178 | 178 | { |
179 | 179 | $deepest = $previous->getDeepestNode(); |
180 | 180 | if ($deepest instanceof Nodes\Partial) { |
181 | - return $deepest->specialProcess($current, $this->_blankBuffer); |
|
182 | - } elseif(!($current instanceof Nodes\Partial)) { |
|
181 | + return $deepest->specialProcess($current, $this->_blankBuffer); |
|
182 | + } elseif (!($current instanceof Nodes\Partial)) { |
|
183 | 183 | return $current->specialProcess($previous, $this->_blankBuffer); |
184 | 184 | } |
185 | 185 | return false; |
@@ -129,8 +129,12 @@ |
||
129 | 129 | try { |
130 | 130 | foreach ($generator as $lineNB => $lineString) { |
131 | 131 | $node = NodeFactory::get($lineString, $lineNB); |
132 | - if ($this->_debug === 1) echo $lineNB.":".get_class($node)."\n"; |
|
133 | - if ($this->needsSpecialProcess($node, $previous)) continue; |
|
132 | + if ($this->_debug === 1) { |
|
133 | + echo $lineNB.":".get_class($node)."\n"; |
|
134 | + } |
|
135 | + if ($this->needsSpecialProcess($node, $previous)) { |
|
136 | + continue; |
|
137 | + } |
|
134 | 138 | $this->_attachBlankLines($previous); |
135 | 139 | switch ($node->indent <=> $previous->indent) { |
136 | 140 | case -1: $target = $previous->getTargetOnLessIndent($node); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function str($node, &$parent = null) |
59 | 59 | { |
60 | - if($node instanceof Nodes\Literals){ |
|
60 | + if ($node instanceof Nodes\Literals) { |
|
61 | 61 | $node = $node->value; |
62 | 62 | } |
63 | 63 | if ($node instanceof Nodes\NodeGeneric) { |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | $list[] = $this->str($child); |
73 | 73 | } |
74 | 74 | // return new Nodes\Scalar(implode('',$list), 0); |
75 | - return implode('',$list); |
|
75 | + return implode('', $list); |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $keyValue = $key->value->build(); |
134 | 134 | if (is_null($parent)) { |
135 | 135 | return [$keyName => $keyValue]; |
136 | - } else{ |
|
136 | + } else { |
|
137 | 137 | $parent[$keyName] = $keyValue; |
138 | 138 | } |
139 | 139 | } else { |
@@ -13,6 +13,6 @@ |
||
13 | 13 | public function build(&$parent = null) |
14 | 14 | { |
15 | 15 | // return substr(Scalar::replaceSequences(trim($this->raw)), 1,-1); |
16 | - return (new Scalar('', 0))->replaceSequences(substr(trim($this->raw), 1,-1)); |
|
16 | + return (new Scalar('', 0))->replaceSequences(substr(trim($this->raw), 1, -1)); |
|
17 | 17 | } |
18 | 18 | } |
19 | 19 | \ No newline at end of file |
@@ -18,7 +18,7 @@ |
||
18 | 18 | try { |
19 | 19 | return $yamlObject->getReference($name); |
20 | 20 | } catch (\Throwable $e) { |
21 | - throw new \ParseError("Unknown anchor : '$name' this:".$this->anchor,1,$e); |
|
21 | + throw new \ParseError("Unknown anchor : '$name' this:".$this->anchor, 1, $e); |
|
22 | 22 | } |
23 | 23 | } else { |
24 | 24 | $built = is_null($this->value) ? null : $this->value->build($parent); |
@@ -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 |