|
@@ -34,11 +34,14 @@ function runDir(string $base, string $dir, array &$lines, array $ignore): int
|
34
|
34
|
$data = preg_replace('/\s*<\?php\s+/s', '', $data, 1);
|
35
|
35
|
$data = preg_replace('/^.*?(vendor\/autoload|declare\s*\(\s*strict_types\s*=\s*1).*?$/m', '', $data);
|
36
|
36
|
array_push($lines, "// file: $dir/$entry");
|
|
37
|
+ if (!preg_match('/^\s*(namespace[^;]*);/', $data)){
|
|
38
|
+ $data = "namespace;\n".$data;
|
|
39
|
+ }
|
37
|
40
|
foreach (explode("\n", trim($data)) as $line) {
|
38
|
41
|
if ($line) {
|
39
|
42
|
$line = ' ' . $line;
|
40
|
43
|
}
|
41
|
|
- $line = preg_replace('/^\s*(namespace[^;]+);/', '\1 {', $line);
|
|
44
|
+ $line = preg_replace('/^\s*(namespace[^;]*);/', '\1 {', $line);
|
42
|
45
|
array_push($lines, $line);
|
43
|
46
|
}
|
44
|
47
|
array_push($lines, '}');
|