Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use 'static' return type in docblock #7

Open
weierophinney opened this issue Dec 31, 2019 · 3 comments
Open

Use 'static' return type in docblock #7

weierophinney opened this issue Dec 31, 2019 · 3 comments

Comments

@weierophinney
Copy link
Member

For example:

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

Instead @return AbstractMemberGenerator


Originally posted by @ViktorPegy at zendframework/zend-code#148

@weierophinney
Copy link
Member Author

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.


Originally posted by @michalbundyra at zendframework/zend-code#148 (comment)

@weierophinney
Copy link
Member Author

I agree


Originally posted by @ViktorPegy at zendframework/zend-code#148 (comment)

@samsonasik
Copy link
Member

The code is now uses @return AbstractMemberGenerator

* @return AbstractMemberGenerator

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

No branches or pull requests

2 participants