revert return_type test and add specific return_self test
parent
4186d8f9ce
commit
a153d71266
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
class FooClass {
|
||||
public static function staticFoo(): self {
|
||||
return new FooClass();
|
||||
}
|
||||
|
||||
public function bar() { }
|
||||
}
|
||||
|
||||
$foo = FooClass::staticFoo();
|
||||
$foo->
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
class FooClass {
|
||||
public static function staticFoo(): self {
|
||||
public static function staticFoo(): FooClass {
|
||||
return new FooClass();
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
},
|
||||
"containerName": "Fixtures\\Prophecy\\WithReturnTypehints"
|
||||
},
|
||||
"type__tostring": "\\self",
|
||||
"type__tostring": "\\Fixtures\\Prophecy\\WithReturnTypehints",
|
||||
"type": {},
|
||||
"declarationLine": "public function getSelf(): self {",
|
||||
"documentation": null
|
||||
|
|
Loading…
Reference in New Issue