@@ -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 = ' '; |
@@ -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; |
@@ -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; |
@@ -93,7 +93,9 @@ discard block |
||
93 | 93 | { |
94 | 94 | $source = $this->content ?? preg_split("/\n/m", preg_replace('/(\r\n|\r)/', "\n", $strContent), 0, PREG_SPLIT_DELIM_CAPTURE); |
95 | 95 | //TODO : be more permissive on $strContent values |
96 | - if (!is_array($source) || !count($source)) throw new \Exception(self::EXCEPTION_LINE_SPLIT); |
|
96 | + if (!is_array($source) || !count($source)) { |
|
97 | + throw new \Exception(self::EXCEPTION_LINE_SPLIT); |
|
98 | + } |
|
97 | 99 | foreach ($source as $key => $value) { |
98 | 100 | yield ++$key => $value; |
99 | 101 | } |
@@ -116,8 +118,12 @@ discard block |
||
116 | 118 | try { |
117 | 119 | foreach ($generator as $lineNb => $lineString) { |
118 | 120 | $node = NodeFactory::get($lineString, $lineNb); |
119 | - if ($this->_debug === 1) echo get_class($node)."\n"; |
|
120 | - if ($this->needsSpecialProcess($node, $previous)) continue; |
|
121 | + if ($this->_debug === 1) { |
|
122 | + echo get_class($node)."\n"; |
|
123 | + } |
|
124 | + if ($this->needsSpecialProcess($node, $previous)) { |
|
125 | + continue; |
|
126 | + } |
|
121 | 127 | $this->attachBlankLines($previous); |
122 | 128 | switch ($node->indent <=> $previous->indent) { |
123 | 129 | case -1: $target = $previous->getTargetOnLessIndent($node); |