1
0
Fork 0
pull/679/merge
letynsoft 2018-12-22 22:58:26 +00:00 committed by GitHub
commit 6832785338
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 7 deletions

View File

@ -41,3 +41,6 @@ TestClass::$staticTestProperty[123]->testProperty;
$child = new ChildClass;
echo $child->testMethod();
ChildClass::staticTestMethod();
ChildClass::$staticTestProperty[123]->testProperty;

View File

@ -41,3 +41,6 @@ TestClass::$staticTestProperty[123]->testProperty;
$child = new ChildClass;
echo $child->testMethod();
ChildClass::staticTestMethod();
ChildClass::$staticTestProperty[123]->testProperty;

View File

@ -499,6 +499,8 @@ class DefinitionResolver
} elseif ($scoped->scopeResolutionQualifier instanceof Node\QualifiedName) {
$className = $scoped->scopeResolutionQualifier->getResolvedName();
}
$origName = null;
$nameSuffix = null;
if ($scoped->memberName instanceof Node\Expression\Variable) {
if ($scoped->parent instanceof Node\Expression\CallExpression) {
return null;
@ -507,13 +509,29 @@ class DefinitionResolver
if (empty($memberName)) {
return null;
}
$name = (string)$className . '::$' . $memberName;
$nameSuffix = '::$' . $memberName;
} else {
$name = (string)$className . '::' . $scoped->memberName->getText($scoped->getFileContents());
$nameSuffix = '::' . $scoped->memberName->getText($scoped->getFileContents());
}
if ($scoped->parent instanceof Node\Expression\CallExpression) {
$name .= '()';
$nameSuffix .= '()';
}
do {
$name = (string)$className . $nameSuffix;
if ($origName === null) {
$origName = $name;
}
$definition = $this->index->getDefinition($name);
if (!!$definition) {
break;
} else {
$class = $this->index->getDefinition((string)$className);
if ($class === null || empty($class->extends)) {
return $origName;
}
$className = $class->extends[0];
}
} while (true);
return $name;
}

View File

@ -155,10 +155,12 @@ abstract class ServerTestCase extends TestCase
],
'TestNamespace\\TestClass::staticTestProperty' => [
0 => new Location($referencesUri, new Range(new Position( 8, 16), new Position( 8, 35))), // echo TestClass::$staticTestProperty;
1 => new Location($referencesUri, new Range(new Position(39, 11), new Position(39, 30))) // TestClass::$staticTestProperty[123]->testProperty;
1 => new Location($referencesUri, new Range(new Position(39, 11), new Position(39, 30))), // TestClass::$staticTestProperty[123]->testProperty;
2 => new Location($referencesUri, new Range(new Position(45, 12), new Position(45, 31))) // ChildClass::$staticTestProperty[123]->testProperty;
],
'TestNamespace\\TestClass::staticTestMethod()' => [
0 => new Location($referencesUri, new Range(new Position( 7, 0), new Position( 7, 27)))
0 => new Location($referencesUri, new Range(new Position( 7, 0), new Position( 7, 27))),
1 => new Location($referencesUri, new Range(new Position(44, 0), new Position(44, 28)))
],
'TestNamespace\\TestClass::testMethod()' => [
0 => new Location($referencesUri, new Range(new Position( 5, 0), new Position( 5, 16))), // $obj->testMethod();
@ -209,10 +211,12 @@ abstract class ServerTestCase extends TestCase
],
'TestClass::staticTestProperty' => [
0 => new Location($globalReferencesUri, new Range(new Position( 8, 16), new Position( 8, 35))), // echo TestClass::$staticTestProperty;
1 => new Location($globalReferencesUri, new Range(new Position(39, 11), new Position(39, 30))) // TestClass::$staticTestProperty[123]->testProperty;
1 => new Location($globalReferencesUri, new Range(new Position(39, 11), new Position(39, 30))), // TestClass::$staticTestProperty[123]->testProperty;
2 => new Location($globalReferencesUri, new Range(new Position(45, 12), new Position(45, 31))) // ChildClass::$staticTestProperty[123]->testProperty;
],
'TestClass::staticTestMethod()' => [
0 => new Location($globalReferencesUri, new Range(new Position( 7, 0), new Position( 7, 27)))
0 => new Location($globalReferencesUri, new Range(new Position( 7, 0), new Position( 7, 27))),
1 => new Location($globalReferencesUri, new Range(new Position(44, 0), new Position(44, 28)))
],
'TestClass::testMethod()' => [
0 => new Location($globalReferencesUri, new Range(new Position( 5, 0), new Position( 5, 16))), // $obj->testMethod();