1
0
Fork 0

revert return_type test and add specific return_self test

pull/550/head
Philip Nelson 2017-12-11 20:03:40 +11:00
parent 4186d8f9ce
commit a153d71266
4 changed files with 37 additions and 3 deletions

View File

@ -0,0 +1,12 @@
<?php
class FooClass {
public static function staticFoo(): self {
return new FooClass();
}
public function bar() { }
}
$foo = FooClass::staticFoo();
$foo->

View File

@ -1,7 +1,7 @@
<?php
class FooClass {
public static function staticFoo(): self {
public static function staticFoo(): FooClass {
return new FooClass();
}
@ -9,4 +9,4 @@ class FooClass {
}
$foo = FooClass::staticFoo();
$foo->
$foo->

View File

@ -620,6 +620,28 @@ class CompletionTest extends TestCase
], true), $items);
}
public function testStaticMethodReturnSelf()
{
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/static_method_return_self.php');
$this->loader->open($completionUri, file_get_contents($completionUri));
$items = $this->textDocument->completion(
new TextDocumentIdentifier($completionUri),
new Position(11, 6)
)->wait();
$this->assertCompletionsListSubset(new CompletionList([
new CompletionItem(
'bar',
CompletionItemKind::METHOD,
'mixed',
null,
null,
null,
null,
null
)
], true), $items);
}
private function assertCompletionsListSubset(CompletionList $subsetList, CompletionList $list)
{
foreach ($subsetList->items as $expectedItem) {

View File

@ -69,7 +69,7 @@
},
"containerName": "Fixtures\\Prophecy\\WithReturnTypehints"
},
"type__tostring": "\\self",
"type__tostring": "\\Fixtures\\Prophecy\\WithReturnTypehints",
"type": {},
"declarationLine": "public function getSelf(): self {",
"documentation": null