now looking up the hierachy chain
parent
3d196ede54
commit
9fb18413f5
|
@ -1,10 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
class Parent1 {
|
class Grand
|
||||||
|
{
|
||||||
/** @return $this */
|
/** @return $this */
|
||||||
public function foo() {
|
public function foo() {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
class Parent1 extends Grand {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
class Child extends Parent1 {
|
class Child extends Parent1 {
|
||||||
public function bar() {
|
public function bar() {
|
||||||
|
|
|
@ -670,16 +670,19 @@ class DefinitionResolver
|
||||||
if ($expr->parent instanceof Node\Expression\CallExpression) {
|
if ($expr->parent instanceof Node\Expression\CallExpression) {
|
||||||
$add .= '()';
|
$add .= '()';
|
||||||
}
|
}
|
||||||
$fqn = $classFqn . $add;
|
$lookupDefinition = function (string $base, string $add) use (&$lookupDefinition) {
|
||||||
$def = $this->index->getDefinition($fqn);
|
$def = $this->index->getDefinition($base . $add);
|
||||||
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 !== 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) {
|
if ($def->type instanceof Types\This) {
|
||||||
return new Types\Object_(new Fqsen('\\' . $classFqn));
|
return new Types\Object_(new Fqsen('\\' . $classFqn));
|
||||||
}
|
}
|
||||||
|
@ -687,9 +690,6 @@ class DefinitionResolver
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SCOPED PROPERTY ACCESS EXPRESSION
|
// SCOPED PROPERTY ACCESS EXPRESSION
|
||||||
if ($expr instanceof Node\Expression\ScopedPropertyAccessExpression) {
|
if ($expr instanceof Node\Expression\ScopedPropertyAccessExpression) {
|
||||||
|
|
|
@ -660,7 +660,7 @@ class CompletionTest extends TestCase
|
||||||
$this->loader->open($completionUri, file_get_contents($completionUri));
|
$this->loader->open($completionUri, file_get_contents($completionUri));
|
||||||
$items = $this->textDocument->completion(
|
$items = $this->textDocument->completion(
|
||||||
new TextDocumentIdentifier($completionUri),
|
new TextDocumentIdentifier($completionUri),
|
||||||
new Position(10, 19)
|
new Position(14, 19)
|
||||||
)->wait();
|
)->wait();
|
||||||
$this->assertEquals(new CompletionList([
|
$this->assertEquals(new CompletionList([
|
||||||
new CompletionItem(
|
new CompletionItem(
|
||||||
|
|
Loading…
Reference in New Issue