Skip to content

Commit

Permalink
upgrade SARIF output format (using bartlett/sarif-php-converters pack…
Browse files Browse the repository at this point in the history
…age)
  • Loading branch information
llaville committed Dec 7, 2024
1 parent f46df2e commit f07f64d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changes/unreleased/Changed-20241207-090052.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Changed
body: upgrade SARIF output to support [PhpLintConverter](https://llaville.github.io/sarif-php-converters/1.0/converter/phplint/) of bartlett/sarif-php-converters package
time: 2024-12-07T09:00:52.188093881Z
8 changes: 7 additions & 1 deletion src/Output/SarifOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
use Symfony\Component\Console\Output\StreamOutput;

use function class_exists;
use function dirname;
use function ob_get_clean;
use function ob_start;

Expand All @@ -38,8 +40,12 @@ public function __construct(
?OutputFormatterInterface $formatter = null,
?ConverterInterface $converter = null
) {
if (!class_exists(PhpLintConverter::class)) {
// use default Composer-Bin-Plugin autoloader to load Sarif-Php-Converters components
require_once dirname(__DIR__, 2) . '/vendor-bin/sarif/vendor/autoload.php';
}
parent::__construct($stream, $verbosity, $decorated, $formatter);
$this->converter = $converter ?? new PhpLintConverter(null, $this->isVerbose());
$this->converter = $converter ?? new PhpLintConverter(['format_output' => $this->isVerbose()]);
}

public function getName(): string
Expand Down
5 changes: 5 additions & 0 deletions vendor-bin/sarif/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require-dev": {
"bartlett/sarif-php-converters": "^1.0"
}
}

0 comments on commit f07f64d

Please sign in to comment.