Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Phpstan Baseline Per Identifier Laravel Package

shipmonk/phpstan-baseline-per-identifier

Split a PHPStan baseline into multiple NEON files grouped by error identifier, with a loader include. Generate baseline as usual, then run split-phpstan-baseline to organize ignores per identifier for easier reviews and maintenance.

View on GitHub
Deep Wiki
Context7

PHPStan baseline per error identifier

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"
        ]
    }
}

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
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation
uri-template/tests