Tools that we consider• PHP Copy/Paste Detector• PHP Mess Detector• PHP_CodeSniffer• PHP Depend
PHP Copy/Paste DetectorAllows to search for duplicate source code fragments in projects.Usage example:
PHP Mess DetectorTakes 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
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
PHP Mess Detector (cont.)Usage example:You can pass a filename or a directory name containingPHP source code to PHPMD.
PHP_CodeSniffer (cont.)Sample PHP_CodeSniffer full report with source codes:Both the full and summary reports can additionally show informationabout the source of errors and warnings.
PHP_CodeSniffer (cont.)Sample PHP_CodeSniffer summary report with source codes:
PHP DependA 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 metricsSoftware metrics are the sum of some statements or code fragments found in the analyzed source.
PHP Depend (cont.) Usage example:This command hasproduced one xml-reportnamed summary.xml thatcontains a summary of allmetrics collected for theanalyzed php sourcecode.