Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AnalyseApplication: Do not re-analyse stubs on every run #730

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Analyser/ResultCache/ResultCacheManager.php
Expand Up @@ -216,6 +216,15 @@ public function restore(array $allAnalysedFiles, bool $debug, bool $onlyFiles, ?
$filteredErrors = [];
$filteredExportedNodes = [];
$newFileAppeared = false;

foreach ($this->stubFiles as $stubFile) {
if (!array_key_exists($stubFile, $errors)) {
continue;
}

$filteredErrors[$stubFile] = $errors[$stubFile];
}

foreach ($allAnalysedFiles as $analysedFile) {
if (array_key_exists($analysedFile, $errors)) {
$filteredErrors[$analysedFile] = $errors[$analysedFile];
Expand Down
23 changes: 16 additions & 7 deletions src/Command/AnalyseApplication.php
Expand Up @@ -65,11 +65,6 @@ public function analyse(
): AnalysisResult
{
$this->updateMemoryLimitFile();
$projectStubFiles = [];
if ($projectConfigArray !== null) {
$projectStubFiles = $projectConfigArray['parameters']['stubFiles'] ?? [];
}
$stubErrors = $this->stubValidator->validate($projectStubFiles, $debug);

register_shutdown_function(function (): void {
$error = error_get_last();
Expand Down Expand Up @@ -109,6 +104,22 @@ public function analyse(
$errorOutput,
$input
);

$projectStubFiles = [];
if ($projectConfigArray !== null) {
$projectStubFiles = $projectConfigArray['parameters']['stubFiles'] ?? [];
}
if ($resultCache->isFullAnalysis() && count($projectStubFiles) !== 0) {
$stubErrors = $this->stubValidator->validate($projectStubFiles, $debug);
$intermediateAnalyserResult = new AnalyserResult(
array_merge($intermediateAnalyserResult->getErrors(), $stubErrors),
$intermediateAnalyserResult->getInternalErrors(),
$intermediateAnalyserResult->getDependencies(),
$intermediateAnalyserResult->getExportedNodes(),
$intermediateAnalyserResult->hasReachedInternalErrorsCountLimit()
);
}

$resultCacheResult = $resultCacheManager->process($intermediateAnalyserResult, $resultCache, $errorOutput, $onlyFiles, true);
$analyserResult = $resultCacheResult->getAnalyserResult();
$internalErrors = $analyserResult->getInternalErrors();
Expand All @@ -121,8 +132,6 @@ public function analyse(
$errors = array_merge($errors, $internalErrors);
}

$errors = array_merge($stubErrors, $errors);

$fileSpecificErrors = [];
$notFileSpecificErrors = [];
foreach ($errors as $error) {
Expand Down