简体   繁体   中英

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)

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.

This is used only for documentation purposes:

  1. Tools like phpDocumentator will generate documetation basing on these comments
  2. Code completion tools in your IDE will base on these comments to know what parameters given method expects, what it will return etc.

Check wiki for list of all these doc annotations

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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