@@ -77,7 +77,9 @@ discard block |
||
| 77 | 77 | { |
| 78 | 78 | $source = $this->content ?? preg_split("/\n/m", preg_replace('/(\r\n|\r)/', "\n", $strContent), 0, PREG_SPLIT_DELIM_CAPTURE); |
| 79 | 79 | //TODO : be more permissive on $strContent values |
| 80 | - if (!is_array($source) || !count($source)) throw new \Exception(self::EXCEPTION_LINE_SPLIT); |
|
| 80 | + if (!is_array($source) || !count($source)) { |
|
| 81 | + throw new \Exception(self::EXCEPTION_LINE_SPLIT); |
|
| 82 | + } |
|
| 81 | 83 | return function () use($source) { |
| 82 | 84 | foreach ($source as $key => $value) { |
| 83 | 85 | yield ++$key => $value; |
@@ -105,7 +107,9 @@ discard block |
||
| 105 | 107 | try { |
| 106 | 108 | foreach ($sourceIterator() as $lineNb => $lineString) { |
| 107 | 109 | $n = new Node($lineString, $lineNb); |
| 108 | - if ($this->onSpecialType($n, $previous, $emptyLines, $lineString)) continue; |
|
| 110 | + if ($this->onSpecialType($n, $previous, $emptyLines, $lineString)) { |
|
| 111 | + continue; |
|
| 112 | + } |
|
| 109 | 113 | $this->attachBlankLines($emptyLines, $previous); |
| 110 | 114 | $emptyLines = []; |
| 111 | 115 | $target = $previous; |
@@ -117,7 +121,9 @@ discard block |
||
| 117 | 121 | default: |
| 118 | 122 | $this->onMoreIndent($previous, $target); |
| 119 | 123 | } |
| 120 | - if ($this->onContextType($n, $target, $lineString)) continue; |
|
| 124 | + if ($this->onContextType($n, $target, $lineString)) { |
|
| 125 | + continue; |
|
| 126 | + } |
|
| 121 | 127 | $target->add($n); |
| 122 | 128 | $previous = $n; |
| 123 | 129 | } |
@@ -200,8 +206,12 @@ discard block |
||
| 200 | 206 | |
| 201 | 207 | private function onSpecialBlank(array &$emptyLines, Node $n, Node $previous, Node $deepest) |
| 202 | 208 | { |
| 203 | - if ($previous->type & Y::SCALAR) $emptyLines[] = $n->setParent($previous->getParent()); |
|
| 204 | - if ($deepest->type & Y::LITTERALS) $emptyLines[] = $n->setParent($deepest); |
|
| 209 | + if ($previous->type & Y::SCALAR) { |
|
| 210 | + $emptyLines[] = $n->setParent($previous->getParent()); |
|
| 211 | + } |
|
| 212 | + if ($deepest->type & Y::LITTERALS) { |
|
| 213 | + $emptyLines[] = $n->setParent($deepest); |
|
| 214 | + } |
|
| 205 | 215 | } |
| 206 | 216 | |
| 207 | 217 | private function onContextType(Node &$n, Node &$previous, $lineString):bool |