@@ -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 | 19 | $content = file_get_contents($file); |
20 | 20 | $yaml = Yaml::parse($content, 0, $debug); |
21 | 21 | |
22 | -echo memory_get_usage() . "\n"; |
|
22 | +echo memory_get_usage()."\n"; |
|
23 | 23 | |
24 | 24 | //var_dump($content);(json_encode($yaml, JSON_OPTIONS)); |
25 | 25 | \ No newline at end of file |
@@ -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 | print_r($yamlObjList); |
@@ -37,12 +37,12 @@ discard block |
||
37 | 37 | public function build(&$parent = null) |
38 | 38 | { |
39 | 39 | if (is_null($parent)) { |
40 | - throw new \Exception(__METHOD__ . " expects a YamlObject as parent", 1); |
|
40 | + throw new \Exception(__METHOD__." expects a YamlObject as parent", 1); |
|
41 | 41 | } |
42 | 42 | if (!is_null($this->value)) { |
43 | 43 | if ($this->value instanceof Tag) { |
44 | 44 | preg_match(Regex::TAG_PARTS, $this->value->raw, $tagparts); |
45 | - if (preg_match("/(?(DEFINE)" . Regex::TAG_URI . ')(?&url)/', $tagparts['tagname'], $matches)) { |
|
45 | + if (preg_match("/(?(DEFINE)".Regex::TAG_URI.')(?&url)/', $tagparts['tagname'], $matches)) { |
|
46 | 46 | $parent->addTag($tagparts['handle'], $tagparts['tagname']); |
47 | 47 | } else { |
48 | 48 | $this->value->build($parent); |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | return $this->value instanceof NodeGeneric && $this->value->isOneOf('Anchor', 'Literal', 'LiteralFolded'); |
61 | 61 | } |
62 | 62 | |
63 | - public function getTargetOnEqualIndent(NodeGeneric &$node): NodeGeneric |
|
63 | + public function getTargetOnEqualIndent(NodeGeneric&$node): NodeGeneric |
|
64 | 64 | { |
65 | 65 | if ($this->value instanceof NodeGeneric) { |
66 | 66 | if ($this->value instanceof Tag) { |
67 | - if (!preg_match("/" . Regex::TAG_URI . "/", $this->value->raw)) { |
|
67 | + if (!preg_match("/".Regex::TAG_URI."/", $this->value->raw)) { |
|
68 | 68 | return $this->value; |
69 | 69 | } |
70 | 70 | } elseif ($this->value->isAwaitingChild($node)) { |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | return is_null($this->value) ? $this->getScalar(trim($this->raw)) : $this->value->build(); |
49 | 49 | } |
50 | 50 | |
51 | - public function getTargetOnLessIndent(NodeGeneric &$node): NodeGeneric |
|
51 | + public function getTargetOnLessIndent(NodeGeneric&$node): NodeGeneric |
|
52 | 52 | { |
53 | 53 | if ($node instanceof Scalar || $node instanceof Blank) { |
54 | 54 | return $this->getParent(); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
60 | - public function getTargetOnMoreIndent(NodeGeneric &$node): NodeGeneric |
|
60 | + public function getTargetOnMoreIndent(NodeGeneric&$node): NodeGeneric |
|
61 | 61 | { |
62 | 62 | return $this->getParent(); |
63 | 63 | } |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | |
115 | 115 | public function replaceSequences($value = '') |
116 | 116 | { |
117 | - $replaceUnicodeSeq = function ($matches) { |
|
118 | - return json_decode('"' . $matches[1] . '"'); |
|
117 | + $replaceUnicodeSeq = function($matches) { |
|
118 | + return json_decode('"'.$matches[1].'"'); |
|
119 | 119 | }; |
120 | - $replaceNonPrintable = function ($matches) { |
|
121 | - return $matches[1] . ""; |
|
120 | + $replaceNonPrintable = function($matches) { |
|
121 | + return $matches[1].""; |
|
122 | 122 | }; |
123 | 123 | return preg_replace_callback_array( |
124 | 124 | [ |