Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Use 'static' return type in docblock #148

Open
ghost opened this issue Dec 12, 2017 · 3 comments
Open

Use 'static' return type in docblock #148

ghost opened this issue Dec 12, 2017 · 3 comments

Comments

@ghost
Copy link

ghost commented Dec 12, 2017

For example:

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

Instead @return AbstractMemberGenerator

@michalbundyra
Copy link
Member

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.

@ghost
Copy link
Author

ghost commented Dec 12, 2017

I agree

@weierophinney
Copy link
Member

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants