@@ -261,8 +261,8 @@ |
||
| 261 | 261 | if ($this->type & (Y::REF_CALL | Y::SCALAR)) return self::getScalar($v); |
| 262 | 262 | if ($this->type & (Y::COMPACT_MAPPING | Y::COMPACT_SEQUENCE)) return self::getCompact(substr($v, 1, -1), $this->type); |
| 263 | 263 | $expected = [Y::JSON => json_decode($v, false, 512, JSON_PARTIAL_OUTPUT_ON_ERROR), |
| 264 | - Y::QUOTED => substr($v, 1, -1), |
|
| 265 | - Y::RAW => strval($v)]; |
|
| 264 | + Y::QUOTED => substr($v, 1, -1), |
|
| 265 | + Y::RAW => strval($v)]; |
|
| 266 | 266 | if (isset($expected[$this->type])) { |
| 267 | 267 | return $expected[$this->type]; |
| 268 | 268 | } |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | } |
| 89 | 89 | $this->value->push($child); |
| 90 | 90 | //modify type according to child |
| 91 | - if ($child->type & (Y::COMMENT | Y::KEY)) $this->value->type = Y::MAPPING; |
|
| 91 | + if ($child->type & (Y::COMMENT|Y::KEY)) $this->value->type = Y::MAPPING; |
|
| 92 | 92 | if ($child->type & Y::ITEM) $this->value->type = Y::SEQUENCE; |
| 93 | 93 | if ($this->type & Y::LITTERALS) $this->value->type = $this->type; |
| 94 | 94 | } |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | if (in_array($first, ['{', '['])) return $this->onObject($nodeValue); |
| 147 | 147 | if (in_array($first, ['!', '&', '*'])) return $this->onNodeAction($nodeValue); |
| 148 | 148 | // Note : php don't like '?' as an array key -_- |
| 149 | - if($first === '?') return [Y::SET_KEY, empty($v) ? null : new Node(ltrim($v), $this->line)]; |
|
| 150 | - $characters = [ '#' => [Y::COMMENT, ltrim($v)], |
|
| 149 | + if ($first === '?') return [Y::SET_KEY, empty($v) ? null : new Node(ltrim($v), $this->line)]; |
|
| 150 | + $characters = ['#' => [Y::COMMENT, ltrim($v)], |
|
| 151 | 151 | "-" => $this->onHyphen($nodeValue), |
| 152 | 152 | '%' => [Y::DIRECTIVE, ltrim($v)], |
| 153 | 153 | ':' => [Y::SET_VALUE, empty($v) ? null : new Node(ltrim($v), $this->line)], |
@@ -258,8 +258,8 @@ discard block |
||
| 258 | 258 | { |
| 259 | 259 | $v = &$this->value; |
| 260 | 260 | if (is_null($v)) return null; |
| 261 | - if ($this->type & (Y::REF_CALL | Y::SCALAR)) return self::getScalar($v); |
|
| 262 | - if ($this->type & (Y::COMPACT_MAPPING | Y::COMPACT_SEQUENCE)) return self::getCompact(substr($v, 1, -1), $this->type); |
|
| 261 | + if ($this->type & (Y::REF_CALL|Y::SCALAR)) return self::getScalar($v); |
|
| 262 | + if ($this->type & (Y::COMPACT_MAPPING|Y::COMPACT_SEQUENCE)) return self::getCompact(substr($v, 1, -1), $this->type); |
|
| 263 | 263 | $expected = [Y::JSON => json_decode($v, false, 512, JSON_PARTIAL_OUTPUT_ON_ERROR), |
| 264 | 264 | Y::QUOTED => substr($v, 1, -1), |
| 265 | 265 | Y::RAW => strval($v)]; |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | { |
| 313 | 313 | $out = new Compact(); |
| 314 | 314 | if ($type === Y::COMPACT_SEQUENCE) { |
| 315 | - $f = function ($e) { return self::getScalar(trim($e));}; |
|
| 315 | + $f = function($e) { return self::getScalar(trim($e)); }; |
|
| 316 | 316 | //TODO : that's not robust enough, improve it |
| 317 | 317 | foreach (array_map($f, explode(",", $mappingOrSeqString)) as $key => $value) { |
| 318 | 318 | $out[$key] = $value; |
@@ -65,12 +65,12 @@ |
||
| 65 | 65 | return self::$_root->getReference($identifier); |
| 66 | 66 | } |
| 67 | 67 | $typesActions = [Y::COMMENT => 'buildComment', |
| 68 | - Y::DIRECTIVE => 'buildDirective', |
|
| 69 | - Y::ITEM => 'buildItem', |
|
| 70 | - Y::KEY => 'buildKey', |
|
| 71 | - Y::SET_KEY => 'buildSetKey', |
|
| 72 | - Y::SET_VALUE => 'buildSetValue', |
|
| 73 | - Y::TAG => 'buildTag', |
|
| 68 | + Y::DIRECTIVE => 'buildDirective', |
|
| 69 | + Y::ITEM => 'buildItem', |
|
| 70 | + Y::KEY => 'buildKey', |
|
| 71 | + Y::SET_KEY => 'buildSetKey', |
|
| 72 | + Y::SET_VALUE => 'buildSetValue', |
|
| 73 | + Y::TAG => 'buildTag', |
|
| 74 | 74 | ]; |
| 75 | 75 | if (isset($typesActions[$type])) { |
| 76 | 76 | return self::{$typesActions[$type]}($node, $parent); |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | private static function buildNodeList(NodeList $node, &$parent) |
| 30 | 30 | { |
| 31 | - if ($node->type & (Y::RAW | Y::LITTERALS)) { |
|
| 31 | + if ($node->type & (Y::RAW|Y::LITTERALS)) { |
|
| 32 | 32 | return self::buildLitteral($node, $node->type); |
| 33 | 33 | } |
| 34 | 34 | $p = $parent; |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | private static function buildNode(Node $node, &$parent) |
| 56 | 56 | { |
| 57 | 57 | extract((array) $node, EXTR_REFS); |
| 58 | - if ($type & (Y::REF_DEF | Y::REF_CALL)) { |
|
| 58 | + if ($type&(Y::REF_DEF|Y::REF_CALL)) { |
|
| 59 | 59 | if (is_object($value)) { |
| 60 | 60 | $tmp = self::build($value, $parent) ?? $parent; |
| 61 | 61 | } else { |
@@ -151,15 +151,15 @@ discard block |
||
| 151 | 151 | { |
| 152 | 152 | self::$_root = new YamlObject(); |
| 153 | 153 | $childTypes = $list->getTypes(); |
| 154 | - $isaMapping = (bool) (Y::KEY | Y::MAPPING) & $childTypes; |
|
| 154 | + $isaMapping = (bool) (Y::KEY|Y::MAPPING)&$childTypes; |
|
| 155 | 155 | $isaSequence = (bool) Y::ITEM & $childTypes; |
| 156 | 156 | $isaSet = (bool) Y::SET_VALUE & $childTypes; |
| 157 | 157 | if ($isaMapping && $isaSequence) { |
| 158 | 158 | throw new \ParseError(sprintf(self::INVALID_DOCUMENT, $key)); |
| 159 | 159 | } else { |
| 160 | 160 | switch (true) { |
| 161 | - case $isaSequence: $list->type = Y::SEQUENCE;break; |
|
| 162 | - case $isaSet: $list->type = Y::SET;break; |
|
| 161 | + case $isaSequence: $list->type = Y::SEQUENCE; break; |
|
| 162 | + case $isaSet: $list->type = Y::SET; break; |
|
| 163 | 163 | default: $list->type = Y::MAPPING; |
| 164 | 164 | } |
| 165 | 165 | } |
@@ -186,15 +186,15 @@ discard block |
||
| 186 | 186 | $lines[] = self::buildLitteral($child->value, $type); |
| 187 | 187 | } else { |
| 188 | 188 | $prefix = ''; |
| 189 | - if ($type & Y::LITT_FOLDED && ($child->indent > $refIndent || ($child->type & Y::BLANK))) { |
|
| 189 | + if ($type&Y::LITT_FOLDED && ($child->indent > $refIndent || ($child->type & Y::BLANK))) { |
|
| 190 | 190 | $prefix = "\n"; |
| 191 | 191 | } |
| 192 | 192 | $lines[] = $prefix.$child->value; |
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | - if ($type & Y::RAW) return implode('', $lines); |
|
| 196 | - if ($type & Y::LITT) return implode("\n", $lines); |
|
| 197 | - if ($type & Y::LITT_FOLDED) return implode(' ', $lines); |
|
| 195 | + if ($type&Y::RAW) return implode('', $lines); |
|
| 196 | + if ($type&Y::LITT) return implode("\n", $lines); |
|
| 197 | + if ($type&Y::LITT_FOLDED) return implode(' ', $lines); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | private function buildSetKey(Node $node, $parent):void |