diff --git a/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php b/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php index 5844cedb9ae..a32260a7573 100644 --- a/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php @@ -684,18 +684,12 @@ public function check(string $base_dir, bool $is_diff = false): void true ); - if ($this->project_cache_provider && $this->parser_cache_provider) { - $removed_parser_files = $this->parser_cache_provider->deleteOldParserCaches( - $is_diff ? $this->project_cache_provider->getLastRun(PSALM_VERSION) : $start_checks - ); + if ($this->parser_cache_provider && !$is_diff) { + $removed_parser_files = $this->parser_cache_provider->deleteOldParserCaches($start_checks); if ($removed_parser_files) { $this->progress->debug('Removed ' . $removed_parser_files . ' old parser caches' . "\n"); } - - if ($is_diff) { - $this->parser_cache_provider->touchParserCaches($this->getAllFiles($this->config), $start_checks); - } } } @@ -1072,24 +1066,6 @@ private function checkDirWithConfig(string $dir_name, Config $config, bool $allo $this->codebase->addFilesToAnalyze($files_to_scan); } - /** - * @return list - */ - private function getAllFiles(Config $config): array - { - $file_extensions = $config->getFileExtensions(); - $file_paths = []; - - foreach ($config->getProjectDirectories() as $dir_name) { - $file_paths = array_merge( - $file_paths, - $this->file_provider->getFilesInDir($dir_name, $file_extensions) - ); - } - - return $file_paths; - } - public function addProjectFile(string $file_path): void { $this->project_files[$file_path] = $file_path; diff --git a/src/Psalm/Internal/Provider/ParserCacheProvider.php b/src/Psalm/Internal/Provider/ParserCacheProvider.php index 09543d00af5..c4b4b9a4050 100644 --- a/src/Psalm/Internal/Provider/ParserCacheProvider.php +++ b/src/Psalm/Internal/Provider/ParserCacheProvider.php @@ -7,7 +7,6 @@ use RuntimeException; use function error_log; -use function file_exists; use function file_get_contents; use function file_put_contents; use function filemtime; @@ -321,7 +320,7 @@ public function deleteOldParserCaches(float $time_before): int { $cache_directory = Config::getInstance()->getCacheDirectory(); - if ($cache_directory) { + if (!$cache_directory) { return 0; } @@ -349,57 +348,6 @@ public function deleteOldParserCaches(float $time_before): int return $removed_count; } - public function processSuccessfulRun(): void - { - $cache_directory = Config::getInstance()->getCacheDirectory(); - - if (!$cache_directory) { - return; - } - - $cache_directory .= DIRECTORY_SEPARATOR . self::PARSER_CACHE_DIRECTORY; - - if (is_dir($cache_directory)) { - $directory_files = scandir($cache_directory, SCANDIR_SORT_NONE); - - foreach ($directory_files as $directory_file) { - $full_path = $cache_directory . DIRECTORY_SEPARATOR . $directory_file; - - if ($directory_file[0] === '.') { - continue; - } - - touch($full_path); - } - } - } - - /** - * @param array $file_names - */ - public function touchParserCaches(array $file_names, int $min_time): void - { - $cache_directory = Config::getInstance()->getCacheDirectory(); - - if (!$cache_directory) { - return; - } - - $cache_directory .= DIRECTORY_SEPARATOR . self::PARSER_CACHE_DIRECTORY; - - if (is_dir($cache_directory)) { - foreach ($file_names as $file_name) { - $hash_file_name = $cache_directory . DIRECTORY_SEPARATOR . $this->getParserCacheKey($file_name); - - if (file_exists($hash_file_name)) { - if (filemtime($hash_file_name) < $min_time) { - touch($hash_file_name, $min_time); - } - } - } - } - } - private function getParserCacheKey(string $file_name): string { return md5($file_name) . ($this->use_igbinary ? '-igbinary' : '') . '-r'; diff --git a/src/Psalm/IssueBuffer.php b/src/Psalm/IssueBuffer.php index 9d3837e32da..b4857dfccea 100644 --- a/src/Psalm/IssueBuffer.php +++ b/src/Psalm/IssueBuffer.php @@ -746,10 +746,6 @@ function (IssueData $d1, IssueData $d2): int { if ($project_analyzer->project_cache_provider) { $project_analyzer->project_cache_provider->processSuccessfulRun($start_time, PSALM_VERSION); } - - if ($codebase->statements_provider->parser_cache_provider) { - $codebase->statements_provider->parser_cache_provider->processSuccessfulRun(); - } } if ($error_count