@@ -130,8 +130,12 @@ |
||
| 130 | 130 | try { |
| 131 | 131 | foreach ($generator as $lineNB => $lineString) { |
| 132 | 132 | $node = NodeFactory::get($lineString, $lineNB); |
| 133 | - if ($this->_debug === 1) echo get_class($node)."\n"; |
|
| 134 | - if ($this->needsSpecialProcess($node, $previous)) continue; |
|
| 133 | + if ($this->_debug === 1) { |
|
| 134 | + echo get_class($node)."\n"; |
|
| 135 | + } |
|
| 136 | + if ($this->needsSpecialProcess($node, $previous)) { |
|
| 137 | + continue; |
|
| 138 | + } |
|
| 135 | 139 | $this->_attachBlankLines($previous); |
| 136 | 140 | switch ($node->indent <=> $previous->indent) { |
| 137 | 141 | case -1: $target = $previous->getTargetOnLessIndent($node); |
@@ -96,8 +96,12 @@ discard block |
||
| 96 | 96 | \.nan | \.NaN | \.NAN tag:yaml.org,2002:float (Not a number) |
| 97 | 97 | * tag:yaml.org,2002:str (Default) |
| 98 | 98 | */ |
| 99 | - if (Regex::isDate($v)) return Builder::$dateAsObject && !$onlyScalar ? date_create($v) : $v; |
|
| 100 | - if (Regex::isNumber($v)) return self::getNumber($v); |
|
| 99 | + if (Regex::isDate($v)) { |
|
| 100 | + return Builder::$dateAsObject && !$onlyScalar ? date_create($v) : $v; |
|
| 101 | + } |
|
| 102 | + if (Regex::isNumber($v)) { |
|
| 103 | + return self::getNumber($v); |
|
| 104 | + } |
|
| 101 | 105 | $types = ['yes' => true, |
| 102 | 106 | 'no' => false, |
| 103 | 107 | 'true' => true, |
@@ -141,8 +145,12 @@ discard block |
||
| 141 | 145 | */ |
| 142 | 146 | private static function getNumber(string $v) |
| 143 | 147 | { |
| 144 | - if ((bool) preg_match(Regex::OCTAL_NUM, $v)) return intval(base_convert($v, 8, 10)); |
|
| 145 | - if ((bool) preg_match(Regex::HEX_NUM, $v)) return intval(base_convert($v, 16, 10)); |
|
| 148 | + if ((bool) preg_match(Regex::OCTAL_NUM, $v)) { |
|
| 149 | + return intval(base_convert($v, 8, 10)); |
|
| 150 | + } |
|
| 151 | + if ((bool) preg_match(Regex::HEX_NUM, $v)) { |
|
| 152 | + return intval(base_convert($v, 16, 10)); |
|
| 153 | + } |
|
| 146 | 154 | return is_bool(strpos($v, '.')) || substr_count($v, '.') > 1 ? intval($v) : floatval($v); |
| 147 | 155 | } |
| 148 | 156 | |