1
0
Fork 0

Removed fluent interface resolution

pull/247/head
Ivan Bozhanov 2017-01-21 17:59:19 +02:00
parent 7b4d0d1c60
commit af53973dd5
1 changed files with 8 additions and 33 deletions

View File

@ -479,17 +479,15 @@ class DefinitionResolver
} else { } else {
$classFqn = substr((string)$t->getFqsen(), 1); $classFqn = substr((string)$t->getFqsen(), 1);
} }
foreach ($this->getParentsDefinition($classFqn) as $parent) { $fqn = $classFqn . '->' . $expr->name;
$fqn = $parent->fqn . '->' . $expr->name; if ($expr instanceof Node\Expr\MethodCall) {
if ($expr instanceof Node\Expr\MethodCall) { $fqn .= '()';
$fqn .= '()'; }
} if ($def = $this->index->getDefinition($fqn)) {
if ($def = $this->index->getDefinition($fqn)) { if ($def->type instanceof Types\This || $def->type instanceof Types\Self_) {
if ($def->type instanceof Types\This || $def->type instanceof Types\Self_) { return $this->resolveExpressionNodeToType($expr->var);
return $this->resolveExpressionNodeToType($expr->var);
}
return $def->type;
} }
return $def->type;
} }
} }
} }
@ -655,29 +653,6 @@ class DefinitionResolver
return new Types\Mixed; return new Types\Mixed;
} }
/**
* Adds the FQNs of all parent classes to an array of FQNs of classes
*
* @param string $fqns
* @return Definition[]
*/
private function getParentsDefinition(string $fqn)
{
$def = $this->index->getDefinition($fqn);
while ($def) {
yield $def;
if ($def->extends) {
foreach ($def->extends as $parent) {
if (($tmp = $this->index->getDefinition($parent)) && $tmp->canBeInstantiated) {
$def = $tmp;
continue;
}
}
}
break;
}
}
/** /**
* Takes any class name node (from a static method call, or new node) and returns a Type object * Takes any class name node (from a static method call, or new node) and returns a Type object
* Resolves keywords like self, static and parent * Resolves keywords like self, static and parent