add AnnotationReader ignore name config (build 445, 2.7.0-beta5)

This commit is contained in:
crazywhalecc 2022-03-20 19:05:13 +08:00
parent 44a0eec74c
commit 2b8cab1824
3 changed files with 29 additions and 10 deletions

View File

@ -44,6 +44,12 @@ $config['runtime'] = [
'reload_delay_time' => 800,
'global_middleware_binding' => [],
'save_console_log_file' => false, // 改为目标路径,则将 Console 输出的日志保存到文件
'annotation_reader_ignore' => [ // 设置注解解析器忽略的注解名或命名空间,防止解析到不该解析的
'name' => [
'mixin',
],
'namespace' => [],
],
];
/* 轻量字符串缓存,默认开启 */

View File

@ -65,6 +65,19 @@ class AnnotationParser
foreach ($this->path_list as $path) {
Console::debug('parsing annotation in ' . $path[0] . ':' . $path[1]);
$all_class = ZMUtil::getClassesPsr4($path[0], $path[1]);
$conf = ZMConfig::get('global', 'runtime')['annotation_reader_ignore'] ?? [];
if (isset($conf['name']) && is_array($conf['name'])) {
foreach ($conf['name'] as $v) {
AnnotationReader::addGlobalIgnoredName($v);
}
}
if (isset($conf['namespace']) && is_array($conf['namespace'])) {
foreach ($conf['namespace'] as $v) {
AnnotationReader::addGlobalIgnoredNamespace($v);
}
}
AnnotationReader::addGlobalIgnoredName('mixin');
$this->reader = new DualReader(new AnnotationReader(), new AttributeReader());
foreach ($all_class as $v) {
Console::debug('正在检索 ' . $v);

View File

@ -28,9 +28,9 @@ use ZM\Exception\InitException;
class ConsoleApplication extends Application
{
public const VERSION_ID = 444;
public const VERSION_ID = 445;
public const VERSION = '2.7.0-beta4';
public const VERSION = '2.7.0-beta5';
private static $obj;