I have a project which uses both PHPMD (PHP Mess Detector) and PHPCS (PHP Code Sniffer) which got me wondering if all PHPMD checks can be replaced with PHPCS checks or is it best to use both in tandem?
The list of PHPMD checks seems to be here: https://phpmd.org/rules/index.html but I haven't found any information on the benefits provided by PHPMD.
PHP Code Sniffer is mainly used to detect violations to a given coding standard like PSR-2. It has configurations for different styles and you can configure manually each of the rules.
PHP Mess Detector is more focused on the quality of the code itself - like complexity of the functions, unnecessary constructs, rules that define clean code, etc. Similarly you can configure each of the predefined rules - whether you want them to be applied or not, and possible threshold for some of the checks.
To answer your questions - yes ALL of PHP MD rules can be written as CodeSniffer sniffs, but until someone has the time and patience to do so - we can keep using both :)
For example, some of the PHPMD rules already exists in the PHPCS, like the complexity one: https://github.com/squizlabs/PHP_CodeSniffer/blob/master/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php
Also for the function/method sizes and other similar checks in PHPMD, here is a standard for PHPCS that has some of them:
https://github.com/object-calisthenics/phpcs-calisthenics-rules
And you can search for more if you really like to mimic everything. And fill in the missing ones yourself.
But for the most of the time, you can use both and not bother combining them if you don't have the time, patience or some hardware/compute/time limitations.