Merge remote-tracking branch 'origin/develop' into wip/laravel-6

This commit is contained in:
Ben Thomson 2020-07-10 16:02:01 +08:00
commit 327d7be604
No known key found for this signature in database
GPG Key ID: 8BDB18DD0909BE22
1 changed files with 4 additions and 2 deletions

View File

@ -128,7 +128,7 @@ class CodeParser
$body = $this->object->code;
$body = preg_replace('/^\s*function/m', 'public function', $body);
$codeNamespaces = [];
$namespaces = [];
$pattern = '/(use\s+[a-z0-9_\\\\]+(\s+as\s+[a-z0-9_]+)?;\n?)/mi';
preg_match_all($pattern, $body, $namespaces);
$body = preg_replace($pattern, '', $body);
@ -141,7 +141,9 @@ class CodeParser
$fileContents = '<?php '.PHP_EOL;
foreach ($namespaces[0] as $namespace) {
$fileContents .= $namespace;
if (str_contains($namespace, '\\')) {
$fileContents .= $namespace;
}
}
$fileContents .= 'class '.$className.$parentClass.PHP_EOL;