Industrial
Industrial

Reputation: 42798

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

}

Upvotes: 6

Views: 510

Answers (2)

yokoloko
yokoloko

Reputation: 2860

/**
* @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

Upvotes: 6

xdazz
xdazz

Reputation: 160963

I prefer

/**
* @return $this
*/

Upvotes: 0

Related Questions