@@ -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); |
@@ -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 | } |