remove unneeded completion tests, add static definition test
parent
85b2ee8604
commit
1f827298c5
|
@ -1,11 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
class FooClass {
|
|
||||||
public function foo(): self {
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$fc = new FooClass();
|
|
||||||
$foo = $fc->foo();
|
|
||||||
$foo->
|
|
|
@ -1,12 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
class FooClass {
|
|
||||||
public static function staticFoo(): self {
|
|
||||||
return new FooClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function bar() { }
|
|
||||||
}
|
|
||||||
|
|
||||||
$foo = FooClass::staticFoo();
|
|
||||||
$foo->
|
|
|
@ -554,146 +554,6 @@ class CompletionTest extends TestCase
|
||||||
], true), $items);
|
], true), $items);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider foreachProvider
|
|
||||||
*/
|
|
||||||
public function testForeach(Position $position, array $expectedItems)
|
|
||||||
{
|
|
||||||
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/foreach.php');
|
|
||||||
$this->loader->open($completionUri, file_get_contents($completionUri));
|
|
||||||
$items = $this->textDocument->completion(
|
|
||||||
new TextDocumentIdentifier($completionUri),
|
|
||||||
$position
|
|
||||||
)->wait();
|
|
||||||
$this->assertCompletionsListSubset(new CompletionList($expectedItems, true), $items);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function foreachProvider(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'foreach value' => [
|
|
||||||
new Position(18, 6),
|
|
||||||
[
|
|
||||||
new CompletionItem(
|
|
||||||
'$value',
|
|
||||||
CompletionItemKind::VARIABLE,
|
|
||||||
'\\Foo\\Bar',
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
new TextEdit(new Range(new Position(18, 6), new Position(18, 6)), 'alue')
|
|
||||||
),
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'foreach value resolved' => [
|
|
||||||
new Position(19, 12),
|
|
||||||
[
|
|
||||||
new CompletionItem(
|
|
||||||
'foo',
|
|
||||||
CompletionItemKind::PROPERTY,
|
|
||||||
'mixed'
|
|
||||||
),
|
|
||||||
new CompletionItem(
|
|
||||||
'test',
|
|
||||||
CompletionItemKind::METHOD,
|
|
||||||
'\\Foo\\Bar[]'
|
|
||||||
),
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'array creation with multiple objects' => [
|
|
||||||
new Position(23, 5),
|
|
||||||
[
|
|
||||||
new CompletionItem(
|
|
||||||
'$value',
|
|
||||||
CompletionItemKind::VARIABLE,
|
|
||||||
'\\Foo\\Bar|\\stdClass',
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
new TextEdit(new Range(new Position(23, 5), new Position(23, 5)), 'value')
|
|
||||||
),
|
|
||||||
new CompletionItem(
|
|
||||||
'$key',
|
|
||||||
CompletionItemKind::VARIABLE,
|
|
||||||
'int',
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
new TextEdit(new Range(new Position(23, 5), new Position(23, 5)), 'key')
|
|
||||||
),
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'array creation with string/int keys and object values' => [
|
|
||||||
new Position(27, 5),
|
|
||||||
[
|
|
||||||
new CompletionItem(
|
|
||||||
'$value',
|
|
||||||
CompletionItemKind::VARIABLE,
|
|
||||||
'\\Foo\\Bar',
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
new TextEdit(new Range(new Position(27, 5), new Position(27, 5)), 'value')
|
|
||||||
),
|
|
||||||
new CompletionItem(
|
|
||||||
'$key',
|
|
||||||
CompletionItemKind::VARIABLE,
|
|
||||||
'string|int',
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
new TextEdit(new Range(new Position(27, 5), new Position(27, 5)), 'key')
|
|
||||||
),
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'array creation with only string keys' => [
|
|
||||||
new Position(31, 5),
|
|
||||||
[
|
|
||||||
new CompletionItem(
|
|
||||||
'$value',
|
|
||||||
CompletionItemKind::VARIABLE,
|
|
||||||
'\\Foo\\Bar',
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
new TextEdit(new Range(new Position(31, 5), new Position(31, 5)), 'value')
|
|
||||||
),
|
|
||||||
new CompletionItem(
|
|
||||||
'$key',
|
|
||||||
CompletionItemKind::VARIABLE,
|
|
||||||
'string',
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
new TextEdit(new Range(new Position(31, 5), new Position(31, 5)), 'key')
|
|
||||||
),
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'foreach function call' => [
|
|
||||||
new Position(35, 5),
|
|
||||||
[
|
|
||||||
new CompletionItem(
|
|
||||||
'$value',
|
|
||||||
CompletionItemKind::VARIABLE,
|
|
||||||
'\\Foo\\Bar',
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
new TextEdit(new Range(new Position(35, 5), new Position(35, 5)), 'value')
|
|
||||||
),
|
|
||||||
]
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testMethodReturnType()
|
public function testMethodReturnType()
|
||||||
{
|
{
|
||||||
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/method_return_type.php');
|
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/method_return_type.php');
|
||||||
|
@ -716,28 +576,6 @@ class CompletionTest extends TestCase
|
||||||
], true), $items);
|
], true), $items);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMethodReturnSelf()
|
|
||||||
{
|
|
||||||
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/method_return_self.php');
|
|
||||||
$this->loader->open($completionUri, file_get_contents($completionUri));
|
|
||||||
$items = $this->textDocument->completion(
|
|
||||||
new TextDocumentIdentifier($completionUri),
|
|
||||||
new Position(10, 6)
|
|
||||||
)->wait();
|
|
||||||
$this->assertCompletionsListSubset(new CompletionList([
|
|
||||||
new CompletionItem(
|
|
||||||
'foo',
|
|
||||||
CompletionItemKind::METHOD,
|
|
||||||
'\FooClass',
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null
|
|
||||||
)
|
|
||||||
], true), $items);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testStaticMethodReturnType()
|
public function testStaticMethodReturnType()
|
||||||
{
|
{
|
||||||
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/static_method_return_type.php');
|
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/static_method_return_type.php');
|
||||||
|
@ -760,28 +598,6 @@ 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) {
|
||||||
|
|
|
@ -5,5 +5,7 @@ class FooClass {
|
||||||
return new FooClass();
|
return new FooClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function staticSelf(): self { }
|
||||||
|
|
||||||
public function bar() { }
|
public function bar() { }
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,31 @@
|
||||||
"parameters": []
|
"parameters": []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"FooClass::staticSelf()": {
|
||||||
|
"fqn": "FooClass::staticSelf()",
|
||||||
|
"extends": [],
|
||||||
|
"isMember": true,
|
||||||
|
"roamed": false,
|
||||||
|
"isStatic": true,
|
||||||
|
"canBeInstantiated": false,
|
||||||
|
"symbolInformation": {
|
||||||
|
"name": "staticSelf",
|
||||||
|
"kind": 6,
|
||||||
|
"location": {
|
||||||
|
"uri": "./staticMethodReturnType.php"
|
||||||
|
},
|
||||||
|
"containerName": "FooClass"
|
||||||
|
},
|
||||||
|
"type__tostring": "\\FooClass",
|
||||||
|
"type": {},
|
||||||
|
"declarationLine": "public static function staticSelf(): self { }",
|
||||||
|
"documentation": null,
|
||||||
|
"signatureInformation": {
|
||||||
|
"label": "()",
|
||||||
|
"documentation": null,
|
||||||
|
"parameters": []
|
||||||
|
}
|
||||||
|
},
|
||||||
"FooClass->bar()": {
|
"FooClass->bar()": {
|
||||||
"fqn": "FooClass->bar()",
|
"fqn": "FooClass->bar()",
|
||||||
"extends": [],
|
"extends": [],
|
||||||
|
|
Loading…
Reference in New Issue