1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Scan entire file/dir list at once (#944)

fixes vimeo/psalm#943
This commit is contained in:
Bruce Weirdan 2018-08-15 18:57:40 +03:00 committed by Matthew Brown
parent 366f625c83
commit 3b3863f3a8
2 changed files with 39 additions and 7 deletions

View File

@ -567,6 +567,44 @@ class ProjectChecker
$this->codebase->analyzer->analyzeFiles($this, $this->threads, $this->alter_code);
}
/**
* @param string[] $paths_to_check
* @return void
*/
public function checkPaths(array $paths_to_check)
{
foreach ($paths_to_check as $path) {
if ($this->debug_output) {
echo 'Checking ' . $path . "\n";
}
if (is_dir($path)) {
$this->checkDirWithConfig($path, $this->config, true);
} elseif (is_file($path)) {
$this->codebase->addFilesToAnalyze([$path => $path]);
$this->config->hide_external_errors = $this->config->isInProjectDirs($path);
}
}
FileReferenceProvider::loadReferenceCache();
if ($this->output_format === self::TYPE_CONSOLE) {
echo 'Scanning files...' . "\n";
}
$this->config->initializePlugins($this);
$this->codebase->scanFiles();
$this->config->visitStubFiles($this->codebase, $this->debug_output);
if ($this->output_format === self::TYPE_CONSOLE) {
echo 'Analyzing files...' . "\n";
}
$this->codebase->analyzer->analyzeFiles($this, $this->threads, $this->alter_code);
}
/**
* @return Config
*/

View File

@ -439,13 +439,7 @@ $start_time = (float) microtime(true);
if ($paths_to_check === null) {
$project_checker->check($current_dir, $is_diff);
} elseif ($paths_to_check) {
foreach ($paths_to_check as $path_to_check) {
if (is_dir($path_to_check)) {
$project_checker->checkDir($path_to_check);
} else {
$project_checker->checkFile($path_to_check);
}
}
$project_checker->checkPaths($paths_to_check);
}
if ($find_references_to) {