Skip to content

A free open source IT asset/license management system

3.5 KB
Raw Blame
includes:
    - ./vendor/larastan/larastan/extension.neon
    - phpstan-baseline.neon

parameters:
    paths:
        - app
        - config
        - database
        - routes
        # Larastan reads @property / @method / @mixin annotations from
        # the ide-helper-generated model stub so magic Eloquent column
        # access and scope dispatch resolve to concrete types instead
        # of the base Model (which was most of the baseline). Keep this
        # file regenerated via `php artisan ide-helper:models
        # --write-mixin` after any migration that adds, removes, or
        # retypes a column.
        - _ide_helper_models.php

    # Level 4 catches dead code branches, always-false instanceof,
    # unreachable code after return, and most type-mismatch classes
    # of bug. Anything higher (5+) starts flagging Laravel-magic paths
    # that need bigger config investments to satisfy. Raise later if
    # the noise budget allows. Baseline captures pre-existing findings
    # so CI stays green on this PR; new findings on future PRs will
    # still fail the check. Unused-parameter detection is handled by
    # PHPMD (see phpmd-ruleset.xml) since PHPStan intentionally omits
    # that check to avoid false positives on interface-conforming
    # methods.
    level: 4

    # Snipe-IT supports PHP 8.2 through 8.5. Setting phpVersion to the
    # MINIMUM supported version makes PHPStan flag any 8.3+ syntax
    # (typed class constants, json_validate, property hooks, etc.)
    # that would break on an 8.2 deployment. The analyzer itself runs
    # under whatever version CI provides; only the target check moves.
    phpVersion: 80200

    # Larastan's facade / interface class-map resolution varies slightly
    # between fresh CI installs and long-lived local vendor trees, so a
    # baseline entry generated in one environment can be "unmatched" in
    # the other. Tolerate unmatched entries rather than fail — the
    # baseline is an allow-list, not a must-match assertion. Real
    # regressions still fail because they'd be genuine NEW findings
    # that aren't in the baseline.
    reportUnmatchedIgnoredErrors: false

    parallel:
        maximumNumberOfProcesses: 4

    # Larastan already understands Laravel Eloquent shapes at level 4.
    # Ignore common false positives so signal stays useful.
    ignoreErrors:
        # $model->save() returns bool but analyzers sometimes flag it as
        # unused when the caller doesn't branch on it; Snipe-IT has
        # deliberate fire-and-forget saves in observers where the
        # return value adds no information.
        -
            message: '#Call to an undefined method Illuminate\\Database\\Eloquent\\Builder#'
            paths:
                - app/Models/*.php
        # ide-helper generates one empty IdeHelperXxx stub class per
        # model with a long list of `@method static Builder<static>|Xxx
        # whereYyy()` docblock tags. The stub classes don't extend
        # Model, so PHPStan complains that the generic `static` in
        # Builder<static> isn't a subtype of the Builder's TModel
        # template bound (which requires Model). The method tags are
        # there for IDE autocomplete via @mixin, not for PHPStan's own
        # type system — the real resolution happens on the actual
        # model class that carries the @mixin phpdoc. Suppressing the
        # category for the stub file keeps the useful column /
        # scope-method knowledge without the variance noise.
        -
            identifier: generics.notSubtype
            path: _ide_helper_models.php