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:
parent
f5e03715f3
commit
21b1c04c1d
@ -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)
|
||||
) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user