mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
Merge branch 'master' of https://github.com/top-think/framework
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
namespace think\console\command\optimize;
|
namespace think\console\command\optimize;
|
||||||
|
|
||||||
use think\App;
|
use think\App;
|
||||||
|
use think\Config;
|
||||||
use think\console\Command;
|
use think\console\Command;
|
||||||
use think\console\Input;
|
use think\console\Input;
|
||||||
use think\console\Output;
|
use think\console\Output;
|
||||||
@@ -42,9 +43,14 @@ EOF;
|
|||||||
'think\\' => LIB_PATH . 'think',
|
'think\\' => LIB_PATH . 'think',
|
||||||
'behavior\\' => LIB_PATH . 'behavior',
|
'behavior\\' => LIB_PATH . 'behavior',
|
||||||
'traits\\' => LIB_PATH . 'traits',
|
'traits\\' => LIB_PATH . 'traits',
|
||||||
'' => realpath(rtrim(EXTEND_PATH))
|
'' => realpath(rtrim(EXTEND_PATH)),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$root_namespace = Config::get('root_namespace');
|
||||||
|
foreach ($root_namespace as $namespace => $dir) {
|
||||||
|
$namespacesToScan[$namespace . '\\'] = realpath($dir);
|
||||||
|
}
|
||||||
|
|
||||||
krsort($namespacesToScan);
|
krsort($namespacesToScan);
|
||||||
$classMap = [];
|
$classMap = [];
|
||||||
foreach ($namespacesToScan as $namespace => $dir) {
|
foreach ($namespacesToScan as $namespace => $dir) {
|
||||||
@@ -84,7 +90,7 @@ EOF;
|
|||||||
$this->output->writeln(
|
$this->output->writeln(
|
||||||
'<warning>Warning: Ambiguous class resolution, "' . $class . '"' .
|
'<warning>Warning: Ambiguous class resolution, "' . $class . '"' .
|
||||||
' was found in both "' . str_replace(["',\n"], [
|
' was found in both "' . str_replace(["',\n"], [
|
||||||
''
|
'',
|
||||||
], $classMap[$class]) . '" and "' . $path . '", the first will be used.</warning>'
|
], $classMap[$class]) . '" and "' . $path . '", the first will be used.</warning>'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -96,20 +102,24 @@ EOF;
|
|||||||
{
|
{
|
||||||
|
|
||||||
$baseDir = '';
|
$baseDir = '';
|
||||||
$appPath = $this->normalizePath(realpath(APP_PATH));
|
|
||||||
$libPath = $this->normalizePath(realpath(LIB_PATH));
|
$libPath = $this->normalizePath(realpath(LIB_PATH));
|
||||||
|
$appPath = $this->normalizePath(realpath(APP_PATH));
|
||||||
$extendPath = $this->normalizePath(realpath(EXTEND_PATH));
|
$extendPath = $this->normalizePath(realpath(EXTEND_PATH));
|
||||||
|
$rootPath = $this->normalizePath(realpath(ROOT_PATH));
|
||||||
$path = $this->normalizePath($path);
|
$path = $this->normalizePath($path);
|
||||||
|
|
||||||
if (strpos($path, $libPath . '/') === 0) {
|
if ($libPath !== null && strpos($path, $libPath . '/') === 0) {
|
||||||
$path = substr($path, strlen(LIB_PATH));
|
$path = substr($path, strlen(LIB_PATH));
|
||||||
$baseDir = 'LIB_PATH';
|
$baseDir = 'LIB_PATH';
|
||||||
} elseif (strpos($path, $appPath . '/') === 0) {
|
} elseif ($appPath !== null && strpos($path, $appPath . '/') === 0) {
|
||||||
$path = substr($path, strlen($appPath) + 1);
|
$path = substr($path, strlen($appPath) + 1);
|
||||||
$baseDir = 'APP_PATH';
|
$baseDir = 'APP_PATH';
|
||||||
} elseif (strpos($path, $extendPath . '/') === 0) {
|
} elseif ($extendPath !== null && strpos($path, $extendPath . '/') === 0) {
|
||||||
$path = substr($path, strlen($extendPath) + 1);
|
$path = substr($path, strlen($extendPath) + 1);
|
||||||
$baseDir = 'EXTEND_PATH';
|
$baseDir = 'EXTEND_PATH';
|
||||||
|
} elseif ($rootPath !== null && strpos($path, $rootPath . '/') === 0) {
|
||||||
|
$path = substr($path, strlen($rootPath) + 1);
|
||||||
|
$baseDir = 'ROOT_PATH';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($path !== false) {
|
if ($path !== false) {
|
||||||
@@ -121,6 +131,9 @@ EOF;
|
|||||||
|
|
||||||
protected function normalizePath($path)
|
protected function normalizePath($path)
|
||||||
{
|
{
|
||||||
|
if ($path === false) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
$parts = [];
|
$parts = [];
|
||||||
$path = strtr($path, '\\', '/');
|
$path = strtr($path, '\\', '/');
|
||||||
$prefix = '';
|
$prefix = '';
|
||||||
|
|||||||
Reference in New Issue
Block a user