PHPackages                             jbelien/phpstan-sarif-formatter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. jbelien/phpstan-sarif-formatter

ActiveLibrary[Testing &amp; Quality](/categories/testing)

jbelien/phpstan-sarif-formatter
===============================

SARIF formatter for PHPStan

1.2.0(1y ago)13253.6k↓12%2[1 issues](https://github.com/jbelien/phpstan-sarif-formatter/issues)[2 PRs](https://github.com/jbelien/phpstan-sarif-formatter/pulls)20MITPHPPHP ^8.1CI passing

Since Jan 28Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/jbelien/phpstan-sarif-formatter)[ Packagist](https://packagist.org/packages/jbelien/phpstan-sarif-formatter)[ GitHub Sponsors](https://github.com/jbelien)[ RSS](/packages/jbelien-phpstan-sarif-formatter/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (3)Dependencies (2)Versions (6)Used By (20)

SARIF formatter for PHPStan
===========================

[](#sarif-formatter-for-phpstan)

🔖 **Compatible with PHPStan 1.x and 2.x**

PHPStan
-------

[](#phpstan)

PHPStan focuses on finding errors in your code without actually running it. It catches whole classes of bugs even before you write tests for the code. It moves PHP closer to compiled languages in the sense that the correctness of each line of the code can be checked before you run the actual line.

Static Analysis Results Interchange Format (SARIF)
--------------------------------------------------

[](#static-analysis-results-interchange-format-sarif)

SARIF, the Static Analysis Results Interchange Format, is a standard, JSON-based format for the output of static analysis tool.
It has been [approved](https://www.oasis-open.org/news/announcements/static-analysis-results-interchange-format-sarif-v2-1-0-is-approved-as-an-oasis-s) as an [OASIS](https://www.oasis-open.org/) standard.

SARIF is a rich format intended to meet the needs of sophisticated tools, while still being practical for use by simpler tools. Because it would be impractical to support every feature of every tool, SARIF provides an extensibility mechanism to allow tool authors to store custom data that the SARIF format doesn't directly represent.

Usage
-----

[](#usage)

```
composer require --dev phpstan/phpstan jbelien/phpstan-sarif-formatter
```

Then update your `phpstan.neon` configuration file:

```
services:
    errorFormatter.sarif:
        class: PHPStanSarifErrorFormatter\SarifErrorFormatter
        arguments:
            relativePathHelper: @simpleRelativePathHelper
            currentWorkingDirectory: %currentWorkingDirectory%
            pretty: true
```

GitHub Code Scanning
--------------------

[](#github-code-scanning)

Documentation:

GitHub Code Scanning features are compatible with SARIF.
The SARIF Formatter for PHPStan allows you to use PHPStan as GitHub Code Scanning tool.

To use in one of your GitHub Actions workflows, add the following in your job:

```
- name: Run PHPStan
  continue-on-error: true
  run: phpstan analyze --error-format=sarif > phpstan-results.sarif

- name: Upload analysis results to GitHub
  uses: github/codeql-action/upload-sarif@v2
  with:
    sarif_file: phpstan-results.sarif
    wait-for-processing: true
```

It will display PHPStan error messages in your PR (check [this PR](https://github.com/jbelien/phpstan-sarif-formatter/pull/1)) and add alerts in the "Code scanning" report in "Security" tab of your project (see screenshot below).

[![Screenshot](assets/screenshot1.png)](assets/screenshot1.png)

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance59

Moderate activity, may be stable

Popularity43

Moderate usage in the ecosystem

Community26

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~370 days

Total

3

Last Release

513d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b434ff5f6f9dcc7095f45c43254299b3cc8f6c83e9a757a80a6b7d229a4c9701?d=identicon)[jbelien](/maintainers/jbelien)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (20 commits)")[![jbelien](https://avatars.githubusercontent.com/u/1150563?v=4)](https://github.com/jbelien "jbelien (13 commits)")

---

Tags

phpstanphpstan-formattersarif

### Embed Badge

![Health badge](/badges/jbelien-phpstan-sarif-formatter/health.svg)

```
[![Health](https://phpackages.com/badges/jbelien-phpstan-sarif-formatter/health.svg)](https://phpackages.com/packages/jbelien-phpstan-sarif-formatter)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.5k55.4M8.5k](/packages/larastan-larastan)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

79475.7M2.2k](/packages/phpstan-phpstan-symfony)[phpstan/phpstan-doctrine

Doctrine extensions for PHPStan

67272.8M1.4k](/packages/phpstan-phpstan-doctrine)[symplify/phpstan-rules

Set of Symplify rules, type extensions and error formatter for PHPStan

26812.7M337](/packages/symplify-phpstan-rules)[shipmonk/dead-code-detector

Dead code detector to find unused PHP code via PHPStan extension. Can automatically remove dead PHP code. Supports libraries like Symfony, Doctrine, PHPUnit etc. Detects dead cycles. Can detect dead code that is tested.

4853.5M92](/packages/shipmonk-dead-code-detector)[tomasvotruba/type-coverage

Measure type coverage of your project

21511.0M398](/packages/tomasvotruba-type-coverage)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
