@@ -70,7 +70,9 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public static function build(object $node, &$parent = null) |
| 72 | 72 | { |
| 73 | - if ($node instanceof NodeList) return self::buildNodeList($node, $parent); |
|
| 73 | + if ($node instanceof NodeList) { |
|
| 74 | + return self::buildNodeList($node, $parent); |
|
| 75 | + } |
|
| 74 | 76 | return self::buildNode($node, $parent); |
| 75 | 77 | } |
| 76 | 78 | |
@@ -164,7 +166,9 @@ discard block |
||
| 164 | 166 | $list->rewind(); |
| 165 | 167 | $refIndent = $list->current()->indent; |
| 166 | 168 | //remove trailing blank |
| 167 | - while ($list->top()->type & Y::BLANK) $list->pop(); |
|
| 169 | + while ($list->top()->type & Y::BLANK) { |
|
| 170 | + $list->pop(); |
|
| 171 | + } |
|
| 168 | 172 | $result = ''; |
| 169 | 173 | $separator = [ Y::RAW => '', Y::LITT => "\n", Y::LITT_FOLDED => ' '][$type]; |
| 170 | 174 | foreach ($list as $child) { |
@@ -181,10 +185,12 @@ discard block |
||
| 181 | 185 | { |
| 182 | 186 | $val = $child->type & (Y::SCALAR) ? $child->value : substr($child->raw, $refIndent); |
| 183 | 187 | if ($type & Y::LITT_FOLDED && ($child->indent > $refIndent || ($child->type & Y::BLANK))) { |
| 184 | - if ($result[-1] === $separator) |
|
| 185 | - $result[-1] = "\n"; |
|
| 186 | - if ($result[-1] === "\n") |
|
| 187 | - $result .= $val; |
|
| 188 | + if ($result[-1] === $separator) { |
|
| 189 | + $result[-1] = "\n"; |
|
| 190 | + } |
|
| 191 | + if ($result[-1] === "\n") { |
|
| 192 | + $result .= $val; |
|
| 193 | + } |
|
| 188 | 194 | return; |
| 189 | 195 | } |
| 190 | 196 | $result .= $val.$separator; |
@@ -17,7 +17,9 @@ discard block |
||
| 17 | 17 | public static function buildReference($node, $parent) |
| 18 | 18 | { |
| 19 | 19 | $tmp = is_null($node->value) ? null : Builder::build($node->value, $parent); |
| 20 | - if ($node->type === Y::REF_DEF) Builder::$_root->addReference($node->identifier, $tmp); |
|
| 20 | + if ($node->type === Y::REF_DEF) { |
|
| 21 | + Builder::$_root->addReference($node->identifier, $tmp); |
|
| 22 | + } |
|
| 21 | 23 | return Builder::$_root->getReference($node->identifier); |
| 22 | 24 | } |
| 23 | 25 | |
@@ -104,7 +106,9 @@ discard block |
||
| 104 | 106 | $built = is_object($node->value) ? Builder::build($node->value) : null; |
| 105 | 107 | $stringKey = is_string($built) && Regex::isProperlyQuoted($built) ? trim($built, '\'" '): $built; |
| 106 | 108 | $key = json_encode($stringKey, JSON_PARTIAL_OUTPUT_ON_ERROR|JSON_UNESCAPED_SLASHES); |
| 107 | - if (empty($key)) throw new \Exception("Cant serialize complex key: ".var_export($node->value, true), 1); |
|
| 109 | + if (empty($key)) { |
|
| 110 | + throw new \Exception("Cant serialize complex key: ".var_export($node->value, true), 1); |
|
| 111 | + } |
|
| 108 | 112 | $parent->{trim($key, '\'" ')} = null; |
| 109 | 113 | } |
| 110 | 114 | |