@@ -87,14 +87,20 @@ public function __construct(
8787 * @param bool $debug
8888 * @return ResultCache
8989 */
90- public function restore (array $ allAnalysedFiles , bool $ debug , Output $ output , ?string $ resultCacheName = null ): ResultCache
90+ public function restore (array $ allAnalysedFiles , bool $ debug , bool $ onlyFiles , Output $ output , ?string $ resultCacheName = null ): ResultCache
9191 {
9292 if ($ debug ) {
9393 if ($ output ->isDebug ()) {
9494 $ output ->writeLineFormatted ('Result cache not used because of debug mode. ' );
9595 }
9696 return new ResultCache ($ allAnalysedFiles , true , time (), [], [], []);
9797 }
98+ if ($ onlyFiles ) {
99+ if ($ output ->isDebug ()) {
100+ $ output ->writeLineFormatted ('Result cache not used because only files were passed as analysed paths. ' );
101+ }
102+ return new ResultCache ($ allAnalysedFiles , true , time (), [], [], []);
103+ }
98104
99105 $ cacheFilePath = $ this ->cacheFilePath ;
100106 if ($ resultCacheName !== null ) {
@@ -255,15 +261,21 @@ private function exportedNodesChanged(string $analysedFile, array $cachedFileExp
255261 * @return ResultCacheProcessResult
256262 * @throws \PHPStan\ShouldNotHappenException
257263 */
258- public function process (AnalyserResult $ analyserResult , ResultCache $ resultCache , Output $ output , $ save ): ResultCacheProcessResult
264+ public function process (AnalyserResult $ analyserResult , ResultCache $ resultCache , Output $ output , bool $ onlyFiles , $ save ): ResultCacheProcessResult
259265 {
260266 $ internalErrors = $ analyserResult ->getInternalErrors ();
261267 $ freshErrorsByFile = [];
262268 foreach ($ analyserResult ->getErrors () as $ error ) {
263269 $ freshErrorsByFile [$ error ->getFilePath ()][] = $ error ;
264270 }
265271
266- $ doSave = function (array $ errorsByFile , ?array $ dependencies , array $ exportedNodes , ?string $ resultCacheName ) use ($ internalErrors , $ resultCache , $ output ): bool {
272+ $ doSave = function (array $ errorsByFile , ?array $ dependencies , array $ exportedNodes , ?string $ resultCacheName ) use ($ internalErrors , $ resultCache , $ output , $ onlyFiles ): bool {
273+ if ($ onlyFiles ) {
274+ if ($ output ->isDebug ()) {
275+ $ output ->writeLineFormatted ('Result cache was not saved because only files were passed as analysed paths. ' );
276+ }
277+ return false ;
278+ }
267279 if ($ dependencies === null ) {
268280 if ($ output ->isDebug ()) {
269281 $ output ->writeLineFormatted ('Result cache was not saved because of error in dependencies. ' );
0 commit comments