@@ -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); |
@@ -31,14 +31,14 @@ |
||
| 31 | 31 | $result = $this->getChildValue($first, $indent); |
| 32 | 32 | foreach ($list as $child) { |
| 33 | 33 | $separator = ($result && $result[-1] === "\n") ? '' : $refSeparator; |
| 34 | - if($child->indent > $indent || $child instanceof NodeBlank) { |
|
| 34 | + if ($child->indent > $indent || $child instanceof NodeBlank) { |
|
| 35 | 35 | $separator = "\n"; |
| 36 | 36 | } |
| 37 | 37 | $val = $this->getChildValue($child, $indent); |
| 38 | 38 | if ($child->value instanceof NodeList) { |
| 39 | 39 | $val = "\n".$this->getFinalString($child->value, $indent); |
| 40 | 40 | } |
| 41 | - $result .= $separator .$val; |
|
| 41 | + $result .= $separator.$val; |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | return $result; |
@@ -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 | } |
@@ -15,10 +15,10 @@ discard block |
||
| 15 | 15 | //public |
| 16 | 16 | /* @var null|string */ |
| 17 | 17 | public static $error; |
| 18 | - public const IGNORE_DIRECTIVES = 1;//DONT include_directive |
|
| 19 | - public const IGNORE_COMMENTS = 2;//DONT include_comments |
|
| 20 | - public const NO_PARSING_EXCEPTIONS = 4;//DONT throw Exception on parsing errors |
|
| 21 | - public const NO_OBJECT_FOR_DATE = 8;//DONT import date strings as dateTime Object |
|
| 18 | + public const IGNORE_DIRECTIVES = 1; //DONT include_directive |
|
| 19 | + public const IGNORE_COMMENTS = 2; //DONT include_comments |
|
| 20 | + public const NO_PARSING_EXCEPTIONS = 4; //DONT throw Exception on parsing errors |
|
| 21 | + public const NO_OBJECT_FOR_DATE = 8; //DONT import date strings as dateTime Object |
|
| 22 | 22 | |
| 23 | 23 | //private |
| 24 | 24 | /* @var null|false|array */ |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | $previous = $target->add($node); |
| 130 | 130 | } |
| 131 | 131 | $this->attachBlankLines($previous); |
| 132 | - if ($this->_debug === 1){ |
|
| 132 | + if ($this->_debug === 1) { |
|
| 133 | 133 | return; |
| 134 | 134 | } |
| 135 | 135 | return Builder::buildContent($root, $this->_debug); |
@@ -170,8 +170,8 @@ discard block |
||
| 170 | 170 | { |
| 171 | 171 | $deepest = $previous->getDeepestNode(); |
| 172 | 172 | if ($deepest instanceof NodePartial) { |
| 173 | - return $deepest->specialProcess($current, $this->_blankBuffer); |
|
| 174 | - } elseif(!($current instanceof NodePartial)) { |
|
| 173 | + return $deepest->specialProcess($current, $this->_blankBuffer); |
|
| 174 | + } elseif (!($current instanceof NodePartial)) { |
|
| 175 | 175 | return $current->specialProcess($previous, $this->_blankBuffer); |
| 176 | 176 | } |
| 177 | 177 | return false; |
@@ -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) { |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | elseif (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 (!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: |
@@ -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); |