I do get a warning whenever I throw an exception in my code without explicitly stating it in the docblocs:
I know this can be fixed by adding @throw
tags, but the warning is actually not 100% true, as I do handle the exception in /app/Exceptions/Handler.php
. I would like to disable the warning for this single exception. Is this possible in PHPStan? I have not found anything in the docs, but in this blog post https://phpstan.org/blog/bring-your-exceptions-under-control it seems that one can have unchecked & checked exceptions, and I believe unchecked exceptions do not need to be declared. However, marking my exception unchecked in phpstan.neon
does not get rid of the error:
exceptions:
uncheckedExceptionClasses:
- 'app\Exceptions\AuthenticationException'
I also noticed that the Symfony\Component\HttpKernel\Exception\NotFoundHttpException
exception does not trigger the warning. I am not sure why, but it seems there is already a set of exceptions where no @throw
is needed.
How can I suppress the warning for my exception?