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; } /**