zendframework / zend-code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use 'static' return type in docblock

opened this issue · comments

For example:

    /**
     * @param  string $name
     * @return static
     */
    public function setName($name)
    {
        $this->name = (string) $name;
        return $this;
    }

Instead @return AbstractMemberGenerator

I think in that case we should use $this, there is slightly difference between static and $this and I think it is good explained in PSR-5 draft (the bottom of the page):
https://github.com/phpDocumentor/fig-standards/blob/master/proposed/phpdoc.md

$this, the element to which this type applies is the same exact instance as the current class in the given context. As such this type is a stricter version of static as, in addition, the returned instance must not only be of the same class but also the same instance.

I agree

This repository has been closed and moved to laminas/laminas-code; a new issue has been opened at laminas/laminas-code#7.