@@ -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 }
0 commit comments