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

Add an option to excluded some method/class/folder when doing the exception check #5044

Closed
VincentLanglet opened this issue May 19, 2021 · 2 comments

Comments

@VincentLanglet
Copy link
Contributor

Feature request

Hi @ondrejmirtes
I recently try the new feature of phpstan about exceptions, seems like it works well, great job.

When I was using https://github.com/pepakriz/phpstan-exception-rules, I used the following config:

    exceptionRule:
        methodWhitelist:
            PHPUnit\Framework\TestCase: '##'

It allows to disable the exception check for all the method of classes extending PHPUnit\Framework\TestCase.
This was pretty useful because I did want to annotate every method of src folder, but would avoid to pollute my tests directory with this ; even if I use phpstan on both src and tests directory for all the other rules.

Would it be possible to introduce a new option under the exceptions key of phpstan config in order to do something similar.
Like an uncheckedMethod, uncheckedClasses or something like this ?

@ondrejmirtes
Copy link
Member

See: phpstan/phpstan-src@a125304 + phpstan/phpstan-src@dec03af

You can now implement any logic you want using your own custom ExceptionTypeResolver. You can even ask for DefaultExceptionTypeResolver in the constructor as a fallback :)

@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 21, 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