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
|
<?php
|
||||||
|
|
||||||
class FooClass {
|
class FooClass {
|
||||||
public static function staticFoo(): self {
|
public static function staticFoo(): FooClass {
|
||||||
return new FooClass();
|
return new FooClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -620,6 +620,28 @@ class CompletionTest extends TestCase
|
||||||
], true), $items);
|
], 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)
|
private function assertCompletionsListSubset(CompletionList $subsetList, CompletionList $list)
|
||||||
{
|
{
|
||||||
foreach ($subsetList->items as $expectedItem) {
|
foreach ($subsetList->items as $expectedItem) {
|
||||||
|
|
|
@ -69,7 +69,7 @@
|
||||||
},
|
},
|
||||||
"containerName": "Fixtures\\Prophecy\\WithReturnTypehints"
|
"containerName": "Fixtures\\Prophecy\\WithReturnTypehints"
|
||||||
},
|
},
|
||||||
"type__tostring": "\\self",
|
"type__tostring": "\\Fixtures\\Prophecy\\WithReturnTypehints",
|
||||||
"type": {},
|
"type": {},
|
||||||
"declarationLine": "public function getSelf(): self {",
|
"declarationLine": "public function getSelf(): self {",
|
||||||
"documentation": null
|
"documentation": null
|
||||||
|
|
Loading…
Reference in New Issue