Skip to content

Commit c7bfb8a

Browse files
committed
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 shipmonk-rnd/dead-code-detector#292
1 parent 5ed2f90 commit c7bfb8a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/Command/AnalysisResult.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,25 @@ public function getChangedProjectExtensionFilesOutsideOfAnalysedPaths(): array
148148
return $this->changedProjectExtensionFilesOutsideOfAnalysedPaths;
149149
}
150150

151+
/**
152+
* @api
153+
* @param list<Error> $fileSpecificErrors
154+
*/
155+
public function withFileSpecificErrors(array $fileSpecificErrors): self
156+
{
157+
return new self(
158+
$fileSpecificErrors,
159+
$this->notFileSpecificErrors,
160+
$this->internalErrors,
161+
$this->warnings,
162+
$this->collectedData,
163+
$this->defaultLevelUsed,
164+
$this->projectConfigFile,
165+
$this->savedResultCache,
166+
$this->peakMemoryUsageBytes,
167+
$this->isResultCacheUsed,
168+
$this->changedProjectExtensionFilesOutsideOfAnalysedPaths,
169+
);
170+
}
171+
151172
}

0 commit comments

Comments
 (0)