@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function getParent(int $indent = null):Node |
67 | 67 | { |
68 | - if (!is_int($indent)){ |
|
68 | + if (!is_int($indent)) { |
|
69 | 69 | if ($this->_parent instanceof Node) { |
70 | 70 | return $this->_parent; |
71 | 71 | } else { |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | if ($this->tag) $props['tag'] = "($this->tag)"; |
216 | 216 | if ($this->value) $props['value'] = $this->value; |
217 | 217 | // $props['value'] = $this->value; |
218 | - $props['raw'] = $this->raw; |
|
218 | + $props['raw'] = $this->raw; |
|
219 | 219 | if (!$this->_parent) $props['parent'] = 'NO PARENT!!!'; |
220 | 220 | return $props; |
221 | 221 | } |
@@ -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 | } |
@@ -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) { |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | && !($child instanceof NodeDirective) |
52 | 52 | && !($child instanceof NodeBlank) |
53 | 53 | && !($child instanceof NodeDocstart |
54 | - && is_null($child->value)) ) return true; |
|
54 | + && is_null($child->value))) return true; |
|
55 | 55 | } |
56 | 56 | return false; |
57 | 57 | } |
@@ -59,12 +59,12 @@ discard block |
||
59 | 59 | public function push($node) |
60 | 60 | { |
61 | 61 | $type = null; |
62 | - if ($node instanceof NodeItem ) $type = self::SEQUENCE; |
|
62 | + if ($node instanceof NodeItem) $type = self::SEQUENCE; |
|
63 | 63 | elseif ($node instanceof NodeKey) $type = self::MAPPING; |
64 | 64 | elseif ($node instanceof NodeSetKey |
65 | 65 | || $node instanceof NodeSetValue) { |
66 | 66 | $type = self::SET; |
67 | - } elseif ($node instanceof NodeScalar ){ |
|
67 | + } elseif ($node instanceof NodeScalar) { |
|
68 | 68 | $type = self::MULTILINE; |
69 | 69 | } |
70 | 70 | if (!is_null($type) && $this->checkTypeCoherence($type)) { |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | $output = trim($first->raw); |
127 | 127 | foreach ($list as $child) { |
128 | 128 | if ($child instanceof NodeScalar) { |
129 | - $separator = isset($output[-1]) && $output[-1] === "\n" ? '' : ' '; |
|
129 | + $separator = isset($output[-1]) && $output[-1] === "\n" ? '' : ' '; |
|
130 | 130 | $output .= $separator.trim($child->raw); |
131 | 131 | } elseif ($child instanceof NodeBlank) { |
132 | 132 | $output .= "\n"; |
@@ -146,10 +146,10 @@ discard block |
||
146 | 146 | if ($child instanceof NodeComment) { |
147 | 147 | // $child->build(); |
148 | 148 | } else { |
149 | - if($child->value instanceof NodeComment) { |
|
149 | + if ($child->value instanceof NodeComment) { |
|
150 | 150 | // $child->value->build(); |
151 | 151 | // $child->value = null; |
152 | - } elseif($child->value instanceof NodeList) { |
|
152 | + } elseif ($child->value instanceof NodeList) { |
|
153 | 153 | $child->value = $child->value->filterComment(); |
154 | 154 | } |
155 | 155 | $out->push($child); |
@@ -12,7 +12,7 @@ |
||
12 | 12 | { |
13 | 13 | public function add(Node $child):Node |
14 | 14 | { |
15 | - if($this->_parent instanceof Node) { |
|
15 | + if ($this->_parent instanceof Node) { |
|
16 | 16 | return $this->_parent->add($child); |
17 | 17 | } else { |
18 | 18 | throw new \ParseError(__METHOD__." no parent to add to", 1); |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | elseif ((bool) preg_match(Regex::KEY, $trimmed, $matches)) return new NodeKey($nodeString, $line, $matches); |
22 | 22 | else { |
23 | 23 | $first = $trimmed[0]; |
24 | - $stringGroups = ["-" ,'>|' ,'"\'',"#%" ,"{[" ,":?" ,'*&!']; |
|
25 | - $methodGroups = ['Hyphen','Literal','Quoted','Special','Compact','SetElement','NodeAction']; |
|
24 | + $stringGroups = ["-", '>|', '"\'', "#%", "{[", ":?", '*&!']; |
|
25 | + $methodGroups = ['Hyphen', 'Literal', 'Quoted', 'Special', 'Compact', 'SetElement', 'NodeAction']; |
|
26 | 26 | foreach ($stringGroups as $groupIndex => $stringRef) { |
27 | 27 | if (is_int(strpos($stringRef, $first))) { |
28 | 28 | $methodName = 'on'.$methodGroups[$groupIndex]; |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | if (!((bool) preg_match(Regex::NODE_ACTIONS, trim($nodeString), $matches))) { |
128 | 128 | return new NodeScalar($nodeString, $line); |
129 | 129 | } |
130 | - $action = trim($matches['action']);//var_dump($matches); |
|
130 | + $action = trim($matches['action']); //var_dump($matches); |
|
131 | 131 | switch ($action[0]) { |
132 | - case '!': return new NodeTag ($nodeString, $line); |
|
132 | + case '!': return new NodeTag($nodeString, $line); |
|
133 | 133 | case '&': return new NodeAnchor($nodeString, $line); |
134 | 134 | case '*': return new NodeAnchor($nodeString, $line); |
135 | 135 | // default: |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | { |
34 | 34 | $reflectAPI = new \ReflectionClass(self::class); |
35 | 35 | $methodsList = []; |
36 | - $list = $reflectAPI->getMethods(RM::IS_FINAL | RM::IS_STATIC & RM::IS_PRIVATE); |
|
36 | + $list = $reflectAPI->getMethods(RM::IS_FINAL|RM::IS_STATIC & RM::IS_PRIVATE); |
|
37 | 37 | foreach ($list as $method) { |
38 | 38 | $methodsList[$method->name] = $method->getClosure(); |
39 | 39 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | // $list[] = self::strHandler($child)->raw; |
105 | 105 | $list[] = self::strHandler($child); |
106 | 106 | } |
107 | - return new NodeScalar(implode('',$list), 0); |
|
107 | + return new NodeScalar(implode('', $list), 0); |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | public static function transform(string $identifier, $value) |
172 | 172 | { |
173 | 173 | if (self::isKnown($identifier)) { |
174 | - if (!($value instanceof Node) && !($value instanceof NodeList) ) { |
|
174 | + if (!($value instanceof Node) && !($value instanceof NodeList)) { |
|
175 | 175 | throw new \Exception(sprintf(self::WRONG_VALUE, $identifier, gettype($value))); |
176 | 176 | } |
177 | 177 | return self::$registeredHandlers[$identifier]($value); |
@@ -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; |