| Conditions | 2 |
| Paths | 2 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 16 | function varexport($expression, $return = false) |
||
| 17 | { |
||
| 18 | $export = var_export($expression, true); |
||
| 19 | $export = preg_replace("/^([ ]*)(.*)/m", '$1$1$2', $export); |
||
| 20 | $array = preg_split("/\r\n|\n|\r/", $export); |
||
| 21 | |||
| 22 | $array = preg_replace( |
||
| 23 | ["/\s*array\s\($/", "/\)(,)?$/", "/\s=>\s$/"], |
||
| 24 | [null, ']$1', ' => ['], |
||
| 25 | $array |
||
| 26 | ); |
||
| 27 | |||
| 28 | $export = join(PHP_EOL, array_filter(["["] + $array)); |
||
| 29 | |||
| 30 | if ((bool)$return) { |
||
| 31 | return $export; |
||
| 32 | } else { |
||
| 33 | echo $export; |
||
| 34 | } |
||
| 35 | } |
||
| 36 |