Try to lookup base class member while resolveExpressionNodeToType
parent
8d1732ed02
commit
51d6128cde
|
@ -656,13 +656,31 @@ class DefinitionResolver
|
||||||
} else {
|
} else {
|
||||||
$classFqn = substr((string)$t->getFqsen(), 1);
|
$classFqn = substr((string)$t->getFqsen(), 1);
|
||||||
}
|
}
|
||||||
$fqn = $classFqn . '->' . $expr->memberName->getText($expr->getFileContents());
|
|
||||||
if ($expr->parent instanceof Node\Expression\CallExpression) {
|
$memberSuffix = '->' . $expr->memberName->getText($expr->getFileContents());
|
||||||
$fqn .= '()';
|
if ($expr instanceof Node\Expression\CallExpression) {
|
||||||
|
$memberSuffix .= '()';
|
||||||
}
|
}
|
||||||
$def = $this->index->getDefinition($fqn);
|
|
||||||
if ($def !== null) {
|
// Find the right class that implements the member
|
||||||
return $def->type;
|
$implementorFqns = [$classFqn];
|
||||||
|
while ($implementorFqn = array_shift($implementorFqns)) {
|
||||||
|
// If the member FQN exists, return it
|
||||||
|
if ($def = $this->index->getDefinition($implementorFqn . $memberSuffix)) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue