|
20 | 20 | use Rector\Core\ValueObject\Error\SystemError; |
21 | 21 | use Rector\Core\ValueObject\Reporting\FileDiff; |
22 | 22 | use Rector\Parallel\ValueObject\Bridge; |
| 23 | +use Rector\Parallel\ValueObject\ProcessFileResult; |
23 | 24 | use Symplify\EasyParallel\Enum\Action; |
24 | 25 | use Symplify\EasyParallel\Enum\ReactCommand; |
25 | 26 | use Symplify\EasyParallel\Enum\ReactEvent; |
@@ -93,11 +94,12 @@ public function run(Encoder $encoder, Decoder $decoder, Configuration $configura |
93 | 94 | $file = new File($filePath, FileSystem::read($filePath)); |
94 | 95 | $this->currentFileProvider->setFile($file); |
95 | 96 |
|
96 | | - $errorAndFileDiffs = $this->processFile($file, $configuration, $errorAndFileDiffs); |
| 97 | + $processFileResult = $this->processFile($file, $configuration, $errorAndFileDiffs); |
| 98 | + $errorAndFileDiffs = $processFileResult->getErrorAndFileDiffs(); |
97 | 99 |
|
98 | 100 | if ($errorAndFileDiffs[Bridge::SYSTEM_ERRORS] !== []) { |
99 | 101 | $this->invalidateFile($file); |
100 | | - } elseif (! $configuration->isDryRun()) { |
| 102 | + } elseif (! $configuration->isDryRun() || $processFileResult->isFileChanged()) { |
101 | 103 | $this->changedFilesDetector->cacheFileWithDependencies($file->getFilePath()); |
102 | 104 | } |
103 | 105 | } catch (Throwable $throwable) { |
@@ -129,23 +131,24 @@ public function run(Encoder $encoder, Decoder $decoder, Configuration $configura |
129 | 131 |
|
130 | 132 | /** |
131 | 133 | * @param array{system_errors: SystemError[], file_diffs: FileDiff[]}|mixed[] $errorAndFileDiffs |
132 | | - * @return array{system_errors: SystemError[], file_diffs: FileDiff[]} |
133 | 134 | */ |
134 | | - private function processFile(File $file, Configuration $configuration, array $errorAndFileDiffs): array |
| 135 | + private function processFile(File $file, Configuration $configuration, array $errorAndFileDiffs): ProcessFileResult |
135 | 136 | { |
| 137 | + $wasFileChanged = false; |
136 | 138 | foreach ($this->fileProcessors as $fileProcessor) { |
137 | 139 | if (! $fileProcessor->supports($file, $configuration)) { |
138 | 140 | continue; |
139 | 141 | } |
140 | 142 |
|
141 | 143 | $currentErrorsAndFileDiffs = $fileProcessor->process($file, $configuration); |
| 144 | + $wasFileChanged = $wasFileChanged || $currentErrorsAndFileDiffs[Bridge::FILE_DIFFS] !== []; |
142 | 145 | $errorAndFileDiffs = $this->arrayParametersMerger->merge( |
143 | 146 | $errorAndFileDiffs, |
144 | 147 | $currentErrorsAndFileDiffs |
145 | 148 | ); |
146 | 149 | } |
147 | 150 |
|
148 | | - return $errorAndFileDiffs; |
| 151 | + return new ProcessFileResult($wasFileChanged, $errorAndFileDiffs); |
149 | 152 | } |
150 | 153 |
|
151 | 154 | /** |
|
0 commit comments