You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
997 B
PHP
40 lines
997 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Helper;
|
|
|
|
use Hyperf\Di\Annotation\AnnotationCollector;
|
|
|
|
class Annotation
|
|
{
|
|
/**
|
|
* 只支持系统默认收集器
|
|
*/
|
|
public static function getMethodsByAnnotationAndClass(string $annotation, string $class): array
|
|
{
|
|
$items = AnnotationCollector::getMethodsByAnnotation($annotation);
|
|
$methods = [];
|
|
foreach ($items as $item) {
|
|
if ($item['class'] == $class) {
|
|
$methods[] = $item;
|
|
}
|
|
}
|
|
return $methods;
|
|
}
|
|
|
|
/**
|
|
* 只支持系统默认收集器
|
|
*/
|
|
public static function getPropertiesByAnnotationAndClass(string $annotation, string $class): array
|
|
{
|
|
$items = AnnotationCollector::getPropertiesByAnnotation($annotation);
|
|
$properties = [];
|
|
foreach ($items as $item) {
|
|
if ($item['class'] == $class) {
|
|
$properties[] = $item;
|
|
}
|
|
}
|
|
return $properties;
|
|
}
|
|
} |