PHPMD Converter
Note
Available since version 1.0.0
Table Of Contents
Requirements
- PHP Mess Detector version 2.0 requires PHP version 5.3.9 or greater, with
xmlextensions loaded - PHP Mess Detector version 3.0 requires PHP version 8.1 or greater, with
xmlextensions loaded
The Bartlett\Sarif\Converter\Reporter\PhpMdRenderer class is ready to use the new feature :
Simplify load of external custom renderer available into PHPMD version 3.0
Installation
Usage
Warning
-
As PHMMD v2.15 is not able to specify/boot custom renderer easily, we have no other alternative that using the Console Tool convert command.
-
With PHPMD v3.0 is easier. Use the alternative solution at step 3.
Build the checkstyle output report
And finally, convert it to SARIF with the Console Tool
php report-converter convert phpmd --input-format=checkstyle --input-file=examples/phpmd/checkstyle.xml -v
Tip
- Without verbose option (
-v) the Console Tool will print a compact SARIF version. --output-fileoption allows to write a copy of the report to a file. By default, the Console Tool will always print the specified report to the standard output.
Alternative usage
Build the sarif output report directly via the default Bartlett\Sarif\Converter\Reporter\PhpMdRenderer
vendor/bin/phpmd analyze /path/to/source --format='\Bartlett\Sarif\Converter\Reporter\PhpMdRenderer' --bootstrap=autoload.php > sarif.json
Tip
- Without verbose option (
-v) the Renderer will print a compact SARIF version.
Learn more
- See demo
examples/phpmd/directory into this repository.
IDE Integration
The SARIF report file [*].sarif.json is automagically recognized and interpreted by PhpStorm (2024).

Web SARIF viewer
With the React based component, you are able to explore a sarif report file previously generated.
For example:
