now looking up the hierachy chain
parent
3d196ede54
commit
9fb18413f5
|
@ -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() {
|
||||
|
|
|
@ -670,23 +670,23 @@ 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);
|
||||
if ($def !== null) {
|
||||
if ($def->type instanceof Types\This) {
|
||||
return new Types\Object_(new Fqsen('\\' . $classFqn));
|
||||
}
|
||||
return $def->type;
|
||||
}
|
||||
$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));
|
||||
}
|
||||
return $def->type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue