【问题标题】:What are those annotation for? @param, @return, @var, and set in annotation of Entity那些注释是干什么用的? @param、@return、@var 和设置在 Entity 的注解中
【发布时间】:2014-09-19 14:59:02
【问题描述】:

我想了解我在某些代码中看到的以下注释。他们的目的是什么。 (我确实了解@Assert 和@ORM,但不了解我在标题中提到的其他内容)

这里是我看到的代码示例。

class Image
{
   /** 
   * Set url // is this line used by any code? Doctrine?
   * @param string $url  // is this line used by any code? Doctrine?
   * @return Image  // is this line used by any code? Doctrine?
   */
   public function setUrl($url){
       $this->url=$url;
       return $this;
   }
}

在这里和那里阅读它仅用于文档。真的?还是像 @ORM 和 @Assert 在构建应用程序中起关键作用。

【问题讨论】:

    标签: symfony annotations entity


    【解决方案1】:

    这仅用于文档目的:

    1. phpDocumentator 等工具将根据这些 cmets 生成文档
    2. IDE 中的代码完成工具将基于这些 cmets 了解给定方法期望的参数、返回的参数等。

    查看wiki 获取所有这些文档注释的列表

    【讨论】:

      猜你喜欢
      • 2020-08-16
      • 1970-01-01
      • 2013-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-02
      • 2013-06-01
      相关资源
      最近更新 更多