Skip to content

Commit 60b85e9

Browse files
committed
[cache] Simplify implementation
1 parent b487f05 commit 60b85e9

File tree

2 files changed

+5
-41
lines changed

2 files changed

+5
-41
lines changed

packages/Parallel/ValueObject/ProcessFileResult.php

Lines changed: 0 additions & 33 deletions
This file was deleted.

packages/Parallel/WorkerRunner.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use Rector\Core\ValueObject\Error\SystemError;
2121
use Rector\Core\ValueObject\Reporting\FileDiff;
2222
use Rector\Parallel\ValueObject\Bridge;
23-
use Rector\Parallel\ValueObject\ProcessFileResult;
2423
use Symplify\EasyParallel\Enum\Action;
2524
use Symplify\EasyParallel\Enum\ReactCommand;
2625
use Symplify\EasyParallel\Enum\ReactEvent;
@@ -94,12 +93,11 @@ public function run(Encoder $encoder, Decoder $decoder, Configuration $configura
9493
$file = new File($filePath, FileSystem::read($filePath));
9594
$this->currentFileProvider->setFile($file);
9695

97-
$processFileResult = $this->processFile($file, $configuration, $errorAndFileDiffs);
98-
$errorAndFileDiffs = $processFileResult->getErrorAndFileDiffs();
96+
$errorAndFileDiffs = $this->processFile($file, $configuration, $errorAndFileDiffs);
9997

10098
if ($errorAndFileDiffs[Bridge::SYSTEM_ERRORS] !== []) {
10199
$this->invalidateFile($file);
102-
} elseif (! $configuration->isDryRun() || $processFileResult->isFileChanged()) {
100+
} else {
103101
$this->changedFilesDetector->cacheFileWithDependencies($file->getFilePath());
104102
}
105103
} catch (Throwable $throwable) {
@@ -131,24 +129,23 @@ public function run(Encoder $encoder, Decoder $decoder, Configuration $configura
131129

132130
/**
133131
* @param array{system_errors: SystemError[], file_diffs: FileDiff[]}|mixed[] $errorAndFileDiffs
132+
* @return array{system_errors: SystemError[], file_diffs: FileDiff[]}
134133
*/
135-
private function processFile(File $file, Configuration $configuration, array $errorAndFileDiffs): ProcessFileResult
134+
private function processFile(File $file, Configuration $configuration, array $errorAndFileDiffs): array
136135
{
137-
$wasFileChanged = false;
138136
foreach ($this->fileProcessors as $fileProcessor) {
139137
if (! $fileProcessor->supports($file, $configuration)) {
140138
continue;
141139
}
142140

143141
$currentErrorsAndFileDiffs = $fileProcessor->process($file, $configuration);
144-
$wasFileChanged = $wasFileChanged || $currentErrorsAndFileDiffs[Bridge::FILE_DIFFS] !== [];
145142
$errorAndFileDiffs = $this->arrayParametersMerger->merge(
146143
$errorAndFileDiffs,
147144
$currentErrorsAndFileDiffs
148145
);
149146
}
150147

151-
return new ProcessFileResult($wasFileChanged, $errorAndFileDiffs);
148+
return $errorAndFileDiffs;
152149
}
153150

154151
/**

0 commit comments

Comments
 (0)