Skip to content

Commit fcce0cb

Browse files
committed
Updated Rector to commit e4cb242d8c8996cc63ce3e796a9595cf73b740b9
rectorphp/rector-src@e4cb242 Cache --only / --only-suffix runs under a rule-scoped key (#8075)
1 parent 735f124 commit fcce0cb

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

src/Application/ApplicationFileProcessor.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ public function __construct(SymfonyStyle $symfonyStyle, FilesFinder $filesFinder
9898
}
9999
public function run(Configuration $configuration, InputInterface $input): ProcessResult
100100
{
101+
// scope the cache to this run's --only / --only-suffix selection before any cache read/write
102+
$this->changedFilesDetector->setActiveScope($configuration->getOnlyRule(), $configuration->getOnlySuffix());
101103
$filePaths = $this->filesFinder->findFilesInPaths($configuration->getPaths(), $configuration);
102104
// no files found
103105
if ($filePaths === []) {
@@ -147,6 +149,8 @@ public function run(Configuration $configuration, InputInterface $input): Proces
147149
*/
148150
public function processFiles(array $filePaths, Configuration $configuration, ?callable $preFileCallback = null, ?callable $postFileCallback = null): ProcessResult
149151
{
152+
// also set here: parallel workers reach processFiles() via WorkerCommand, bypassing run()
153+
$this->changedFilesDetector->setActiveScope($configuration->getOnlyRule(), $configuration->getOnlySuffix());
150154
/** @var SystemError[] $systemErrors */
151155
$systemErrors = [];
152156
/** @var FileDiff[] $fileDiffs */
@@ -188,11 +192,8 @@ private function processFile(File $file, Configuration $configuration): FileProc
188192
if ($fileProcessResult->getSystemErrors() !== []) {
189193
$this->changedFilesDetector->invalidateFile($file->getFilePath());
190194
} elseif (!$configuration->isDryRun() || !$fileProcessResult->getFileDiff() instanceof FileDiff) {
191-
// a file clean under a subset of rules is not necessarily clean under all rules,
192-
// caching it would hide its pending changes from the next full run
193-
if ($configuration->getOnlyRule() === null && $configuration->getOnlySuffix() === null) {
194-
$this->changedFilesDetector->cacheFile($file->getFilePath());
195-
}
195+
// selective runs are safe to cache now — the key is scoped to the rule selection
196+
$this->changedFilesDetector->cacheFile($file->getFilePath());
196197
}
197198
return $fileProcessResult;
198199
}

src/Application/VersionResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class VersionResolver
1919
* @api
2020
* @var string
2121
*/
22-
public const PACKAGE_VERSION = '0815da7a888492b7884bafb17c8e0233ad397cd3';
22+
public const PACKAGE_VERSION = 'e4cb242d8c8996cc63ce3e796a9595cf73b740b9';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2026-06-25 10:43:25';
27+
public const RELEASE_DATE = '2026-06-25 18:47:41';
2828
/**
2929
* @var int
3030
*/

src/Caching/Detector/ChangedFilesDetector.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,19 @@ final class ChangedFilesDetector
3030
* @var array<string, true>
3131
*/
3232
private array $cacheableFiles = [];
33+
// scopes the per-file cache key to the active --only / --only-suffix selection (empty = full run)
34+
private string $scopeSuffix = '';
3335
public function __construct(FileHashComputer $fileHashComputer, Cache $cache, FileHasher $fileHasher)
3436
{
3537
$this->fileHashComputer = $fileHashComputer;
3638
$this->cache = $cache;
3739
$this->fileHasher = $fileHasher;
3840
}
41+
public function setActiveScope(?string $onlyRule, ?string $onlySuffix): void
42+
{
43+
// each selection gets its own cache key, so --only and full runs coexist without clearing or poisoning
44+
$this->scopeSuffix = $onlyRule === null && $onlySuffix === null ? '' : '|only:' . ($onlyRule ?? '') . '|suffix:' . ($onlySuffix ?? '');
45+
}
3946
public function cacheFile(string $filePath): void
4047
{
4148
$filePathCacheKey = $this->getFilePathCacheKey($filePath);
@@ -90,7 +97,7 @@ private function resolvePath(string $filePath): string
9097
}
9198
private function getFilePathCacheKey(string $filePath): string
9299
{
93-
return $this->fileHasher->hash($this->resolvePath($filePath));
100+
return $this->fileHasher->hash($this->resolvePath($filePath) . $this->scopeSuffix);
94101
}
95102
private function hashFile(string $filePath): string
96103
{

0 commit comments

Comments
 (0)