@@ -94,7 +94,7 @@ |
||
94 | 94 | * @return string The child value. |
95 | 95 | * @todo double check behaviour for KEY and ITEM |
96 | 96 | */ |
97 | - protected function getChildValue(object $child, $refIndent=0):string |
|
97 | + protected function getChildValue(object $child, $refIndent = 0):string |
|
98 | 98 | { |
99 | 99 | $value = $child->value; |
100 | 100 | $start = ''; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | public function add(NodeGeneric $child):NodeGeneric |
63 | 63 | { |
64 | - if ($this->value instanceof NodeGeneric && $this->value->isOneOf('Literal','LiteralFolded', 'Anchor')) { |
|
64 | + if ($this->value instanceof NodeGeneric && $this->value->isOneOf('Literal', 'LiteralFolded', 'Anchor')) { |
|
65 | 65 | return $this->value->add($child); |
66 | 66 | } else { |
67 | 67 | return parent::add($child); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | if ($current instanceof Comment) { |
97 | 97 | return true; |
98 | 98 | } |
99 | - if($current instanceof Scalar) { |
|
99 | + if ($current instanceof Scalar) { |
|
100 | 100 | return $node->isOneOf('Scalar', 'Blank'); |
101 | 101 | } |
102 | 102 | if ($current instanceof Item) { |
@@ -106,7 +106,7 @@ |
||
106 | 106 | if (count(self::$schemas) === 0) { |
107 | 107 | self::createCoreSchema(); |
108 | 108 | } |
109 | - if (!($value instanceof NodeGeneric) && !($value instanceof NodeList) ) { |
|
109 | + if (!($value instanceof NodeGeneric) && !($value instanceof NodeList)) { |
|
110 | 110 | throw new \Exception(sprintf(self::WRONG_VALUE, $identifier, gettype($value))); |
111 | 111 | } else { |
112 | 112 | // try { |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function str(object $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 { |
@@ -39,7 +39,7 @@ |
||
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); |
@@ -59,7 +59,7 @@ |
||
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 |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | elseif ((bool) preg_match(Regex::KEY, $trimmed, $matches)) return new Nodes\Key($nodeString, $line, $matches); |
29 | 29 | else { |
30 | 30 | $first = $trimmed[0]; |
31 | - $stringGroups = ['-', '>|' , '"\'', "#%" , "{[" , ":?" , '*&!']; |
|
32 | - $methodGroups = ['Hyphen','Literal','Quoted','Special','Compact','SetElement','NodeAction']; |
|
31 | + $stringGroups = ['-', '>|', '"\'', "#%", "{[", ":?", '*&!']; |
|
32 | + $methodGroups = ['Hyphen', 'Literal', 'Quoted', 'Special', 'Compact', 'SetElement', 'NodeAction']; |
|
33 | 33 | foreach ($stringGroups as $groupIndex => $stringRef) { |
34 | 34 | if (is_int(strpos($stringRef, $first))) { |
35 | 35 | $methodName = 'on'.$methodGroups[$groupIndex]; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | } |
146 | 146 | // $action = trim($matches['action']);//var_dump($matches); |
147 | 147 | switch ($first) { |
148 | - case '!': return new Nodes\Tag ($nodeString, $line); |
|
148 | + case '!': return new Nodes\Tag($nodeString, $line); |
|
149 | 149 | default : |
150 | 150 | return new Nodes\Anchor($nodeString, $line); |
151 | 151 | // case '&': return new NodeAnchor($nodeString, $line); |
@@ -12,6 +12,6 @@ |
||
12 | 12 | { |
13 | 13 | public function build(&$parent = null) |
14 | 14 | { |
15 | - return substr(Scalar::replaceSequences(trim($this->raw)), 1,-1); |
|
15 | + return substr(Scalar::replaceSequences(trim($this->raw)), 1, -1); |
|
16 | 16 | } |
17 | 17 | } |
18 | 18 | \ No newline at end of file |
@@ -6,18 +6,18 @@ |
||
6 | 6 | /** |
7 | 7 | * Display some use cases for Yaml library |
8 | 8 | */ |
9 | -const JSON_OPTIONS = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_LINE_TERMINATORS | JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION | JSON_PARTIAL_OUTPUT_ON_ERROR; |
|
9 | +const JSON_OPTIONS = JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_LINE_TERMINATORS|JSON_UNESCAPED_UNICODE|JSON_PRESERVE_ZERO_FRACTION|JSON_PARTIAL_OUTPUT_ON_ERROR; |
|
10 | 10 | |
11 | 11 | $debug = (int) (isset($argv[1]) ? $argv[1] : null); |
12 | 12 | |
13 | -echo memory_get_usage() . "\n"; |
|
13 | +echo memory_get_usage()."\n"; |
|
14 | 14 | /* USE CASE 1 |
15 | 15 | * load and parse if file exists |
16 | 16 | */ |
17 | -$content = file_get_contents('./tests/cases/examples/Example_2_25.yml');//var_dump($content); |
|
17 | +$content = file_get_contents('./tests/cases/examples/Example_2_25.yml'); //var_dump($content); |
|
18 | 18 | $yaml = Yaml::parse($content, 0, $debug); |
19 | 19 | |
20 | -echo memory_get_usage() . "\n"; |
|
20 | +echo memory_get_usage()."\n"; |
|
21 | 21 | // var_dump($yaml); |
22 | 22 | var_dump(json_encode($yaml, JSON_OPTIONS)); |
23 | 23 | exit(0); |