The tests

PSR2 checks

PSR2 is a coding style guide maintained by the PHP Framework Interop(ability) Group

Embedded configuration (Magic Numbers)

Magic Numbers are coding issue in which configuration information is littered throughout the code base, rather than being clearly defined as config.

Clean code

Clean Code checks look for four things:

  • Static access
  • ELSE clauses in classes
  • Duplicate array keys
  • Boolean arguments to change the semantics of a function

Whether all of these are appropriate for your code is a matter of some contention, particularly the ELSE rule.

Code size (complexity)

This checks against a number of metrics including:

  • Number of methods per class
  • Number of parameters per class
  • NPath complexity of each method
  • Cyclomatic complexity of each method

Unused code

We check for unused code in the following:

  • Private fields
  • Local variables
  • Private methods
  • Parameters to methods

This sometimes gives false positives, such as in situations where function names are passed, quoted, as parameters to other functions. (uasort is notorious for this.)

SOLID design rules

The SOLID checks test for a large number of things, from goto statements, to the use of print_r

In practice, we find the coding error it regularly catches is the use of assignments in if clauses. These are possible in PHP, but in our experience tend to happen when someone has typed = (assignment) instead of == (equality).

Code duplication (Copy/Paste detection)

Code duplication is generally a sing of copy/paste, and tends to break the DRY principle.

By default, code duplication will be flagged if the number of duplicated lines is over 5 / the number of duplicated tokens is over 70.