Try to lookup base class member while resolveExpressionNodeToType
parent
420c22bd93
commit
c58407e8ad
|
@ -679,6 +679,29 @@ class DefinitionResolver
|
||||||
return new Types\Object_(new Fqsen('\\' . $classFqn));
|
return new Types\Object_(new Fqsen('\\' . $classFqn));
|
||||||
}
|
}
|
||||||
return $def->type;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue