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 Positive: Dead Catch for exceptions thrown from \Traversable or \Iterator traversing #5903

Closed
rattuscz opened this issue Nov 2, 2021 · 2 comments · Fixed by phpstan/phpstan-src#1051
Labels
Milestone

Comments

@rattuscz
Copy link

rattuscz commented Nov 2, 2021

Bug report

Dead Catch is reported from try/catch block around foreach that is operating on \Traversable ( or \Iterator I expect ).
During iteration there can definitely be exception thrown

Code snippet that reproduces the problem

https://phpstan.org/r/460202bd-5a21-4f1d-94c1-1c365337f5a3

Expected output

31 | Parameter #1 $travers of class Response constructor expects Traversable<mixed, string>, Generator<int, string, mixed, *NEVER*> given.

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

Happily fixing 200 errors phpstan 1.0 "introduced" :-)

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Jan 31, 2022
@phpstan-bot
Copy link
Contributor

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

@@ @@
-25: Dead catch - Throwable is never thrown in the try block.
-31: Parameter #1 $travers of class Response constructor expects Traversable<mixed, string>, Generator<int, string, mixed, *NEVER*> given.
+25: Dead catch - Throwable is never thrown in the try block.
Full report
Line Error
25 Dead catch - Throwable is never thrown in the try block.

@github-actions
Copy link

github-actions bot commented Apr 7, 2022

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

Successfully merging a pull request may close this issue.

3 participants