1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Fix #1526 - ignore files if they weren’t picked up in scanning step

This commit is contained in:
Brown 2019-04-03 10:43:41 -04:00
parent f5e03715f3
commit 21b1c04c1d
3 changed files with 25 additions and 7 deletions

View File

@ -79,6 +79,7 @@ class IncludeAnalyzer
if ($current_file_analyzer->project_analyzer->fileExists($path_to_file)) {
if ($statements_analyzer->hasParentFilePath($path_to_file)
|| !$codebase->file_storage_provider->has($path_to_file)
|| ($statements_analyzer->hasAlreadyRequiredFilePath($path_to_file)
&& !$codebase->file_storage_provider->get($path_to_file)->has_extra_statements)
) {

View File

@ -66,7 +66,7 @@ class FileStorageProvider
*
* @return bool
*/
public function has($file_path, $file_contents)
public function has($file_path, string $file_contents = null)
{
$file_path = strtolower($file_path);
@ -78,15 +78,17 @@ class FileStorageProvider
return false;
}
$cached_value = $this->cache->getLatestFromCache($file_path, $file_contents);
if ($file_contents !== null) {
$cached_value = $this->cache->getLatestFromCache($file_path, $file_contents);
if (!$cached_value) {
return false;
if (!$cached_value) {
return false;
}
self::$storage[$file_path] = $cached_value;
self::$new_storage[$file_path] = $cached_value;
}
self::$storage[$file_path] = $cached_value;
self::$new_storage[$file_path] = $cached_value;
return true;
}

View File

@ -539,6 +539,21 @@ class IncludeTest extends TestCase
getcwd() . DIRECTORY_SEPARATOR . 'index.php',
],
],
'suppressMissingFile' => [
'files' => [
getcwd() . DIRECTORY_SEPARATOR . 'file1.php' => '<?php
function getEndpoints() : void {
$listFile = "tests/stubs/custom_functions.php";
if (!file_exists($listFile)) {
throw new RuntimeException("Endpoint list not found");
}
include $listFile;
}',
],
'files_to_check' => [
getcwd() . DIRECTORY_SEPARATOR . 'file1.php',
],
],
];
}