@@ -74,7 +74,7 @@ |
||
| 74 | 74 | switch (gettype($dataType)) { |
| 75 | 75 | case 'boolean': return $dataType ? 'true' : 'false'; |
| 76 | 76 | case 'float': if (is_infinite($dataType)) return $dataType > 0 ? '.inf' : '-.inf'; |
| 77 | - return sprintf('%.2F', $dataType); |
|
| 77 | + return sprintf('%.2F', $dataType); |
|
| 78 | 78 | case 'double': if (is_nan((float) $dataType)) return '.nan'; |
| 79 | 79 | default: |
| 80 | 80 | return $dataType; |
@@ -102,6 +102,9 @@ |
||
| 102 | 102 | //TODO: $references = $dataType->getAllReferences(); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | + /** |
|
| 106 | + * @param integer $indent |
|
| 107 | + */ |
|
| 105 | 108 | private static function add($value, $indent) |
| 106 | 109 | { |
| 107 | 110 | $newVal = str_repeat(" ", $indent).$value; |
@@ -162,11 +162,11 @@ |
||
| 162 | 162 | } |
| 163 | 163 | if ($type & Y::COMMENT) self::$_root->addComment($node->line, $node->value); |
| 164 | 164 | $typesActions = [Y::DIRECTIVE => 'buildDirective', |
| 165 | - Y::ITEM => 'buildItem', |
|
| 166 | - Y::KEY => 'buildKey', |
|
| 167 | - Y::SET_KEY => 'buildSetKey', |
|
| 168 | - Y::SET_VALUE => 'buildSetValue', |
|
| 169 | - Y::TAG => 'buildTag', |
|
| 165 | + Y::ITEM => 'buildItem', |
|
| 166 | + Y::KEY => 'buildKey', |
|
| 167 | + Y::SET_KEY => 'buildSetKey', |
|
| 168 | + Y::SET_VALUE => 'buildSetValue', |
|
| 169 | + Y::TAG => 'buildTag', |
|
| 170 | 170 | ]; |
| 171 | 171 | if (isset($typesActions[$type])) { |
| 172 | 172 | return self::{$typesActions[$type]}($node, $parent); |
@@ -238,7 +238,6 @@ |
||
| 238 | 238 | /** |
| 239 | 239 | * Builds a litteral (folded or not) or any NodeList that has YAML::RAW type (like a multiline value) |
| 240 | 240 | * |
| 241 | - * @param NodeList $children The children |
|
| 242 | 241 | * @param integer $type The type |
| 243 | 242 | * |
| 244 | 243 | * @return string The litteral. |
@@ -37,6 +37,9 @@ discard block |
||
| 37 | 37 | private const EXCEPTION_READ_ERROR = self::class.": file '%s' failed to be loaded (permission denied ?)"; |
| 38 | 38 | private const EXCEPTION_LINE_SPLIT = self::class.": content is not a string(maybe a file error?)"; |
| 39 | 39 | |
| 40 | + /** |
|
| 41 | + * @param string $absolutePath |
|
| 42 | + */ |
|
| 40 | 43 | public function __construct($absolutePath = null, $options = null, $debug = 0) |
| 41 | 44 | { |
| 42 | 45 | $this->debug = is_int($debug) ? min($debug, 3) : 1; |
@@ -73,6 +76,9 @@ discard block |
||
| 73 | 76 | return $this; |
| 74 | 77 | } |
| 75 | 78 | |
| 79 | + /** |
|
| 80 | + * @param string $strContent |
|
| 81 | + */ |
|
| 76 | 82 | private function getSourceIterator($strContent = null) |
| 77 | 83 | { |
| 78 | 84 | $source = $this->content ?? preg_split("/\n/m", preg_replace('/(\r\n|\r)/', "\n", $strContent), 0, PREG_SPLIT_DELIM_CAPTURE); |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | if ($n->type & (Y::REF_CALL|Y::SCALAR)) return self::getScalar((string) $n->value); |
| 28 | 28 | if ($n->type & Y::JSON) return $n->value; |
| 29 | 29 | $expected = [Y::QUOTED => trim((string) $n->value, "\"'"), |
| 30 | - Y::RAW => strval((string) $n->value)]; |
|
| 30 | + Y::RAW => strval((string) $n->value)]; |
|
| 31 | 31 | return $expected[$n->type] ?? null; |
| 32 | 32 | } |
| 33 | 33 | |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * Create the Node object and parses $nodeString IF not null (else assume a root type Node) |
| 33 | 33 | * |
| 34 | 34 | * @param string|null $nodeString The node string |
| 35 | - * @param int|null $line The line |
|
| 35 | + * @param integer $line The line |
|
| 36 | 36 | */ |
| 37 | 37 | public function __construct($nodeString = null, $line = 0) |
| 38 | 38 | { |
@@ -200,12 +200,18 @@ discard block |
||
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | + /** |
|
| 204 | + * @param string $nodeValue |
|
| 205 | + */ |
|
| 203 | 206 | private function onQuoted($nodeValue) |
| 204 | 207 | { |
| 205 | 208 | $this->type = R::isProperlyQuoted($nodeValue) ? Y::QUOTED : Y::PARTIAL; |
| 206 | 209 | $this->value = $nodeValue; |
| 207 | 210 | } |
| 208 | 211 | |
| 212 | + /** |
|
| 213 | + * @param string $nodeValue |
|
| 214 | + */ |
|
| 209 | 215 | private function onSetElement($nodeValue) |
| 210 | 216 | { |
| 211 | 217 | $this->type = $nodeValue[0] === '?' ? Y::SET_KEY : Y::SET_VALUE; |
@@ -220,7 +226,7 @@ discard block |
||
| 220 | 226 | * Process when a "key: value" syntax is found in the parsed string |
| 221 | 227 | * Note : key is match 1, value is match 2 as per regex from R::KEY |
| 222 | 228 | * |
| 223 | - * @param array $matches The matches provided by 'preg_match' function in Node::parse |
|
| 229 | + * @param string[] $matches The matches provided by 'preg_match' function in Node::parse |
|
| 224 | 230 | */ |
| 225 | 231 | private function onKey(array $matches) |
| 226 | 232 | { |