Skip to content

more features

Inhere edited this page Jan 15, 2019 · 3 revisions

更多功能说明

注释中使用变量替换

相信在前面的文档中已经看到过类似:

 @usage {command} [arg ...] [--opt ...]
OR
 @usage {fullCommand} [arg ...] [--opt ...]

其中的 {command} {fullCommand} 就是可替换变量,在渲染时,会被自动替换为对应的值。

增加自定义变量

  • 方式一
protected function annotationVars(): array
{
     return \array_merge(parent::annotationVars(), [
         'myVar' => 'value',
     ]);
}
  • 方式二

在 init 方法里,调用 addAnnotationVar

    protected function init()
    {
        parent::init();

        $this->addAnnotationVar('myVar', 'value');
    }
Clone this wiki locally