PHP: cross-file knowledge of functions and methods allows to raise more accurate issues

Hello PHP developers,

The PHP analyzer was updated to gather cross-file knowledge of functions and methods. With these data such as parameters of functions/methods and properties like visibility or overriding, the PHP analyzer is able to draw better conclusions for rules raising issues on functions/methods. With this you can expect more true-positive issues to be raised.

Here is the list of rules that benefits from this enhancement.

Bug Rules:

  • S930: The number of arguments passed to a function should match the number of parameters (Major)
  • S3699: The output of functions that don’t return anything should not be used (Major)

Code Smell Rules:

  • S110: Inheritance tree of classes should not be too deep (Major)
  • S2234: Parameters should be passed in the correct order (Major)
  • S107: Functions should not have too many parameters (Major)
  • S1172: Unused function parameters should be removed (Major)
  • S100: Method and function names should comply with a naming convention (Minor)

For more information, you can check the changelog.

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

Alex

2 Likes