Skip to content

Unable to inline-ignore errors from most collector-based rules #12328

Open

Description

@janedbal

Bug report

When a collector-based rule needs data from full codebase, it uses if ($node->isOnlyFilesAnalysis()) return [] (example). But then, you are unable to inline-ignore those errors via // @phpstan-ignore identifier as it produces false-positives in partial analysis of such file (unmatched ignore reported).

See reproduction repository: https://github.com/janedbal/phpstan-unable-to-inline-ignore-collector-based-rule

Code snippet that reproduces the problem

No response

Expected output

Be able to inline-ignore everything

Did PHPStan help you today? Did it make you happy in any way?

No response

Activity

  1. mergeable commented on Dec 27, 2024

    @mergeable

    This bug report is missing a link to reproduction at phpstan.org/try.

    It will most likely be closed after manual review.

  2. ondrejmirtes commented on Jan 4, 2025

    @ondrejmirtes
    Member

    You're right here, this isn't easy to solve. Because we're issuing " No error with identifier shipmonk.deadMethod is reported on line 5." error so no CollectedDataNode rule is actually running during that, so we don't see the unmatched ignored error actually comes from a collector.

  3. janedbal commented on Jan 23, 2025

    @janedbal
    ContributorAuthor

    If anyone cares, this is solvable by custom formatter, where you list error identifiers of incriminated rules: https://gist.github.com/janedbal/aa11c0b65f05b121e3c8c1ead6b4c6a2

  4. janedbal commented on Mar 4, 2026

    @janedbal
    ContributorAuthor

    Dead-code-detector "solved" this in shipmonk-rnd/dead-code-detector#292 (and this approach is usable for other identifiers as well).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions