Skip to content

Make ignore.allLineErrors fixable - #6907

Merged
ondrejmirtes merged 2 commits into
2.3.xfrom
fix-all-line-errors-ignore
Nov 2, 2026
Merged

ondrejmirtes merged 2 commits into
2.3.xfrom
fix-all-line-errors-ignore

Conversation

@ondrejmirtes

@ondrejmirtes ondrejmirtes commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

With reportIgnoresWithoutComments: true, --fix replaces @phpstan-ignore-line and @phpstan-ignore-next-line with @phpstan-ignore and the identifiers of the errors reported on the ignored line (one for each error, since each identifier ignores one error).

  • The fix is made in AnalyserResultFinalizer, so the identifiers include errors of CollectedDataNode rules reported on the ignored line.
  • Text after the tag becomes the comment in parentheses of every identifier, so ignore.noComment is satisfied. A comment on several PHPDoc lines is joined into one line, because lines after the identifiers would not parse.
  • A next-line ignore after code (2, // @phpstan-ignore-next-line) moves to the end of the next line, like in phpstan-fixer.
  • Not fixed when an error on the line has no identifier, there are no errors on the line, other tags follow the ignore, or the comment has unbalanced parentheses.

Docs: phpstan/phpstan#15636

With reportIgnoresWithoutComments, @phpstan-ignore-line and
@phpstan-ignore-next-line are replaced with @PHPStan-Ignore and the
identifiers of the errors reported on the ignored line, one for each error.
Text after the tag becomes the comment of every identifier. A next-line
ignore after code moves to the end of the next line.

Amp-Thread-ID: https://ampcode.com/threads/T-01a19bdb-a0f8-76c3-8540-9b8919996af4
The identifiers now include the errors of CollectedDataNode rules
reported on the ignored line, which are known only after FileAnalyser.

Amp-Thread-ID: https://ampcode.com/threads/T-01a19bdb-a0f8-76c3-8540-9b8919996af4
@ondrejmirtes
ondrejmirtes merged commit 9211a83 into 2.3.x Nov 2, 2026
1036 of 1037 checks passed
@ondrejmirtes
ondrejmirtes deleted the fix-all-line-errors-ignore branch November 2, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant