PHP analyzer detects code quality issues related to exceptions

Hello PHP developers,

Handling exceptions is a common task for you and it can lead to coding mistakes. Some of those mistakes are usually caught by the compiler in other languages but for sure this is not the case for PHP.
This is the reason why we added 5 rules that will help you to not face these coding pitfalls.

Bug Rules:

  • S5911: Class of caught exception should be defined (Blocker)
  • S5708: Caught Exceptions must derive from Throwable (Blocker)
  • S5632: Raised Exceptions must derive from Throwable (Blocker)
  • S1045: All “catch” blocks should be able to catch exceptions (Major)

Code Smell Rule:

  • S5713: A subclass should not be in the same “catch” clause as a parent class (Minor)

For more information, you can check the changelog.

These features are already available on SonarCloud, and will be included in SonarQube 8.5 and SonarLint.

Alex

1 Like