@@ -68,8 +68,12 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function getParent(int $indent = null, $type = 0):Node |
| 70 | 70 | { |
| 71 | - if ($this->type === Y::ROOT) return $this; |
|
| 72 | - if (!is_int($indent)) return $this->parent ?? $this; |
|
| 71 | + if ($this->type === Y::ROOT) { |
|
| 72 | + return $this; |
|
| 73 | + } |
|
| 74 | + if (!is_int($indent)) { |
|
| 75 | + return $this->parent ?? $this; |
|
| 76 | + } |
|
| 73 | 77 | $cursor = $this; |
| 74 | 78 | while ($cursor instanceof Node && $cursor->indent >= $indent) { |
| 75 | 79 | if ($cursor->indent === $indent && $cursor->type !== $type) { |
@@ -101,7 +105,7 @@ discard block |
||
| 101 | 105 | if (is_null($current)) { |
| 102 | 106 | $this->value = $child; |
| 103 | 107 | return; |
| 104 | - }elseif ($current instanceof Node) { |
|
| 108 | + } elseif ($current instanceof Node) { |
|
| 105 | 109 | if ($current->type & Y::LITTERALS) { |
| 106 | 110 | $this->value = new NodeList(); |
| 107 | 111 | $this->value->type = $current->type; |
@@ -176,12 +180,17 @@ discard block |
||
| 176 | 180 | { |
| 177 | 181 | $v = ltrim(substr($nodeValue, 1)); |
| 178 | 182 | $first = $nodeValue[0]; |
| 179 | - if ($first === "-") $this->onHyphen($nodeValue); |
|
| 180 | - elseif (in_array($first, ['"', "'"])) $this->onQuoted($nodeValue); |
|
| 181 | - elseif (in_array($first, ['{', '['])) $this->onCompact($nodeValue); |
|
| 182 | - elseif (in_array($first, ['?', ':'])) $this->onSetElement($nodeValue); |
|
| 183 | - elseif (in_array($first, ['!', '&', '*'])) $this->onNodeAction($nodeValue); |
|
| 184 | - else { |
|
| 183 | + if ($first === "-") { |
|
| 184 | + $this->onHyphen($nodeValue); |
|
| 185 | + } elseif (in_array($first, ['"', "'"])) { |
|
| 186 | + $this->onQuoted($nodeValue); |
|
| 187 | + } elseif (in_array($first, ['{', '['])) { |
|
| 188 | + $this->onCompact($nodeValue); |
|
| 189 | + } elseif (in_array($first, ['?', ':'])) { |
|
| 190 | + $this->onSetElement($nodeValue); |
|
| 191 | + } elseif (in_array($first, ['!', '&', '*'])) { |
|
| 192 | + $this->onNodeAction($nodeValue); |
|
| 193 | + } else { |
|
| 185 | 194 | $characters = [ '#' => [Y::COMMENT, $v], |
| 186 | 195 | '%' => [Y::DIRECTIVE, $v], |
| 187 | 196 | '>' => [Y::LITT_FOLDED, null], |