@@ -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 |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @return YamlObject the YAML document as an object |
72 | 72 | */ |
73 | - public function buildDocument(NodeList &$list, int $docNum):YamlObject |
|
73 | + public function buildDocument(NodeList&$list, int $docNum):YamlObject |
|
74 | 74 | { |
75 | 75 | $yamlObject = new YamlObject($this->_options); |
76 | 76 | $rootNode = new Root(); |
@@ -89,14 +89,14 @@ discard block |
||
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | - public function pushAndSave(DocEnd $child, NodeList &$buffer, array &$documents) |
|
92 | + public function pushAndSave(DocEnd $child, NodeList&$buffer, array &$documents) |
|
93 | 93 | { |
94 | 94 | $buffer->push($child); |
95 | 95 | $documents[] = $this->buildDocument($buffer, count($documents) + 1); |
96 | 96 | $buffer = new NodeList(); |
97 | 97 | } |
98 | 98 | |
99 | - public function saveAndPush(DocStart $child, NodeList &$buffer, array &$documents) |
|
99 | + public function saveAndPush(DocStart $child, NodeList&$buffer, array &$documents) |
|
100 | 100 | { |
101 | 101 | if ($buffer->count() > 0 && $buffer->hasContent()) { |
102 | 102 | $documents[] = $this->buildDocument($buffer, count($documents) + 1); |
@@ -12,14 +12,14 @@ discard block |
||
12 | 12 | { |
13 | 13 | public function add(NodeGeneric $child):NodeGeneric |
14 | 14 | { |
15 | - if($this->_parent instanceof NodeGeneric) { |
|
15 | + if ($this->_parent instanceof NodeGeneric) { |
|
16 | 16 | return $this->_parent->add($child); |
17 | 17 | } else { |
18 | 18 | throw new \ParseError(__METHOD__." no parent to add to", 1); |
19 | 19 | } |
20 | 20 | } |
21 | 21 | |
22 | - public function specialProcess(NodeGeneric &$previous, array &$emptyLines):bool |
|
22 | + public function specialProcess(NodeGeneric&$previous, array &$emptyLines):bool |
|
23 | 23 | { |
24 | 24 | $deepest = $previous->getDeepestNode(); |
25 | 25 | if ($previous instanceof Scalar) { |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | return "\n"; |
36 | 36 | } |
37 | 37 | |
38 | - public function getTargetOnEqualIndent(NodeGeneric &$node):NodeGeneric |
|
38 | + public function getTargetOnEqualIndent(NodeGeneric&$node):NodeGeneric |
|
39 | 39 | { |
40 | 40 | return $this->getParent($node->indent); |
41 | 41 | } |
42 | 42 | |
43 | - public function getTargetOnMoreIndent(NodeGeneric &$node):NodeGeneric |
|
43 | + public function getTargetOnMoreIndent(NodeGeneric&$node):NodeGeneric |
|
44 | 44 | { |
45 | 45 | return $this->getParent($node->indent); |
46 | 46 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | throw new \Exception(__METHOD__." expects a YamlObject as parent", 1); |
40 | 40 | } |
41 | 41 | if (!is_null($this->value)) { |
42 | - if ($this->value instanceof Tag){ |
|
42 | + if ($this->value instanceof Tag) { |
|
43 | 43 | preg_match(Regex::TAG_PARTS, $this->value->raw, $tagparts); |
44 | 44 | if (preg_match("/(?(DEFINE)".Regex::TAG_URI.')(?&url)/', $tagparts['tagname'], $matches)) { |
45 | 45 | // throw new \UnexpectedValueException("Tag '".$this->value->raw."' is invalid", 1); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | return $this->value instanceof NodeGeneric && $this->value->isOneOf('Anchor', 'Literal', 'LiteralFolded'); |
63 | 63 | } |
64 | 64 | |
65 | - public function getTargetOnEqualIndent(NodeGeneric &$node):NodeGeneric |
|
65 | + public function getTargetOnEqualIndent(NodeGeneric&$node):NodeGeneric |
|
66 | 66 | { |
67 | 67 | if ($this->value instanceof NodeGeneric) { |
68 | 68 | if ($this->value instanceof Tag) { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | if ($value instanceof Key && $child instanceof Key) { |
33 | 33 | if ($value->indent === $child->indent) { |
34 | 34 | return parent::add($child); |
35 | - } elseif ($value->isAwaitingChild($child)){ |
|
35 | + } elseif ($value->isAwaitingChild($child)) { |
|
36 | 36 | return $value->add($child); |
37 | 37 | } else { |
38 | 38 | // throw new \ParseError('key ('.$value->identifier.')@'.$value->line.' has already a value', 1); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | return parent::add($child); |
43 | 43 | } |
44 | 44 | |
45 | - public function getTargetOnEqualIndent(NodeGeneric &$node):NodeGeneric |
|
45 | + public function getTargetOnEqualIndent(NodeGeneric&$node):NodeGeneric |
|
46 | 46 | { |
47 | 47 | $supposedParent = $this->getParent(); |
48 | 48 | if ($node->indent === $supposedParent->indent) { |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | return $supposedParent; |
52 | 52 | } |
53 | 53 | |
54 | - public function getTargetOnMoreIndent(NodeGeneric &$node):NodeGeneric |
|
54 | + public function getTargetOnMoreIndent(NodeGeneric&$node):NodeGeneric |
|
55 | 55 | { |
56 | 56 | return $this->value instanceof NodeGeneric && $this->value->isAwaitingChild($node) ? $this->value : $this; |
57 | 57 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | * |
21 | 21 | * @return boolean true to skip normal Loader process, false to continue |
22 | 22 | */ |
23 | - public function specialProcess(NodeGeneric &$current, array &$emptyLines):bool |
|
23 | + public function specialProcess(NodeGeneric&$current, array &$emptyLines):bool |
|
24 | 24 | { |
25 | 25 | $parent = $this->getParent(); |
26 | 26 | $addValue = ltrim($current->raw); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | return is_null($this->value); |
23 | 23 | } |
24 | 24 | |
25 | - public function getTargetOnEqualIndent(NodeGeneric &$node):NodeGeneric |
|
25 | + public function getTargetOnEqualIndent(NodeGeneric&$node):NodeGeneric |
|
26 | 26 | { |
27 | 27 | if (is_null($this->value) && $this->indent > 0) { |
28 | 28 | return $this; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | } catch (\UnexpectedValueException $e) { |
60 | 60 | return new Tagged($this->tag, is_null($value) ? null : $this->value->build($parent)); |
61 | 61 | } catch (\Throwable $e) { |
62 | - throw new \Exception("Tagged value could not be transformed for tag '$this->tag'", 1, $e);; |
|
62 | + throw new \Exception("Tagged value could not be transformed for tag '$this->tag'", 1, $e); ; |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | } |
66 | 66 | \ No newline at end of file |