1
0
Fork 0

Try to lookup base class member while resolveExpressionNodeToType

pull/483/head
Fuyao Zhao 2017-06-15 05:28:49 +08:00 committed by Alan Li
parent 420c22bd93
commit c58407e8ad
1 changed files with 23 additions and 0 deletions

View File

@ -679,6 +679,29 @@ class DefinitionResolver
return new Types\Object_(new Fqsen('\\' . $classFqn));
}
return $def->type;
$memberSuffix = '->' . $expr->name;
if ($expr instanceof Node\Expr\MethodCall) {
$memberSuffix .= '()';
}
// Find the right class that implements the member
$implementorFqns = [$classFqn];
while ($implementorFqn = array_shift($implementorFqns)) {
// If the member FQN exists, return it
$def = $this->index->getDefinition($implementorFqn . $memberSuffix);
if ($def) {
return $def->type;
}
// Get Definition of implementor class
$implementorDef = $this->index->getDefinition($implementorFqn);
// If it doesn't exist, return the initial guess
if ($implementorDef === null) {
break;
}
// Repeat for parent class
if ($implementorDef->extends) {
foreach ($implementorDef->extends as $extends) {
$implementorFqns[] = $extends;
}
}
}