1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Prevent unnecessary warnings

This commit is contained in:
Brown 2019-07-11 11:07:39 -04:00
parent 976d3bf787
commit 7268558aa7
5 changed files with 21 additions and 4 deletions

View File

@ -1746,6 +1746,7 @@ class ClassAnalyzer extends ClassLikeAnalyzer
&& ($local_offset
= array_search($t->param_name, array_keys($storage->template_types)))
!== false
&& isset($storage->template_covariants[$local_offset])
&& $storage->template_covariants[$local_offset]
) {
if (IssueBuffer::accepts(

View File

@ -247,6 +247,13 @@ class Analyzer
$project_analyzer->interpretRefactors();
}
$this->files_to_analyze = array_filter(
$this->files_to_analyze,
function (string $file_path) : bool {
return $this->file_provider->fileExists($file_path);
}
);
$analysis_worker =
/**
* @param int $_

View File

@ -358,8 +358,9 @@ class Scanner
$files_to_scan = array_filter(
$this->files_to_scan,
function (string $file_path) : bool {
return !isset($this->scanned_files[$file_path])
|| (isset($this->files_to_deep_scan[$file_path]) && !$this->scanned_files[$file_path]);
return $this->file_provider->fileExists($file_path)
&& (!isset($this->scanned_files[$file_path])
|| (isset($this->files_to_deep_scan[$file_path]) && !$this->scanned_files[$file_path]));
}
);

View File

@ -35,6 +35,10 @@ class FileProvider
return $this->open_files[strtolower($file_path)];
}
if (!file_exists($file_path)) {
throw new \UnexpectedValueException('File ' . $file_path . ' should exist to get contents');
}
return (string)file_get_contents($file_path);
}
@ -77,6 +81,10 @@ class FileProvider
*/
public function getModifiedTime($file_path)
{
if (!file_exists($file_path)) {
throw new \UnexpectedValueException('File should exist to get modified time');
}
return (int)filemtime($file_path);
}

View File

@ -649,8 +649,8 @@ class FileReferenceCacheProvider
$cache_directory = Config::getInstance()->getCacheDirectory();
if ($cache_directory) {
if (file_exists($cache_directory)) {
mkdir($cache_directory, 0777, true);
if (!file_exists($cache_directory)) {
\mkdir($cache_directory, 0777, true);
}
$config_hash_cache_location = $cache_directory . DIRECTORY_SEPARATOR . self::CONFIG_HASH_CACHE_NAME;