简体   繁体   English

这些注释是做什么用的? @ param,@ return,@ var,并在Entity的注释中设置

[英]What are those annotation for? @param, @return, @var, and set in annotation of Entity

I would like to understand the following annotation that I see in some codes. 我想了解一些代码中的以下注释。 What is their purpose. 他们的目的是什么。 (I do understand @Assert and @ORM but not the others which I mentioned in my Title) (我确实了解@Assert和@ORM,但不了解我在标题中提到的其他对象)

here an exemple of code where I saw it. 这是我看到的一个示例代码。

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;
   }
}

Have read here and there that it s only used for Documentation only. 在这里和那里已经阅读过,它仅用于文档。 True? 真正? or is it like @ORM and @Assert which have a key role in the building of an Application. 还是@ORM和@Assert,它们在构建应用程序中起着关键作用。

This is used only for documentation purposes: 这仅用于文档目的:

  1. Tools like phpDocumentator will generate documetation basing on these comments phpDocumentator这样的工具将根据这些评论生成文档
  2. Code completion tools in your IDE will base on these comments to know what parameters given method expects, what it will return etc. IDE中的代码完成工具将基于这些注释来了解给定方法期望的参数,返回的参数等。

Check wiki for list of all these doc annotations 检查Wiki以获取所有这些文档注释的列表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM