PhpStorm 2017.3 introduces several useful inspections and the corresponding quick-fixes for handling exceptions in your code.
Situations where executing your code will lead to a Fatal Error should be detected in advance and avoided. The new Unhandled exception inspection will help you with this by reporting exceptions that are not enclosed in a try-catch block, or that are not documented using the @throws tag. You can resolve the reported issues by using the provided Add @throws tag and the Surround with try-catch quick-fixes:
Redundant @throws tag
When refactoring your code, it’s always a good idea to make sure that your changes are reflected in the PHPDoc block.
In earlier releases, the Missing @throws tag(s) inspection checked that all the exceptions thrown by a function had been documented. The new Redundant @throws tag inspection serves the same purpose, though by doing exactly the opposite: it detects tags for which no exceptions are present in the function, and suggests removing them.
Using the corresponding Remove @throws tag and Update PHPDoc Comment quick-fixes, you will clean up your PHPDoc in a breeze:
Redundant catch clause
The new Redundant catch clause inspection will detect the situations in which the exception you are trying to catch is actually never thrown. Use the the corresponding Delete catch clause quick-fix to remove redundant catch blocks:
We hope that the new inspections will save you precious time and streamline your work with exceptions handling. If you need to customize the inspections’ severity level or define the scope they are applied to, navigate to Settings | Editor | Inspections and explore the PHP | Error handling and PHP | PHPDoc sections in the inspections list.
Your JetBrains PhpStorm Team
The Drive to Develop