Search code examples
phpoopdocumentationphpdoc

PHPdoc: Documenting chainable methods?


How should I properly use PHPdoc to document chainable methods in a class, as seen in the below example - what is the correct usage?

class myClass {


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

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

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

}

Solution

  • /**
    * @return myClass
    */
    

    I'm not a phpDoc expert but's that's how they do it in Zend framework. So I think it's reliable