简单的 PHP 类注释解析类
- PHP 5.6+
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' ]
变量同名会覆盖 "父类" 的变量和函数。
phpunit