定制 shipmonk/phpstan-baseline-per-identifier 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

shipmonk/phpstan-baseline-per-identifier

最新稳定版本:2.3.0

Composer 安装命令:

composer require --dev shipmonk/phpstan-baseline-per-identifier

包简介

Split your PHPStan baseline into multiple files, one per error identifier. Supports both neon baseline and PHP baseline.

README 文档

README

Split your PHPStan baseline into multiple files, one per error identifier:

baselines/
 ├─ _loader.neon
 ├─ empty.notAllowed.neon
 ├─ foreach.nonIterable.neon
 ├─ identical.alwaysFalse.neon
 └─ if.condNotBoolean.neon

Each file looks like this:

# total 1 error

parameters:
    ignoreErrors:
        -
            message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
            path: ../app/index.php
            count: 1

Installation:

composer require --dev shipmonk/phpstan-baseline-per-identifier

Usage

Important

This usage is available since version 2.0. See legacy usage below if you are still using PHPStan 1.x

Remove old single baseline include:

-includes:
-	- phpstan-baseline.neon

Run native baseline generation and split it into multiple files via our script (other baseline files will be placed beside the loader):

vendor/bin/phpstan --generate-baseline=baselines/_loader.neon && vendor/bin/split-phpstan-baseline baselines/_loader.neon

Setup the baselines loader:

# phpstan.neon.dist
includes:
    - baselines/_loader.neon

(optional) You can simplify generation with e.g. composer script:

{
    "scripts": {
        "generate:baseline:phpstan": [
            "phpstan --generate-baseline=baselines/_loader.neon",
            "split-phpstan-baseline baselines/_loader.neon"
        ]
    }
}

Legacy usage

This usage is deprecated since 2.0, but it works in all versions. Downside is that it cannot utilize result cache and does not support rawMessage.

Setup where your baseline files should be stored and include its loader:

# phpstan.neon.dist
includes:
    - vendor/shipmonk/phpstan-baseline-per-identifier/extension.neon # or use extension-installer
    - baselines/loader.neon

parameters:
    shipmonkBaselinePerIdentifier:
        directory: %currentWorkingDirectory%/baselines
        indent: '    '

Prepare composer script to simplify generation:

{
    "scripts": {
        "generate:baseline:phpstan": [
            "rm baselines/*.neon",
            "touch baselines/loader.neon",
            "phpstan analyse --error-format baselinePerIdentifier"
        ]
    }
}

Cli options

  • --tabs to use tabs as indents in generated neon files
  • --no-error-count to remove errors count in generated files

PHP Baseline

  • If the loader file extension is php, the generated files will be php files as well

统计信息

  • 总下载量: 786.37k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 91
  • 点击次数: 1
  • 依赖项目数: 17
  • 推荐数: 0

GitHub 信息

  • Stars: 89
  • Watchers: 3
  • Forks: 6
  • 开发语言: PHP

其他信息

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