Configurable unchecked exceptions
In PhpStorm 2017.3, we’ve implemented several inspections that will help you eliminate unhandled exceptions and redundant @throws from your code. Initially, it was possible to exclude the \RuntimeException and \LogicException exceptions, as well as their derived classes, from the inspection scope.
In PhpStorm 2018.1, we are providing you with even more control over how you analyze your code:
To configure exceptions analysis, navigate to Settings / Preferences | Languages & Frameworks | PHP. On the Analysis tab, you will see the list of exceptions that are treated as unchecked by PhpStorm. Such exceptions will always be skipped, despite any missing @throws annotation for them.
To cover most cases of such exceptions, we’ve included \Error, \RuntimeException, and \LogicException into this list. Their derived classes are implicitly included, too.
You can extend the list by adding any of your own specific exceptions that you don’t need to be caught by the analyzer. We encourage you, however, to keep the list as short as possible to avoid missing anything meaningful and for performance reasons.
Using the Call tree analysis depth list, you can set the desired analysis depth level. By default, 1 is selected: PhpStorm, in this case, will report the unhandled exceptions for the parent method throwing an exception, as well as methods directly calling it.
Selecting 0 will limit the analysis to the parent method; using greater values will allow you to drill down deeper into the calls hierarchy:
By now, PhpStorm can analyze the thrown unhandled exceptions up to 3 levels deep. Note, however, that since the exception analysis is a resource-intensive operation, values greater than 1 might affect the performance of the IDE. If you experience issues, feel free to report them with the CPU snapshot attached.
Your JetBrains PhpStorm Team
The Drive to Develop
Subscribe to Blog updates
Thanks, we've got you!