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

False report on return typehint that can be removed #3748

Closed
gmponos opened this issue Aug 18, 2020 · 5 comments
Closed

False report on return typehint that can be removed #3748

gmponos opened this issue Aug 18, 2020 · 5 comments
Labels
Milestone

Comments

@gmponos
Copy link

gmponos commented Aug 18, 2020

Bug report

Code snippet that reproduces the problem

Initially I have this:

https://phpstan.org/r/4f38a849-8c15-47aa-a6c9-b416aa4f4a64

And I am trying to fix it with this:

https://phpstan.org/r/7d2c5bb4-aaae-4295-96d1-8aee8e20e6ba

but as you can see I get that the typehint should be removed.

I am getting the same error even if I remove the typehint;

https://phpstan.org/r/02b4d43a-d070-491f-8b73-cbf30591f07e

Expected output

No errors reported.

@gmponos gmponos changed the title False report on typehint that can be removed False report on return typehint that can be removed Aug 18, 2020
@ondrejmirtes
Copy link
Member

Yeah, this is a bug and should be fixed: https://phpstan.org/r/7d2c5bb4-aaae-4295-96d1-8aee8e20e6ba

Right now you can do it like this: https://phpstan.org/r/c3d1789b-d5d4-4083-9bbe-efdf7e7932a9

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Aug 18, 2020
@phpstan-bot
Copy link
Contributor

@gmponos After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-35: Method LampFactory::getState() never returns int so it can be removed from the return typehint.
+35: Method LampFactory::getState() never returns 0 so it can be removed from the return typehint.
Full report
Line Error
35 Method LampFactory::getState() never returns 0 so it can be removed from the return typehint.

@phpstan-bot
Copy link
Contributor

@gmponos After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-35: Method LampFactory::getState() never returns int so it can be removed from the return typehint.
+35: Method LampFactory::getState() never returns 0 so it can be removed from the return typehint.
Full report
Line Error
35 Method LampFactory::getState() never returns 0 so it can be removed from the return typehint.

@ondrejmirtes
Copy link
Member

Fixed by: phpstan/phpstan-src@838d1e4

@github-actions
Copy link

github-actions bot commented Jul 2, 2021

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 Jul 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants