1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-12 09:19:40 +01:00

method_id can be string (why, when?)

This commit is contained in:
Olle 2020-06-30 16:02:48 +00:00
parent 1aec75292a
commit ee9a7c00fe

View File

@ -5,6 +5,7 @@ use PhpParser;
use Psalm\Internal\Analyzer\Statements\ExpressionAnalyzer; use Psalm\Internal\Analyzer\Statements\ExpressionAnalyzer;
use Psalm\Internal\Analyzer\Statements\Expression\ExpressionIdentifier; use Psalm\Internal\Analyzer\Statements\Expression\ExpressionIdentifier;
use Psalm\Internal\Analyzer\StatementsAnalyzer; use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\Internal\MethodIdentifier;
use Psalm\CodeLocation; use Psalm\CodeLocation;
use Psalm\Context; use Psalm\Context;
use Psalm\Issue\InvalidMethodCall; use Psalm\Issue\InvalidMethodCall;
@ -406,8 +407,8 @@ class MethodCallAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\
if ($lhs_var_id) { if ($lhs_var_id) {
// TODO: Always defined? Always correct? // TODO: Always defined? Always correct?
/** @var \Psalm\Internal\MethodIdentifier */
$method_id = $result->existent_method_ids[0]; $method_id = $result->existent_method_ids[0];
if ($method_id instanceof MethodIdentifier) {
// TODO: When should a method have a storage? // TODO: When should a method have a storage?
if ($codebase->methods->hasStorage($method_id)) { if ($codebase->methods->hasStorage($method_id)) {
$storage = $codebase->methods->getStorage($method_id); $storage = $codebase->methods->getStorage($method_id);
@ -416,6 +417,9 @@ class MethodCallAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\
$context->vars_in_scope[$lhs_var_id] = $self_out_type; $context->vars_in_scope[$lhs_var_id] = $self_out_type;
} }
} }
} else {
// TODO: When is method_id a string?
}
} }
return true; return true;