add sort param

This commit is contained in:
crazywhalecc 2023-01-15 21:28:02 +08:00
parent 0a979e3674
commit fcc4f48231
No known key found for this signature in database
GPG Key ID: 3A96869D13956E98

View File

@ -41,13 +41,18 @@ class AnnotationMap
* 添加一个独立的注解到全局注解列表中
*
* @param AnnotationBase $annotation 注解对象
* @param bool $sort 是否在添加后排序(默认为 False
*/
public static function addSingleAnnotation(AnnotationBase $annotation): void
public static function addSingleAnnotation(AnnotationBase $annotation, bool $sort = false): void
{
self::$_list[get_class($annotation)][] = $annotation;
if ($annotation->class !== '') {
self::$_map[$annotation->class][$annotation->method][] = $annotation;
}
if ($sort) {
self::sortAnnotationList();
}
}
/**
@ -59,7 +64,7 @@ class AnnotationMap
}
/**
* 排序所有的注解
* 排序所有的注解(仅排序 List,不排序 Map
*/
public static function sortAnnotationList(): void
{