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

Make sure to remember correct positions of @var references

This commit is contained in:
Brown 2020-04-27 00:05:20 -04:00
parent 10f3bef743
commit f91e94b64e
6 changed files with 29 additions and 8 deletions

View File

@ -144,7 +144,10 @@ class AssignmentAnalyzer
new CodeLocation($statements_analyzer->getSource(), $assign_var),
$statements_analyzer->getSuppressedIssues(),
[],
false
false,
false,
false,
$context->calling_method_id
);
$type_location = null;

View File

@ -979,7 +979,11 @@ class FunctionCallAnalyzer extends CallAnalyzer
$statements_analyzer,
new CodeLocation($statements_analyzer->getSource(), $stmt),
$statements_analyzer->getSuppressedIssues(),
$context->phantom_classes
$context->phantom_classes,
true,
false,
false,
$context->calling_method_id
);
}
}

View File

@ -197,7 +197,11 @@ class MethodCallReturnTypeFetcher
$statements_analyzer,
new CodeLocation($statements_analyzer, $stmt),
$statements_analyzer->getSuppressedIssues(),
$context->phantom_classes
$context->phantom_classes,
true,
false,
false,
$context->calling_method_id
);
}
} else {

View File

@ -979,7 +979,11 @@ class StaticCallAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\
$statements_analyzer,
new CodeLocation($source, $stmt),
$statements_analyzer->getSuppressedIssues(),
$context->phantom_classes
$context->phantom_classes,
true,
false,
false,
$context->calling_method_id
);
}
}

View File

@ -63,6 +63,8 @@ class TypeChecker extends NodeVisitor
/** @var bool */
private $has_errors = false;
private $calling_method_id;
/**
* @param StatementsSource $source
* @param CodeLocation $code_location
@ -79,7 +81,8 @@ class TypeChecker extends NodeVisitor
array $phantom_classes = [],
bool $inferred = true,
bool $inherited = false,
bool $prevent_template_covariance = false
bool $prevent_template_covariance = false,
?string $calling_method_id = null
) {
$this->source = $source;
$this->code_location = $code_location;
@ -88,6 +91,7 @@ class TypeChecker extends NodeVisitor
$this->inferred = $inferred;
$this->inherited = $inherited;
$this->prevent_template_covariance = $prevent_template_covariance;
$this->calling_method_id = $calling_method_id;
}
/**
@ -156,7 +160,7 @@ class TypeChecker extends NodeVisitor
$atomic->value,
$this->code_location,
$this->source->getFQCLN(),
null,
$this->calling_method_id,
$this->suppressed_issues,
$this->inferred,
false,

View File

@ -1620,7 +1620,8 @@ class Union implements TypeNode
array $phantom_classes = [],
bool $inferred = true,
bool $inherited = false,
bool $prevent_template_covariance = false
bool $prevent_template_covariance = false,
?string $calling_method_id = null
) : bool {
if ($this->checked) {
return true;
@ -1633,7 +1634,8 @@ class Union implements TypeNode
$phantom_classes,
$inferred,
$inherited,
$prevent_template_covariance
$prevent_template_covariance,
$calling_method_id
);
$checker->traverseArray($this->types);