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

Allow a const/variable's value to be used as a type #17

Closed
nickyr opened this issue Dec 14, 2016 · 6 comments
Closed

Allow a const/variable's value to be used as a type #17

nickyr opened this issue Dec 14, 2016 · 6 comments

Comments

@nickyr
Copy link
Contributor

nickyr commented Dec 14, 2016

For example,

class A {
    const CLASS = '\My\Namespace\Class';

    /**
     * @return self::CLASS
     */
    public function foo() 
    {
        // ...
    }
}
@nickyr
Copy link
Contributor Author

nickyr commented Dec 14, 2016

Would be helpful for #16 also

@nickyr
Copy link
Contributor Author

nickyr commented Dec 14, 2016

For a real world example, see https://github.com/vimeo/omnipay-vindicia/blob/5f97e6eb9dfdae8e3cc888e32edd584de27a5846/src/Message/AbstractHOARequest.php#L30-L36, where reflection is being used to fake double inheritance.

@muglug
Copy link
Collaborator

muglug commented Apr 12, 2018

Psalm has @return class-string now FWIW

@nickyr
Copy link
Contributor Author

nickyr commented Apr 12, 2018

Nice! I see that's documented for @param here: https://github.com/vimeo/psalm/blob/master/docs/supported_annotations.md#class-constants

is it documented for @return?

@muglug
Copy link
Collaborator

muglug commented Apr 12, 2018

Ah, the docs weren't clear – I've improved them.

@muglug
Copy link
Collaborator

muglug commented May 29, 2018

Not going to support this beyond what's already supported with enums

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