2011-08-25 32 views
6

我應該如何正確使用PHPdoc來爲一個類中的可鏈式方法進行文檔化,如下面的例子所示 - 什麼是正確的用法?PHPdoc:記錄可鏈式方法?

class myClass { 


    /** 
    * @return myClass 
    */ 
    function one() 
    { 
     return $this; 
    } 

    /** 
    * @return self 
    */ 
    function two() 
    { 
     return $this; 
    } 

    /** 
    * @return $this 
    */ 
    function three() 
    { 
     return $this; 
    } 

} 

回答

6
/** 
* @return myClass 
*/ 

我不是一個PHPDoc的專家,但就是這是他們如何做到這一點的Zend框架。所以,我認爲這是可靠

+1

此選項往往最,特別是與IDE自動完成。 – ashnazg

0

我喜歡

/** 
* @return $this 
*/ 
+1

那是* PHPDoc支持*嗎?這只是運行時間,而不是我眼中的靜態代碼文檔。 – hakre