add plugin loader support

This commit is contained in:
crazywhalecc
2022-12-19 01:45:27 +08:00
parent 52a195aca2
commit cd2bb1b570
18 changed files with 373 additions and 96 deletions

View File

@@ -4,6 +4,8 @@ declare(strict_types=1);
namespace ZM\Annotation;
use ZM\Annotation\Interfaces\Level;
/**
* 注解全局存取位置
*/
@@ -36,4 +38,20 @@ class AnnotationMap
self::$_list = array_merge(self::$_list, $parser->generateAnnotationList());
self::$_map = $parser->getAnnotationMap();
}
/**
* 排序所有的注解
*/
public static function sortAnnotationList(): void
{
foreach (self::$_list as $class => $annotations) {
if (is_a($class, Level::class, true)) {
usort(self::$_list[$class], function ($a, $b) {
$left = $a->getLevel(); /** @phpstan-ignore-line */
$right = $b->getLevel(); /* @phpstan-ignore-line */
return $left > $right ? -1 : ($left == $right ? 0 : 1);
});
}
}
}
}