jbelien/phpstan-sarif-formatter 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jbelien/phpstan-sarif-formatter

最新稳定版本:1.2.0

Composer 安装命令:

composer require jbelien/phpstan-sarif-formatter

包简介

SARIF formatter for PHPStan

README 文档

README

???? Compatible with PHPStan 1.x and 2.x

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.

https://phpstan.org/

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 as an OASIS 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.

https://docs.oasis-open.org/sarif/sarif/v2.0/sarif-v2.0.html

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

Documentation: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/about-code-scanning

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) and add alerts in the "Code scanning" report in "Security" tab of your project (see screenshot below).

Screenshot

统计信息

  • 总下载量: 147k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 12
  • 点击次数: 3
  • 依赖项目数: 18
  • 推荐数: 0

GitHub 信息

  • Stars: 12
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固