Commit b61502a committed Mar 1, 2024 · 0 / 1
1 parent 505401a commit b61502a Copy full SHA for b61502a
File tree 1 file changed +8
-3
lines changed
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -31,15 +31,20 @@ public static function import(string $in): mixed {
31
31
return $ vars ;
32
32
}
33
33
34
- public static function export (mixed $ in ): string {
34
+ public static function export (mixed $ in , bool $ noHeader =false ): string {
35
+ $ header = '' ;
36
+ if ($ noHeader === false ) {
37
+ $ header = '<? ' . 'php ' . PHP_EOL . PHP_EOL .
38
+ 'declare(script_types=1); ' . PHP_EOL . PHP_EOL ;
39
+ }
35
40
if (!is_array ($ in ) || Utils::arrayIsList ($ in )) {
36
- return VarExporter::export ($ in );
41
+ return $ header . VarExporter::export ($ in );
37
42
}
38
43
$ blocks = [];
39
44
foreach ($ in as $ key => $ value ) {
40
45
$ blocks []= "\$vars[ " . VarExporter::export ($ key ) . "] = " .
41
46
VarExporter::export ($ value ) . "; \n" ;
42
47
}
43
- return join ("" , $ blocks );
48
+ return $ header . join ("" , $ blocks );
44
49
}
45
50
}
You can’t perform that action at this time.
0 commit comments