mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Merge pull request #9012 from kkmuffme/ignore-missingfile-error-for-file_exists-files
dont report MissingFile error when file_exists is validated beforehand
This commit is contained in:
commit
9366c5ed32
@ -10,6 +10,7 @@ use Psalm\Internal\Analyzer\FunctionLikeAnalyzer;
|
||||
use Psalm\Internal\Analyzer\Statements\Expression\AssertionFinder;
|
||||
use Psalm\Internal\Analyzer\Statements\Expression\ExpressionIdentifier;
|
||||
use Psalm\Internal\Analyzer\Statements\Expression\Fetch\ConstFetchAnalyzer;
|
||||
use Psalm\Internal\Analyzer\Statements\Expression\IncludeAnalyzer;
|
||||
use Psalm\Internal\Analyzer\Statements\ExpressionAnalyzer;
|
||||
use Psalm\Internal\Analyzer\StatementsAnalyzer;
|
||||
use Psalm\Internal\Codebase\VariableUseGraph;
|
||||
@ -178,6 +179,22 @@ class NamedFunctionCallHandler
|
||||
|
||||
if ($var_id) {
|
||||
$context->phantom_files[$var_id] = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// literal string or (magic) const in file path
|
||||
$codebase = $statements_analyzer->getCodebase();
|
||||
$config = $codebase->config;
|
||||
$path_to_file = IncludeAnalyzer::getPathTo(
|
||||
$first_arg->value,
|
||||
$statements_analyzer->node_data,
|
||||
$statements_analyzer,
|
||||
$statements_analyzer->getFileName(),
|
||||
$config,
|
||||
);
|
||||
|
||||
if ($path_to_file) {
|
||||
$context->phantom_files[$path_to_file] = true;
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -231,6 +231,15 @@ class IncludeAnalyzer
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isset($context->phantom_files[$path_to_file])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$var_id = ExpressionIdentifier::getExtendedVarId($stmt->expr, null);
|
||||
if ($var_id && isset($context->phantom_files[$var_id])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$source = $statements_analyzer->getSource();
|
||||
|
||||
IssueBuffer::maybeAdd(
|
||||
|
Loading…
Reference in New Issue
Block a user