1
0
Fork 0

Fix definition for method return type (#76)

pull/110/head
Michal Niewrzal 2016-10-21 16:51:11 +02:00 committed by Felix Becker
parent b16674d394
commit a19d225a7a
6 changed files with 17 additions and 6 deletions

View File

@ -55,7 +55,7 @@ class TestClass implements TestInterface
* @param TestClass $testParameter Lorem sunt velit incididunt mollit
* @return TestClass
*/
public function testMethod($testParameter)
public function testMethod($testParameter): TestInterface
{
$this->testProperty = $testParameter;
}

View File

@ -55,7 +55,7 @@ class TestClass implements TestInterface
* @param TestClass $testParameter Lorem sunt velit incididunt mollit
* @return TestClass
*/
public function testMethod($testParameter)
public function testMethod($testParameter): TestInterface
{
$this->testProperty = $testParameter;
}

View File

@ -31,7 +31,7 @@ function getReferencedFqn(Node $node)
$node instanceof Node\Name && (
$parent instanceof Node\Stmt\ClassLike
|| $parent instanceof Node\Param
|| $parent instanceof Node\Stmt\Function_
|| $parent instanceof Node\FunctionLike
|| $parent instanceof Node\Expr\StaticCall
|| $parent instanceof Node\Expr\ClassConstFetch
|| $parent instanceof Node\Expr\StaticPropertyFetch

View File

@ -104,7 +104,8 @@ abstract class ServerTestCase extends TestCase
6 => new Location($useUri, new Range(new Position( 4, 4), new Position( 4, 27))), // use TestNamespace\TestClass;
],
'TestNamespace\\TestInterface' => [
0 => new Location($symbolsUri, new Range(new Position(20, 27), new Position(20, 40))) // class TestClass implements TestInterface
0 => new Location($symbolsUri, new Range(new Position(20, 27), new Position(20, 40))), // class TestClass implements TestInterface
1 => new Location($symbolsUri, new Range(new Position(57, 48), new Position(57, 61))) // public function testMethod($testParameter): TestInterface
],
'TestNamespace\\TestClass::TEST_CLASS_CONST' => [
0 => new Location($symbolsUri, new Range(new Position(48, 13), new Position(48, 35))), // echo self::TEST_CLASS_CONSTANT
@ -141,7 +142,8 @@ abstract class ServerTestCase extends TestCase
5 => new Location($globalReferencesUri, new Range(new Position(21, 37), new Position(21, 46))), // function whatever(TestClass $param): TestClass
],
'TestInterface' => [
0 => new Location($globalSymbolsUri, new Range(new Position(20, 27), new Position(20, 40))) // class TestClass implements TestInterface
0 => new Location($globalSymbolsUri, new Range(new Position(20, 27), new Position(20, 40))), // class TestClass implements TestInterface
1 => new Location($globalSymbolsUri, new Range(new Position(57, 48), new Position(57, 61))) // public function testMethod($testParameter): TestInterface
],
'TestClass::TEST_CLASS_CONST' => [
0 => new Location($globalSymbolsUri, new Range(new Position(48, 13), new Position(48, 35))), // echo self::TEST_CLASS_CONSTANT

View File

@ -165,6 +165,15 @@ class GlobalTest extends ServerTestCase
$this->assertEquals($this->getDefinitionLocation('TestClass'), $result);
}
public function testDefinitionForMethodReturnTypeHints()
{
// public function testMethod($testParameter): TestInterface
// Get definition for TestInterface
$reference = $this->getReferenceLocations('TestInterface')[1];
$result = $this->textDocument->definition(new TextDocumentIdentifier($reference->uri), $reference->range->start);
$this->assertEquals($this->getDefinitionLocation('TestInterface'), $result);
}
public function testDefinitionForParams()
{
// echo $param;

View File

@ -30,7 +30,7 @@ class HoverTest extends ServerTestCase
$reference = $this->getReferenceLocations('TestClass::testMethod()')[0];
$result = $this->textDocument->hover(new TextDocumentIdentifier($reference->uri), $reference->range->end);
$this->assertEquals(new Hover([
new MarkedString('php', "<?php\npublic function testMethod(\$testParameter)"),
new MarkedString('php', "<?php\npublic function testMethod(\$testParameter) : \TestInterface"),
'Non culpa nostrud mollit esse sunt laboris in irure ullamco cupidatat amet.'
], $reference->range), $result);
}