Detect errors and potential problems (lint or code quality tool)

2

Is it possible to analyze (check) a PHP code to determine the "quality" of the organization and to detect potential problems?

link

    
asked by anonymous 17.02.2015 / 19:23

1 answer

2

PHP already provides this type of tool by command line, you can test the "quality of the code" by command line:

php -l <fileName>

An example in Windows would be:

D:\wamp\php\php.exe -l "D:\wamp\www\arquivo.php"

In addition to this tool there are other ways to do this as you answer in SOen :

  • PHP Metrics - Presents an overview and general quality charts, according to different metrics such as Index maintainability, Halstead metrics, Coupling or Cyclomatic complexity .
  • PHP Code Sniffer - Basically ensures that PHP code complies with the standard. You can write your own "default".
  • PHP Unit or atoum - Test Unit (unit tests / unit tests are for small pieces of code).
  • PHP Project Mess Detector - N-Path and other complex analyzes to determine the complexity of parts of the code.
  • PHP Depend - Does static code analysis on a given base structure (this structure is usually called an Abstract Syntax Tree).
  • ScrutinizerCi ( link ) - List of tools described above
  • There is also a simple tool called PHPLint and can be test online , the problem is that for newer versions of PHP and phpDocumentor it has been outdated but still useful for simpler testing.

        
    17.02.2015 / 19:23