@@ -92,13 +92,13 @@ |
||
92 | 92 | if (Regex::isDate($v)) return self::$dateAsObject && !$onlyScalar ? date_create($v) : $v; |
93 | 93 | if (Regex::isNumber($v)) return self::getNumber($v); |
94 | 94 | $types = ['yes' => true, |
95 | - 'no' => false, |
|
96 | - 'true' => true, |
|
97 | - 'false' => false, |
|
98 | - 'null' => null, |
|
99 | - '.inf' => \INF, |
|
100 | - '-.inf' => -\INF, |
|
101 | - '.nan' => \NAN |
|
95 | + 'no' => false, |
|
96 | + 'true' => true, |
|
97 | + 'false' => false, |
|
98 | + 'null' => null, |
|
99 | + '.inf' => \INF, |
|
100 | + '-.inf' => -\INF, |
|
101 | + '.nan' => \NAN |
|
102 | 102 | ]; |
103 | 103 | return array_key_exists(strtolower($v), $types) ? $types[strtolower($v)] : $v; |
104 | 104 | } |
@@ -89,8 +89,12 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public static function getScalar(string $v, bool $onlyScalar = false) |
91 | 91 | { |
92 | - if (Regex::isDate($v)) return self::$dateAsObject && !$onlyScalar ? date_create($v) : $v; |
|
93 | - if (Regex::isNumber($v)) return self::getNumber($v); |
|
92 | + if (Regex::isDate($v)) { |
|
93 | + return self::$dateAsObject && !$onlyScalar ? date_create($v) : $v; |
|
94 | + } |
|
95 | + if (Regex::isNumber($v)) { |
|
96 | + return self::getNumber($v); |
|
97 | + } |
|
94 | 98 | $types = ['yes' => true, |
95 | 99 | 'no' => false, |
96 | 100 | 'true' => true, |
@@ -113,8 +117,12 @@ discard block |
||
113 | 117 | */ |
114 | 118 | private static function getNumber(string $v) |
115 | 119 | { |
116 | - if (preg_match(Regex::OCTAL_NUM, $v)) return intval(base_convert($v, 8, 10)); |
|
117 | - if (preg_match(Regex::HEX_NUM, $v)) return intval(base_convert($v, 16, 10)); |
|
120 | + if (preg_match(Regex::OCTAL_NUM, $v)) { |
|
121 | + return intval(base_convert($v, 8, 10)); |
|
122 | + } |
|
123 | + if (preg_match(Regex::HEX_NUM, $v)) { |
|
124 | + return intval(base_convert($v, 16, 10)); |
|
125 | + } |
|
118 | 126 | return is_bool(strpos($v, '.')) ? intval($v) : floatval($v); |
119 | 127 | } |
120 | 128 |
@@ -38,7 +38,7 @@ |
||
38 | 38 | if (is_null($this->value)) { |
39 | 39 | return null; |
40 | 40 | } else { |
41 | - if ($this->value instanceof NodeTag){ |
|
41 | + if ($this->value instanceof NodeTag) { |
|
42 | 42 | $parent->addTag($this->value->tag); |
43 | 43 | $this->value->build($parent); |
44 | 44 | } else { |
@@ -22,7 +22,7 @@ |
||
22 | 22 | $result = ''; |
23 | 23 | $list = $value->filterComment(); |
24 | 24 | if ($this->identifier !== '+') { |
25 | - self::litteralStripTrailing($list); |
|
25 | + self::litteralStripTrailing($list); |
|
26 | 26 | } |
27 | 27 | if ($list->count()) { |
28 | 28 | $list->setIteratorMode(NodeList::IT_MODE_DELETE); |
@@ -28,7 +28,7 @@ |
||
28 | 28 | if ($value instanceof NodeKey && $child instanceof NodeKey) { |
29 | 29 | if ($value->indent === $child->indent) { |
30 | 30 | return parent::add($child); |
31 | - } elseif ($value->isAwaitingChild($child)){ |
|
31 | + } elseif ($value->isAwaitingChild($child)) { |
|
32 | 32 | return $value->add($child); |
33 | 33 | } else { |
34 | 34 | // throw new \ParseError('key ('.$value->identifier.')@'.$value->line.' has already a value', 1); |
@@ -27,7 +27,7 @@ |
||
27 | 27 | public function setIdentifier(string $keyString) |
28 | 28 | { |
29 | 29 | if ($keyString === '') { |
30 | - throw new \ParseError(sprintf(self::ERROR_NO_KEYNAME, $this->line)); |
|
30 | + throw new \ParseError(sprintf(self::ERROR_NO_KEYNAME, $this->line)); |
|
31 | 31 | } else { |
32 | 32 | $keyNode = NodeFactory::get($keyString); |
33 | 33 | if (!is_null($keyNode->anchor)) { |
@@ -21,8 +21,8 @@ |
||
21 | 21 | $result = ''; |
22 | 22 | $list = $value->filterComment(); |
23 | 23 | if ($this->identifier !== '+') { |
24 | - self::litteralStripLeading($list); |
|
25 | - self::litteralStripTrailing($list); |
|
24 | + self::litteralStripLeading($list); |
|
25 | + self::litteralStripTrailing($list); |
|
26 | 26 | } |
27 | 27 | if ($list->count()) { |
28 | 28 | $refSeparator = ' '; |
@@ -31,14 +31,14 @@ |
||
31 | 31 | $result = $this->getChildValue($first, $indent); |
32 | 32 | foreach ($list as $child) { |
33 | 33 | $separator = ($result && $result[-1] === "\n") ? '' : $refSeparator; |
34 | - if($child->indent > $indent || $child instanceof NodeBlank) { |
|
34 | + if ($child->indent > $indent || $child instanceof NodeBlank) { |
|
35 | 35 | $separator = "\n"; |
36 | 36 | } |
37 | 37 | $val = $this->getChildValue($child, $indent); |
38 | 38 | if ($child->value instanceof NodeList) { |
39 | 39 | $val = "\n".$this->getFinalString($child->value, $indent); |
40 | 40 | } |
41 | - $result .= $separator .$val; |
|
41 | + $result .= $separator.$val; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | return $result; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function getParent(int $indent = null):Node |
67 | 67 | { |
68 | - if (!is_int($indent)){ |
|
68 | + if (!is_int($indent)) { |
|
69 | 69 | if ($this->_parent instanceof Node) { |
70 | 70 | return $this->_parent; |
71 | 71 | } else { |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | if ($this->tag) $props['tag'] = "($this->tag)"; |
216 | 216 | if ($this->value) $props['value'] = $this->value; |
217 | 217 | // $props['value'] = $this->value; |
218 | - $props['raw'] = $this->raw; |
|
218 | + $props['raw'] = $this->raw; |
|
219 | 219 | if (!$this->_parent) $props['parent'] = 'NO PARENT!!!'; |
220 | 220 | return $props; |
221 | 221 | } |
@@ -210,13 +210,23 @@ |
||
210 | 210 | { |
211 | 211 | $props = []; |
212 | 212 | $props['line->indent'] = "$this->line -> $this->indent"; |
213 | - if ($this->identifier) $props['identifier'] = "($this->identifier)"; |
|
214 | - if ($this->anchor) $props['anchor'] = "($this->anchor)"; |
|
215 | - if ($this->tag) $props['tag'] = "($this->tag)"; |
|
216 | - if ($this->value) $props['value'] = $this->value; |
|
213 | + if ($this->identifier) { |
|
214 | + $props['identifier'] = "($this->identifier)"; |
|
215 | + } |
|
216 | + if ($this->anchor) { |
|
217 | + $props['anchor'] = "($this->anchor)"; |
|
218 | + } |
|
219 | + if ($this->tag) { |
|
220 | + $props['tag'] = "($this->tag)"; |
|
221 | + } |
|
222 | + if ($this->value) { |
|
223 | + $props['value'] = $this->value; |
|
224 | + } |
|
217 | 225 | // $props['value'] = $this->value; |
218 | 226 | $props['raw'] = $this->raw; |
219 | - if (!$this->_parent) $props['parent'] = 'NO PARENT!!!'; |
|
227 | + if (!$this->_parent) { |
|
228 | + $props['parent'] = 'NO PARENT!!!'; |
|
229 | + } |
|
220 | 230 | return $props; |
221 | 231 | } |
222 | 232 | } |