From eebcadc976f522054a65bf278e998a4139498f86 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 22 Jun 2016 18:06:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BLoader=E7=B1=BB=E7=9A=84parse?= =?UTF-8?q?PhpNamespace=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Loader.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/think/Loader.php b/library/think/Loader.php index dddc4163..6b59f4f5 100644 --- a/library/think/Loader.php +++ b/library/think/Loader.php @@ -225,17 +225,18 @@ class Loader return ['namespace' => $namespace, 'files' => $files, 'classmap' => $classmap]; } + // 解析PHP文件 获取类的命名空间 private static function parsePhpNamespace($file) { $content = php_strip_whitespace($file); $content = substr($content, 5); if (0 === strpos(ltrim($content), 'namespace')) { - preg_match('/\snamespace\s(.*?);/', $content, $matches); + preg_match('/\snamespace\s(.*?);/is', $content, $matches); $namespace = $matches[1] . '\\'; } else { $namespace = ''; } - preg_match_all('/\sclass\s(\w+)\s?\{/', $content, $matches); + preg_match_all('/[\s|\;\}]class\s(\w+)\s?\{/is', $content, $matches); $info = []; foreach ($matches[1] as $class) {