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 to skip Dead catch reporting for unchecked exception #9921

Closed
VincentLanglet opened this issue Sep 25, 2023 · 3 comments
Closed

Allow to skip Dead catch reporting for unchecked exception #9921

VincentLanglet opened this issue Sep 25, 2023 · 3 comments

Comments

@VincentLanglet
Copy link
Contributor

Feature request

Let's say I have configured

check:
    missingCheckedExceptionInThrows: true
uncheckedExceptionClasses
    - LogicException

In this following example https://phpstan.org/r/543df433-81a7-494c-aacf-78323bca1dec
Since I don't ask PHPStan to report every missing @throws LogicException
I'd like a way to avoid having PHPStan reporting the deadCatch for the LogicException too.

Kinda similar to the "sometimes" example of
https://phpstan.org/blog/bring-your-exceptions-under-control#future-scope

Disallow unchecked exceptions in catch blocks. This might sound useful, but sometimes we want to check an unchecked exception and convert it to a checked exception before re-throwing.

Is it something doable ?

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

No response

@ondrejmirtes
Copy link
Member

What you want to implement here is a exceptions.reportUncheckedExceptionDeadCatch which would default to true (current behaviour).

@VincentLanglet
Copy link
Contributor Author

What you want to implement here is a exceptions.reportUncheckedExceptionDeadCatch which would default to true (current behaviour).

Indeed, it was easier than expected phpstan/phpstan-src#2648

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

No branches or pull requests

2 participants