簡體   English   中英

這些注釋是做什么用的? @ param,@ return,@ var,並在Entity的注釋中設置

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

我想了解一些代碼中的以下注釋。 他們的目的是什么。 (我確實了解@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,它們在構建應用程序中起着關鍵作用。

這僅用於文檔目的:

  1. phpDocumentator這樣的工具將根據這些評論生成文檔
  2. IDE中的代碼完成工具將基於這些注釋來了解給定方法期望的參數,返回的參數等。

檢查Wiki以獲取所有這些文檔注釋的列表

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM