From c7bfb8a4de174019cda009f94b045bce56434e85 Mon Sep 17 00:00:00 2001 From: Jan Nedbal Date: Mon, 23 Feb 2026 17:27:26 +0100 Subject: [PATCH] feat: add AnalysisResult::withFileSpecificErrors() to public API 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 https://github.com/shipmonk-rnd/dead-code-detector/pull/292 --- src/Command/AnalysisResult.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Command/AnalysisResult.php b/src/Command/AnalysisResult.php index 1697b5f38a..ad7162b32b 100644 --- a/src/Command/AnalysisResult.php +++ b/src/Command/AnalysisResult.php @@ -148,4 +148,25 @@ public function getChangedProjectExtensionFilesOutsideOfAnalysedPaths(): array return $this->changedProjectExtensionFilesOutsideOfAnalysedPaths; } + /** + * @api + * @param list $fileSpecificErrors + */ + public function withFileSpecificErrors(array $fileSpecificErrors): self + { + return new self( + $fileSpecificErrors, + $this->notFileSpecificErrors, + $this->internalErrors, + $this->warnings, + $this->collectedData, + $this->defaultLevelUsed, + $this->projectConfigFile, + $this->savedResultCache, + $this->peakMemoryUsageBytes, + $this->isResultCacheUsed, + $this->changedProjectExtensionFilesOutsideOfAnalysedPaths, + ); + } + }