/annotation

Fastd Annotation

Primary LanguagePHPMIT LicenseMIT

Annotation

Building Latest Stable Version Total Downloads Latest Unstable Version License

简单的 PHP 类注释解析类

要求

  • PHP 5.6+

Composer

composer require "fastd/annotation"

使用

use FastD\Annotation\Reader;
use Tests\AnnotationsClasses\IndexController;

$reader = new Reader();

/**
 * Class IndexController
 * @package Tests\AnnotationsClasses
 *
 * @name foo
 * @json ["abc"]
 * @directive("test")
 * @route("/")
 * @Tests\AnnotationsClasses\AnnotationObject -> test()
 */
$annotation = $reader->getAnnotations(IndexController::class);

$annotation->get('name'); // foo
$annotation->get('json'); // [ 'ab' ]

继承与覆盖

变量同名会覆盖 "父类" 的变量和函数。

Testing

phpunit

License MIT