mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-22 16:15:34 +08:00
add get file load type test
This commit is contained in:
@@ -102,6 +102,7 @@ class RefactoredConfig
|
||||
// 按照加载顺序加载配置文件
|
||||
foreach (self::LOAD_ORDER as $load_type) {
|
||||
foreach ($stages[$load_type] as $file_path) {
|
||||
logger()->info('Loading config file: ' . $file_path);
|
||||
$this->loadConfigFromPath($file_path);
|
||||
}
|
||||
}
|
||||
@@ -189,12 +190,13 @@ class RefactoredConfig
|
||||
/**
|
||||
* 获取文件加载类型
|
||||
*
|
||||
* @param string $name 文件名
|
||||
* @param string $name 文件名,不带扩展名
|
||||
*
|
||||
* @return string 可能为:global, environment, patch
|
||||
*/
|
||||
private function getFileLoadType(string $name): string
|
||||
{
|
||||
// TODO: 对于多段名称的处理,如 test.patch.development
|
||||
// 传入此处的 name 参数有三种可能的格式:
|
||||
// 1. 纯文件名:如 test,此时加载类型为 global
|
||||
// 2. 文件名.环境:如 test.development,此时加载类型为 environment
|
||||
|
||||
@@ -120,4 +120,21 @@ class ReflectionUtil
|
||||
? new ReflectionMethod($callback[0], $callback[1])
|
||||
: new ReflectionFunction($callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取传入的类方法,并确保其可访问
|
||||
*
|
||||
* 请不要滥用此方法!!!
|
||||
*
|
||||
* @param string $class 类名
|
||||
* @param string $method 方法名
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public static function getMethod(string $class, string $method): ReflectionMethod
|
||||
{
|
||||
$class = new \ReflectionClass($class);
|
||||
$method = $class->getMethod($method);
|
||||
$method->setAccessible(true);
|
||||
return $method;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user