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

Adding a phpdoc to declare returning values of constants complains about the string native return type #5095

Closed
stof opened this issue May 29, 2021 · 3 comments

Comments

@stof
Copy link
Contributor

stof commented May 29, 2021

Bug report

When using a native return type ?string combined with an annotation @phpstan-return UnaryOperator::*|null, phpstan complains about the string type

Code snippet that reproduces the problem

https://phpstan.org/r/0346e5da-af41-4055-92d4-09021e4f5b8f

Expected output

no error being reported.

Did PHPStan help you today? Did it make you happy in any way?

I consider a static analysis of the PHP code a must-have today, so it definitely helps.

@ondrejmirtes
Copy link
Member

Hi, the error is expected, just the error message needed adjusting. The expected error message is: Method Parser::unaryOperatorFor() never returns 'not' so it can be removed from the return typehint.

Fixed: phpstan/phpstan-src@838d1e4

@stof
Copy link
Contributor Author

stof commented May 29, 2021

Well, with the right error message, I can understand the error 😄

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 30, 2021
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