I use phpmd for code reviews. It is quick and easy to setup. Provides me first hand information about sub optimal code, over complicated experssion,Unused parameters, methods, properties and suggestions for refactoring class and functions.
Add in your composer.json of your project
“phpmd/phpmd” : “@stable”
Command prompt >phpmd /path/to/directory/for/php/class text
You may get following error sometimes
‘phpmd’ is not recognized as internal or external command
on command prompt run
> composer global require phpmd/phpmd
1) A php source code filename or directory. Can be a comma-separated string
2) A report format (It can be Text, Html, XML)
3) A ruleset filename or a comma-separated string of ruleset filenames
Available rulesets: cleancode, codesize, controversial, design, naming, unusedcode.
- minimumpriority: rule priority threshold; rules with lower priority than this will not be used
- reportfile: send report output to a file; default to STDOUT
- suffixes: comma-separated string of valid source code filename extensions, e.g. php,phtml
- exclude: comma-separated string of patterns that are used to ignore directories
- strict: also report those nodes with a @SuppressWarnings annotation
To dump phpmd output in a file
On command prompt
phpmd C:\wamp64\www\myproject\models text –reportfile anyfilename.txt unusedcode, controversial, codesize, cleancode
The interesting thing is you can define the rules as per your projects. An easy CLI tool to keep code neat and clean.
Happy Coding !