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!
Qodana Clone Finder: Early Access Program
In December 2020, we announced the EAP for Qodana, which is rapidly evolving into a comprehensive platform that allows companies to perform multi-level evaluations of the quality of code they own, contract, or purchase. Qodana helps you detect bugs without relying on an IDE, either on a local machi…
PhpStorm 2020.2 EAP #3
The Early Access Program for PhpStorm 2020.2 is in full swing and today we’ve got the third build of the 2020.2 EAP for you. In this blog post, you can read about improvements for Git installed in WSL2 and Search Everywhere. Download PhpStorm 2020.2 EAP (more…)…
PhpStorm 2019.3.3 Preview
We’ve just rolled out a preview for the third minor update for PhpStorm 2019.3. Please give the PhpStorm 2019.3.3 Preview build 193.6494.5 a try and share your feedback with us. (more…)…
How to Upgrade to PHP 7.4 with PhpStorm
Check out our fresh video with a few nice tips and tricks on how to update your codebase to PHP 7.4. It combines materials from the PhpStorm 2019.2 and PhpStorm 2019.3 releases, with a few cool bonuses to boot. Nikita drew our attention to the fact that setters are slower than assigning prop…