joking/annotation

注释拓展

Installs: 18

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/joking/annotation

v1.0 2017-07-29 14:54 UTC

This package is auto-updated.

Last update: 2025-10-04 14:18:03 UTC


README

拓展PHP注释,在注释上可以使用更多的@标签,并且可以比较简单的读取这些@标签

例如:

在使用之前需要先创建一个标签类

class ContainerLabel {
    public $value;
    public $param;

    public function __construct($value , $param) {
        $this->value = $value;
        $this->param = $param;
    }
}

然后开始注册

Annotation::register("标签的名字 Container" , "标签的实体类 ContainerLabel::class");



/**
 * @Container('className' , param="lalala")
 */
 class Name {
    
 }

然后你可以这样读读取它

$reflectionClass = new ReflectionClass(Name::class);
$reflectionAnnotationClass = new ReflectionAnnotationClass($reflectionClass);
$label = $reflectionAnnotationClass->getAnnotation("Container")

echo $label->param;

输出 lalala

还有更多功能有待开发,等等我想睡觉