From 0e1ef2e0968db7605da06a24647d9e5a7024ded5 Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Mon, 4 Jan 2021 19:00:44 +0000 Subject: [PATCH] Ignore recently-deleted files for scanning --- src/Psalm/Internal/Codebase/Scanner.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Psalm/Internal/Codebase/Scanner.php b/src/Psalm/Internal/Codebase/Scanner.php index 0109e733f..5dfc3ae23 100644 --- a/src/Psalm/Internal/Codebase/Scanner.php +++ b/src/Psalm/Internal/Codebase/Scanner.php @@ -530,7 +530,7 @@ class Scanner string $file_path, array $filetype_scanners, bool $will_analyze = false - ): FileScanner { + ): void { $file_scanner = $this->getScannerForPath($file_path, $filetype_scanners, $will_analyze); if (isset($this->scanned_files[$file_path]) @@ -539,6 +539,11 @@ class Scanner throw new \UnexpectedValueException('Should not be rescanning ' . $file_path); } + if (!$this->file_provider->fileExists($file_path) && $this->config->mustBeIgnored($file_path)) { + // this should not happen, but might if the file was temporary + return; + } + $file_contents = $this->file_provider->getContents($file_path); $from_cache = $this->file_storage_provider->has($file_path, $file_contents); @@ -610,8 +615,6 @@ class Scanner $this->codebase->classlikes->addClassAlias($unaliased_name, $aliased_name); } } - - return $file_scanner; } /**