1
0
Fork 0

now looking up the hierachy chain

pull/421/head
Ivan Bozhanov 2017-06-19 15:19:14 +03:00
parent 3d196ede54
commit 9fb18413f5
3 changed files with 21 additions and 17 deletions

View File

@ -1,10 +1,14 @@
<?php
class Parent1 {
class Grand
{
/** @return $this */
public function foo() {
return $this;
}
}
class Parent1 extends Grand {
}
class Child extends Parent1 {
public function bar() {

View File

@ -670,16 +670,19 @@ class DefinitionResolver
if ($expr->parent instanceof Node\Expression\CallExpression) {
$add .= '()';
}
$fqn = $classFqn . $add;
$def = $this->index->getDefinition($fqn);
if ($def !== null) {
return $def->type;
} else {
$classDef = $this->index->getDefinition($classFqn);
if ($classDef !== null && is_array($classDef->extends)) {
foreach ($classDef->extends as $parent) {
$def = $this->index->getDefinition($parent . $add);
$lookupDefinition = function (string $base, string $add) use (&$lookupDefinition) {
$def = $this->index->getDefinition($base . $add);
if ($def !== null) {
yield $def;
}
$baseDef = $this->index->getDefinition($base);
if ($baseDef !== null && is_array($baseDef->extends)) {
foreach ($baseDef->extends as $name) {
yield from $lookupDefinition($name, $add);
}
}
};
foreach ($lookupDefinition($classFqn, $add) as $def) {
if ($def->type instanceof Types\This) {
return new Types\Object_(new Fqsen('\\' . $classFqn));
}
@ -687,9 +690,6 @@ class DefinitionResolver
}
}
}
}
}
}
// SCOPED PROPERTY ACCESS EXPRESSION
if ($expr instanceof Node\Expression\ScopedPropertyAccessExpression) {

View File

@ -660,7 +660,7 @@ class CompletionTest extends TestCase
$this->loader->open($completionUri, file_get_contents($completionUri));
$items = $this->textDocument->completion(
new TextDocumentIdentifier($completionUri),
new Position(10, 19)
new Position(14, 19)
)->wait();
$this->assertEquals(new CompletionList([
new CompletionItem(