@@ -92,13 +92,13 @@ |
||
92 | 92 | if (Regex::isDate($v)) return self::$dateAsObject && !$onlyScalar ? date_create($v) : $v; |
93 | 93 | if (Regex::isNumber($v)) return self::getNumber($v); |
94 | 94 | $types = ['yes' => true, |
95 | - 'no' => false, |
|
96 | - 'true' => true, |
|
97 | - 'false' => false, |
|
98 | - 'null' => null, |
|
99 | - '.inf' => \INF, |
|
100 | - '-.inf' => -\INF, |
|
101 | - '.nan' => \NAN |
|
95 | + 'no' => false, |
|
96 | + 'true' => true, |
|
97 | + 'false' => false, |
|
98 | + 'null' => null, |
|
99 | + '.inf' => \INF, |
|
100 | + '-.inf' => -\INF, |
|
101 | + '.nan' => \NAN |
|
102 | 102 | ]; |
103 | 103 | return array_key_exists(strtolower($v), $types) ? $types[strtolower($v)] : $v; |
104 | 104 | } |
@@ -45,7 +45,7 @@ |
||
45 | 45 | $buffer->push($child); |
46 | 46 | } |
47 | 47 | } |
48 | - $documents[] = self::buildDocument($buffer, count($documents) +1); |
|
48 | + $documents[] = self::buildDocument($buffer, count($documents) + 1); |
|
49 | 49 | } catch (\Exception|\Error|\ParseError $e) { |
50 | 50 | throw new \Exception($e->getMessage(), 1, $e); |
51 | 51 | } |
@@ -112,8 +112,12 @@ discard block |
||
112 | 112 | \.nan | \.NaN | \.NAN tag:yaml.org,2002:float (Not a number) |
113 | 113 | * tag:yaml.org,2002:str (Default) |
114 | 114 | */ |
115 | - if (Regex::isDate($v)) return self::$dateAsObject && !$onlyScalar ? date_create($v) : $v; |
|
116 | - if (Regex::isNumber($v)) return self::getNumber($v); |
|
115 | + if (Regex::isDate($v)) { |
|
116 | + return self::$dateAsObject && !$onlyScalar ? date_create($v) : $v; |
|
117 | + } |
|
118 | + if (Regex::isNumber($v)) { |
|
119 | + return self::getNumber($v); |
|
120 | + } |
|
117 | 121 | $types = ['yes' => true, |
118 | 122 | 'no' => false, |
119 | 123 | 'true' => true, |
@@ -136,8 +140,12 @@ discard block |
||
136 | 140 | */ |
137 | 141 | private static function getNumber(string $v) |
138 | 142 | { |
139 | - if ((bool) preg_match(Regex::OCTAL_NUM, $v)) return intval(base_convert($v, 8, 10)); |
|
140 | - if ((bool) preg_match(Regex::HEX_NUM, $v)) return intval(base_convert($v, 16, 10)); |
|
143 | + if ((bool) preg_match(Regex::OCTAL_NUM, $v)) { |
|
144 | + return intval(base_convert($v, 8, 10)); |
|
145 | + } |
|
146 | + if ((bool) preg_match(Regex::HEX_NUM, $v)) { |
|
147 | + return intval(base_convert($v, 16, 10)); |
|
148 | + } |
|
141 | 149 | return is_bool(strpos($v, '.')) || substr_count($v, '.') > 1 ? intval($v) : floatval($v); |
142 | 150 | } |
143 | 151 |
@@ -38,7 +38,7 @@ |
||
38 | 38 | if (is_null($this->value)) { |
39 | 39 | return null; |
40 | 40 | } else { |
41 | - if ($this->value instanceof NodeTag){ |
|
41 | + if ($this->value instanceof NodeTag) { |
|
42 | 42 | $parent->addTag($this->value->tag); |
43 | 43 | $this->value->build($parent); |
44 | 44 | } else { |
@@ -22,7 +22,7 @@ |
||
22 | 22 | $result = ''; |
23 | 23 | $list = $value->filterComment(); |
24 | 24 | if ($this->identifier !== '+') { |
25 | - self::litteralStripTrailing($list); |
|
25 | + self::litteralStripTrailing($list); |
|
26 | 26 | } |
27 | 27 | if ($list->count()) { |
28 | 28 | $list->setIteratorMode(NodeList::IT_MODE_DELETE); |
@@ -28,7 +28,7 @@ |
||
28 | 28 | if ($value instanceof NodeKey && $child instanceof NodeKey) { |
29 | 29 | if ($value->indent === $child->indent) { |
30 | 30 | return parent::add($child); |
31 | - } elseif ($value->isAwaitingChild($child)){ |
|
31 | + } elseif ($value->isAwaitingChild($child)) { |
|
32 | 32 | return $value->add($child); |
33 | 33 | } else { |
34 | 34 | // throw new \ParseError('key ('.$value->identifier.')@'.$value->line.' has already a value', 1); |
@@ -21,8 +21,8 @@ |
||
21 | 21 | $result = ''; |
22 | 22 | $list = $value->filterComment(); |
23 | 23 | if ($this->identifier !== '+') { |
24 | - self::litteralStripLeading($list); |
|
25 | - self::litteralStripTrailing($list); |
|
24 | + self::litteralStripLeading($list); |
|
25 | + self::litteralStripTrailing($list); |
|
26 | 26 | } |
27 | 27 | if ($list->count()) { |
28 | 28 | $refSeparator = ' '; |
@@ -32,10 +32,10 @@ |
||
32 | 32 | $result = $this->getChildValue($first, $indent); |
33 | 33 | foreach ($list as $child) { |
34 | 34 | $separator = ($result && $result[-1] === "\n") ? '' : $refSeparator; |
35 | - if($child->indent > $indent || $child instanceof NodeBlank) { |
|
35 | + if ($child->indent > $indent || $child instanceof NodeBlank) { |
|
36 | 36 | $separator = "\n"; |
37 | 37 | } |
38 | - $result .= $separator .$this->getChildValue($child, $indent); |
|
38 | + $result .= $separator.$this->getChildValue($child, $indent); |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | return $result; |
@@ -13,7 +13,7 @@ |
||
13 | 13 | public function __construct(string $nodeString, int $line) |
14 | 14 | { |
15 | 15 | parent::__construct($nodeString, $line); |
16 | - preg_match_all(Regex::MAPPING_VALUES, trim(substr(trim($nodeString), 1,-1)), $matches); |
|
16 | + preg_match_all(Regex::MAPPING_VALUES, trim(substr(trim($nodeString), 1, -1)), $matches); |
|
17 | 17 | foreach ($matches['k'] as $index => $property) { |
18 | 18 | $pair = $property.': '.trim($matches['v'][$index]); |
19 | 19 | $child = NodeFactory::get($pair, $line); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | public function add(Node $child):Node |
54 | 54 | { |
55 | - if ($this->value instanceof Node && Yaml::isOneOf($this->value, ['NodeLit','NodeLitFolded', 'NodeAnchor'])) { |
|
55 | + if ($this->value instanceof Node && Yaml::isOneOf($this->value, ['NodeLit', 'NodeLitFolded', 'NodeAnchor'])) { |
|
56 | 56 | return $this->value->add($child); |
57 | 57 | } else { |
58 | 58 | return parent::add($child); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | if ($current instanceof NodeComment) { |
88 | 88 | return true; |
89 | 89 | } |
90 | - if($current instanceof NodeScalar) { |
|
90 | + if ($current instanceof NodeScalar) { |
|
91 | 91 | return Yaml::isOneOf($node, ['NodeScalar', 'NodeBlank']); |
92 | 92 | } |
93 | 93 | if ($current instanceof NodeItem) { |
@@ -33,7 +33,7 @@ |
||
33 | 33 | public function setIdentifier(string $keyString) |
34 | 34 | { |
35 | 35 | if ($keyString === '') { |
36 | - throw new \ParseError(sprintf(self::ERROR_NO_KEYNAME, $this->line)); |
|
36 | + throw new \ParseError(sprintf(self::ERROR_NO_KEYNAME, $this->line)); |
|
37 | 37 | } else { |
38 | 38 | $keyNode = NodeFactory::get($keyString); |
39 | 39 | if ($keyNode instanceof NodeTag || $keyNode instanceof NodeQuoted) { |
@@ -25,7 +25,9 @@ |
||
25 | 25 | |
26 | 26 | public function add(Node $child):Node |
27 | 27 | { |
28 | - if (is_null($this->value)) $this->value = new NodeList(); |
|
28 | + if (is_null($this->value)) { |
|
29 | + $this->value = new NodeList(); |
|
30 | + } |
|
29 | 31 | $candidate = $child; |
30 | 32 | if (!Yaml::isOneOf($child, ['NodeScalar', 'NodeBlank', 'NodeComment', 'NodeQuoted'])) { |
31 | 33 | $candidate = new NodeScalar((string) $child->raw, $child->line); |
@@ -107,7 +107,9 @@ |
||
107 | 107 | { |
108 | 108 | foreach ($comparison as $className) { |
109 | 109 | $fqn = __NAMESPACE__."\\Yaml\\$className"; |
110 | - if ($subject instanceof $fqn) return true; |
|
110 | + if ($subject instanceof $fqn) { |
|
111 | + return true; |
|
112 | + } |
|
111 | 113 | } |
112 | 114 | return false; |
113 | 115 | } |