| Conditions | 5 |
| Paths | 1 |
| Total Lines | 36 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | protected function runVariableMacro(string & $content, int $depth): void // Intentionally & |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Remove lines with inline variables definition and put then into DocuScope |
||
| 14 | */ |
||
| 15 | $content = preg_replace_callback( |
||
| 16 | '/(^.*)?\{\$\$([a-zA-Z_0-9]+)\}/m', |
||
| 17 | function(array $input) use ($depth): string { |
||
| 18 | $whitespacePrefix = ''; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Prefix the whole block with current identation |
||
| 22 | */ |
||
| 23 | foreach (str_split($input[1]) as $character) { |
||
| 24 | if ($character === "\t") { |
||
| 25 | $whitespacePrefix .= $character; |
||
| 26 | |||
| 27 | continue; |
||
| 28 | } |
||
| 29 | |||
| 30 | break; |
||
| 31 | } |
||
| 32 | |||
| 33 | $block = $this->docuScope->getBlockVariable($input[2]); |
||
| 34 | |||
| 35 | if ($depth <= parent::MAX_EXECUTE_DEPTH) { |
||
| 36 | foreach ($this->getMacrosToRunOnBlockVariables() as $macro) { |
||
| 37 | $macro->runVariableMacro($block, $depth + 1); |
||
| 38 | } |
||
| 39 | } |
||
| 40 | |||
| 41 | return $input[1] . preg_replace('/\n/m', "\n{$whitespacePrefix}", $block); |
||
| 42 | }, |
||
| 43 | $content |
||
| 44 | ); |
||
| 45 | } |
||
| 46 | } |
||
| 47 |