Note
Available since version 1.0.0
- PHPLint requires PHP version 8.1.0 or greater
- This SARIF converter requires at least PHPLint version 9.4.0
composer require --dev overtrue/phplint bartlett/sarif-php-converters
vendor/bin/phplint --format='\Overtrue\PHPLint\Output\SarifOutput' /path/to/source/code
Warning
If you have the following error
Could not load sarif converter class: "Bartlett\Sarif\Converter\PhpLintConverter"
That means you've not specified the correct autoloader.
Please use the --bootstrap
run option of PHPLint like that:
vendor/bin/phplint --format='\Overtrue\PHPLint\Output\SarifOutput' --bootstrap=vendor/autoload.php
There are many ways to customize render of your converter.
By default, all converters use the default \Bartlett\Sarif\Factory\PhpSerializerFactory
to return the SARIF JSON representation of your report.
But this serializer factory component, as native PHP json_encode
function,
does not use whitespace in returned data to format it.
To make your report human-readable, you have to specify the \JSON_PRETTY_PRINT
constant, as encoder option.
Here is the way to do it !
Tip
- Without verbose option (
-v
) the PHPLintSarifOutput
will print a compact SARIF version.
vendor/bin/phplint --format='\Overtrue\PHPLint\Output\SarifOutput' --bootstrap vendor/autoload.php --output=examples/phplint/.sarif.json -v /path/to/source/code
If you prefer to convert from a format supported natively by PHPLint, then :
vendor/bin/phplint --format=checkstyle --output=checkstyle.xml /path/to/source/code
php report-converter convert phplint --input-format=checkstyle --input-file=examples/phplint/checkstyle.xml -v
Tip
- Without verbose option (
-v
) the Console Tool will print a compact SARIF version. --output-file
option 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.
- See demo
examples/phplint/
directory into this repository.
The SARIF report file [*].sarif.json
is automagically recognized and interpreted by PhpStorm (2024).