@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | private static function buildNodeList(NodeList $node, &$parent) |
30 | 30 | { |
31 | 31 | $type = &$node->type; |
32 | - if ($type & (Y::RAW | Y::LITTERALS)) { |
|
32 | + if ($type&(Y::RAW|Y::LITTERALS)) { |
|
33 | 33 | return self::litteral($node, $type); |
34 | 34 | } |
35 | 35 | $p = $parent; |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | private static function buildNode(Node $node, &$parent) |
57 | 57 | { |
58 | 58 | extract((array) $node, EXTR_REFS); |
59 | - if ($type & (Y::REF_DEF | Y::REF_CALL)) { |
|
59 | + if ($type&(Y::REF_DEF|Y::REF_CALL)) { |
|
60 | 60 | if (is_object($value)) { |
61 | 61 | $tmp = self::build($value, $parent) ?? $parent; |
62 | 62 | } else { |
@@ -176,15 +176,15 @@ discard block |
||
176 | 176 | { |
177 | 177 | self::$_root = new YamlObject(); |
178 | 178 | $childTypes = $list->getTypes(); |
179 | - $isMapping = (bool) (Y::KEY | Y::MAPPING) & $childTypes; |
|
179 | + $isMapping = (bool) (Y::KEY|Y::MAPPING)&$childTypes; |
|
180 | 180 | $isSequence = (bool) Y::ITEM & $childTypes; |
181 | 181 | $isSet = (bool) Y::SET_VALUE & $childTypes; |
182 | 182 | if ($isMapping && $isSequence) { |
183 | 183 | throw new \ParseError(sprintf(self::INVALID_DOCUMENT, $key)); |
184 | 184 | } else { |
185 | 185 | switch (true) { |
186 | - case $isSequence: $list->type = Y::SEQUENCE;break; |
|
187 | - case $isSet: $list->type = Y::SET;break; |
|
186 | + case $isSequence: $list->type = Y::SEQUENCE; break; |
|
187 | + case $isSet: $list->type = Y::SET; break; |
|
188 | 188 | default: $list->type = Y::MAPPING; |
189 | 189 | } |
190 | 190 | } |
@@ -206,11 +206,11 @@ discard block |
||
206 | 206 | $children->rewind(); |
207 | 207 | $refIndent = $children->current()->indent; |
208 | 208 | $separator = $type === Y::RAW ? '' : "\n"; |
209 | - $action = function ($c) { return (string) $c->value; }; |
|
209 | + $action = function($c) { return (string) $c->value; }; |
|
210 | 210 | //TODO: use iterator_to_array for LITT & RAW |
211 | - if ($type & Y::LITT_FOLDED) { |
|
211 | + if ($type&Y::LITT_FOLDED) { |
|
212 | 212 | $separator = ' '; |
213 | - $action = function ($c) use ($refIndent) { |
|
213 | + $action = function($c) use ($refIndent) { |
|
214 | 214 | return $c->indent > $refIndent || ($c->type & Y::BLANK) ? "\n".$c->value : $c->value; |
215 | 215 | }; |
216 | 216 | } |
@@ -19,17 +19,17 @@ discard block |
||
19 | 19 | /* @var null|string */ |
20 | 20 | public $error; |
21 | 21 | |
22 | - public const EXCLUDE_DIRECTIVES = 1;//DONT include_directive |
|
23 | - public const IGNORE_COMMENTS = 2;//DONT include_comments |
|
24 | - public const NO_PARSING_EXCEPTIONS = 4;//THROW Exception on parsing Errors |
|
25 | - public const NO_OBJECT_FOR_DATE = 8;//DONT import date strings as dateTime Object |
|
22 | + public const EXCLUDE_DIRECTIVES = 1; //DONT include_directive |
|
23 | + public const IGNORE_COMMENTS = 2; //DONT include_comments |
|
24 | + public const NO_PARSING_EXCEPTIONS = 4; //THROW Exception on parsing Errors |
|
25 | + public const NO_OBJECT_FOR_DATE = 8; //DONT import date strings as dateTime Object |
|
26 | 26 | //privates |
27 | 27 | /* @var null|string */ |
28 | 28 | private $content; |
29 | 29 | /* @var null|string */ |
30 | 30 | private $filePath; |
31 | 31 | /* @var integer */ |
32 | - private $debug = 0;///TODO: determine levels |
|
32 | + private $debug = 0; ///TODO: determine levels |
|
33 | 33 | /* @var integer */ |
34 | 34 | private $options = 0; |
35 | 35 | //Exceptions messages |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $previous = $root = new Node(); |
92 | 92 | $emptyLines = []; |
93 | 93 | try { |
94 | - $gen = function () use($source) { |
|
94 | + $gen = function() use($source) { |
|
95 | 95 | foreach ($source as $key => $value) { |
96 | 96 | yield ++$key => $value; |
97 | 97 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $target->add($n); |
118 | 118 | $previous = $n; |
119 | 119 | } |
120 | - if ($this->debug === 2) echo "\033[33mParsed Structure\033[0m\n",var_export($root, true); |
|
120 | + if ($this->debug === 2) echo "\033[33mParsed Structure\033[0m\n", var_export($root, true); |
|
121 | 121 | $out = Builder::buildContent($root, $this->debug); |
122 | 122 | return $out; |
123 | 123 | } catch (\Error|\Exception|\ParseError $e) { |
@@ -263,8 +263,8 @@ discard block |
||
263 | 263 | { |
264 | 264 | $v = &$this->value; |
265 | 265 | if (is_null($v)) return null; |
266 | - if ($this->type & (Y::REF_CALL | Y::SCALAR)) return self::getScalar($v); |
|
267 | - if ($this->type & (Y::COMPACT_MAPPING | Y::COMPACT_SEQUENCE)) return self::getCompact(substr($v, 1, -1), $this->type); |
|
266 | + if ($this->type & (Y::REF_CALL|Y::SCALAR)) return self::getScalar($v); |
|
267 | + if ($this->type & (Y::COMPACT_MAPPING|Y::COMPACT_SEQUENCE)) return self::getCompact(substr($v, 1, -1), $this->type); |
|
268 | 268 | switch ($this->type) { |
269 | 269 | case Y::JSON: return json_decode($v, false, 512, JSON_PARTIAL_OUTPUT_ON_ERROR); |
270 | 270 | case Y::QUOTED: return substr($v, 1, -1); |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | { |
321 | 321 | $out = new Compact(); |
322 | 322 | if ($type === Y::COMPACT_SEQUENCE) { |
323 | - $f = function ($e) { return self::getScalar(trim($e));}; |
|
323 | + $f = function($e) { return self::getScalar(trim($e)); }; |
|
324 | 324 | //TODO : that's not robust enough, improve it |
325 | 325 | foreach (array_map($f, explode(",", $mappingOrSeqString)) as $key => $value) { |
326 | 326 | $out[$key] = $value; |
@@ -32,7 +32,7 @@ |
||
32 | 32 | public function __call($funcName, $arguments) |
33 | 33 | { |
34 | 34 | $reflectAPI = new \ReflectionClass(get_class($this->__yaml__object__api)); |
35 | - $getName = function ($o) { return $o->name; }; |
|
35 | + $getName = function($o) { return $o->name; }; |
|
36 | 36 | $publicApi = array_map($getName, $reflectAPI->getMethods(\ReflectionMethod::IS_PUBLIC)); |
37 | 37 | $privateApi = array_map($getName, $reflectAPI->getMethods(\ReflectionMethod::IS_PRIVATE)); |
38 | 38 | if (!in_array($funcName, $publicApi) && !in_array($funcName, $privateApi)) { |