4. PHP Mess Detector
Takes a given PHP source code base and look for
several potential problems within that source.
These problems can be things like:
• Possible bugs
• Suboptimal code
• Over complicated expressions
• Unused parameters, methods, properties
5. PHP Mess Detector (cont.)
PHPMD uses so called rule sets that configure/define a
set of rules which will be applied against the source
under test. It only provides a set of predefined rules.
List of rule sets:
• Code size rules
• Controversial rules
• Design rules
• Naming rules
6. PHP Mess Detector (cont.)
Usage example:
You can pass a filename or a directory name containing
PHP source code to PHPMD.
7. PHP_CodeSniffer
PHP5 script that tokenizes and "sniffs" PHP, Javascript
and CSS files to detect violations of a defined coding
standard.
A coding standard in PHP_CodeSniffer is a collection of
sniff files. Each sniff file checks one part of the coding
standard only.
The default coding standard used by PHP_CodeSniffer is
the PEAR coding standard.
9. PHP_CodeSniffer (cont.)
Sample PHP_CodeSniffer full report with source codes:
Both the full and summary reports can additionally show information
about the source of errors and warnings.
11. PHP Depend
A small program that performs static code
analysis on a given code base.
Static code analysis:
• takes the source code and parses it into an easily
processable internal data structure (Abstract Syntax Tree)
• takes the generated AST and measures several
values, the so called software metrics
Software metrics are the sum of some statements or code fragments
found in the analyzed source.
12. PHP Depend (cont.)
Usage example:
This command has
produced one xml-report
named summary.xml that
contains a summary of all
metrics collected for the
analyzed php source
code.