Skip to content

feat: add AnalysisResult::withFileSpecificErrors() to public API#5034

Merged
ondrejmirtes merged 1 commit intophpstan:2.1.xfrom
janedbal:analysis-result-with-methods
Feb 26, 2026
Merged

feat: add AnalysisResult::withFileSpecificErrors() to public API#5034
ondrejmirtes merged 1 commit intophpstan:2.1.xfrom
janedbal:analysis-result-with-methods

Conversation

@janedbal
Copy link
Contributor

Custom ErrorFormatter implementations that need to filter or modify file-specific errors currently have to call the AnalysisResult constructor directly, which is not part of the public API.

This adds an @api withFileSpecificErrors() method that returns a copy of the result with different file-specific errors, allowing extensions to create modified results without relying on internal constructor.

See example usecase: shipmonk-rnd/dead-code-detector#292

Custom ErrorFormatter implementations that need to filter or modify
file-specific errors currently have to call the AnalysisResult
constructor directly, which is not part of the public API.

This adds an @api withFileSpecificErrors() method that returns a copy
of the result with different file-specific errors, allowing extensions
to create modified results without relying on internal constructor.

See shipmonk-rnd/dead-code-detector#292
@ondrejmirtes ondrejmirtes merged commit c205b88 into phpstan:2.1.x Feb 26, 2026
641 of 644 checks passed
@ondrejmirtes
Copy link
Member

Thank you!

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.

2 participants