2018-10-26 22:17:15 +02:00
|
|
|
<?php
|
|
|
|
namespace Psalm\Tests\LanguageServer;
|
|
|
|
|
|
|
|
use LanguageServerProtocol\Position;
|
2019-03-23 19:27:54 +01:00
|
|
|
use Psalm\Context;
|
2018-11-06 03:57:36 +01:00
|
|
|
use Psalm\Internal\Analyzer\ProjectAnalyzer;
|
2021-07-02 01:10:21 +02:00
|
|
|
use Psalm\Internal\Provider\FakeFileProvider;
|
2018-11-06 03:57:36 +01:00
|
|
|
use Psalm\Internal\Provider\Providers;
|
2021-12-04 21:55:53 +01:00
|
|
|
use Psalm\Tests\Internal\Provider\FakeFileReferenceCacheProvider;
|
2021-12-03 20:11:20 +01:00
|
|
|
use Psalm\Tests\Internal\Provider\ParserInstanceCacheProvider;
|
|
|
|
use Psalm\Tests\Internal\Provider\ProjectCacheProvider;
|
|
|
|
use Psalm\Tests\TestCase;
|
2019-03-23 19:27:54 +01:00
|
|
|
use Psalm\Tests\TestConfig;
|
2021-01-27 03:34:46 +01:00
|
|
|
use Psalm\Type;
|
2021-06-08 04:55:21 +02:00
|
|
|
|
2021-02-12 22:59:47 +01:00
|
|
|
use function count;
|
2018-10-26 22:17:15 +02:00
|
|
|
|
2021-12-03 20:11:20 +01:00
|
|
|
class CompletionTest extends TestCase
|
2018-10-26 22:17:15 +02:00
|
|
|
{
|
2021-12-05 18:51:26 +01:00
|
|
|
public function setUp(): void
|
2018-10-26 22:17:15 +02:00
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
2021-07-02 01:10:21 +02:00
|
|
|
$this->file_provider = new FakeFileProvider();
|
2018-10-26 22:17:15 +02:00
|
|
|
|
|
|
|
$config = new TestConfig();
|
|
|
|
|
|
|
|
$providers = new Providers(
|
|
|
|
$this->file_provider,
|
2021-12-03 20:11:20 +01:00
|
|
|
new ParserInstanceCacheProvider(),
|
2018-10-26 22:17:15 +02:00
|
|
|
null,
|
|
|
|
null,
|
2021-12-04 21:55:53 +01:00
|
|
|
new FakeFileReferenceCacheProvider(),
|
2021-12-03 20:11:20 +01:00
|
|
|
new ProjectCacheProvider()
|
2018-10-26 22:17:15 +02:00
|
|
|
);
|
|
|
|
|
2018-11-11 18:01:14 +01:00
|
|
|
$this->project_analyzer = new ProjectAnalyzer(
|
2018-10-26 22:17:15 +02:00
|
|
|
$config,
|
2019-06-09 18:37:28 +02:00
|
|
|
$providers
|
2018-10-26 22:17:15 +02:00
|
|
|
);
|
2021-11-27 01:06:33 +01:00
|
|
|
$this->project_analyzer->setPhpVersion('7.3', 'tests');
|
2019-02-24 07:33:25 +01:00
|
|
|
$this->project_analyzer->getCodebase()->store_node_types = true;
|
2018-10-26 22:17:15 +02:00
|
|
|
}
|
|
|
|
|
2020-09-12 17:24:05 +02:00
|
|
|
public function testCompletionOnThisWithNoAssignment(): void
|
2018-10-26 22:17:15 +02:00
|
|
|
{
|
2018-11-11 18:01:14 +01:00
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
2018-10-26 22:17:15 +02:00
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace B;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var int|null */
|
|
|
|
protected $a;
|
|
|
|
|
|
|
|
public function foo() {
|
|
|
|
$this->
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
);
|
|
|
|
|
2018-11-20 22:32:40 +01:00
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
2018-10-26 22:17:15 +02:00
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
2020-03-25 14:18:49 +01:00
|
|
|
$this->assertSame(['B\A&static', '->', 213], $codebase->getCompletionDataAtPosition('somefile.php', new Position(8, 31)));
|
2018-10-26 22:17:15 +02:00
|
|
|
}
|
|
|
|
|
2020-09-12 17:24:05 +02:00
|
|
|
public function testCompletionOnThisWithAssignmentBelow(): void
|
2018-10-26 22:17:15 +02:00
|
|
|
{
|
2018-11-11 18:01:14 +01:00
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
2018-10-26 22:17:15 +02:00
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace B;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var int|null */
|
|
|
|
protected $a;
|
|
|
|
|
|
|
|
public function foo() : self {
|
|
|
|
$this->
|
|
|
|
|
|
|
|
$a = "foo";
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
);
|
|
|
|
|
2018-11-20 22:32:40 +01:00
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
2018-10-26 22:17:15 +02:00
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
2020-03-25 14:18:49 +01:00
|
|
|
$this->assertSame(['B\A&static', '->', 220], $codebase->getCompletionDataAtPosition('somefile.php', new Position(8, 31)));
|
2018-10-26 22:17:15 +02:00
|
|
|
}
|
|
|
|
|
2020-09-12 17:24:05 +02:00
|
|
|
public function testCompletionOnThisWithIfBelow(): void
|
2018-10-26 22:17:15 +02:00
|
|
|
{
|
2018-11-11 18:01:14 +01:00
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
2018-10-26 22:17:15 +02:00
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace B;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var int|null */
|
|
|
|
protected $a;
|
|
|
|
|
|
|
|
public function foo() : self {
|
|
|
|
$this
|
|
|
|
|
|
|
|
if(rand(0, 1)) {}
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
);
|
|
|
|
|
2018-11-20 22:32:40 +01:00
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
2018-10-26 22:17:15 +02:00
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
|
|
|
$codebase->addTemporaryFileChanges(
|
|
|
|
'somefile.php',
|
2018-11-09 16:41:51 +01:00
|
|
|
'<?php
|
2018-10-26 22:17:15 +02:00
|
|
|
namespace B;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var int|null */
|
|
|
|
protected $a;
|
|
|
|
|
|
|
|
public function foo() : self {
|
|
|
|
$this->
|
|
|
|
|
|
|
|
if(rand(0, 1)) {}
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
);
|
2018-11-20 21:51:47 +01:00
|
|
|
$codebase->reloadFiles($this->project_analyzer, ['somefile.php']);
|
2018-11-11 18:01:14 +01:00
|
|
|
$codebase->analyzer->analyzeFiles($this->project_analyzer, 1, false);
|
2018-10-26 22:17:15 +02:00
|
|
|
|
2020-03-25 14:18:49 +01:00
|
|
|
$this->assertSame(['B\A&static', '->', 220], $codebase->getCompletionDataAtPosition('somefile.php', new Position(8, 31)));
|
2018-10-26 22:17:15 +02:00
|
|
|
}
|
|
|
|
|
2021-02-15 17:12:04 +01:00
|
|
|
public function testCompletionOnSelfWithIfBelow(): void
|
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace B;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var int|null */
|
|
|
|
protected static $a;
|
|
|
|
|
|
|
|
public function foo() : self {
|
|
|
|
A
|
|
|
|
|
|
|
|
if(rand(0, 1)) {}
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
|
|
|
$codebase->addTemporaryFileChanges(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace B;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var int|null */
|
|
|
|
protected static $a;
|
|
|
|
|
|
|
|
public function foo() : self {
|
|
|
|
A::
|
|
|
|
|
|
|
|
if(rand(0, 1)) {}
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
);
|
|
|
|
$codebase->reloadFiles($this->project_analyzer, ['somefile.php']);
|
|
|
|
$codebase->analyzer->analyzeFiles($this->project_analyzer, 1, false);
|
|
|
|
|
|
|
|
$this->assertSame(['B\A', '::', 223], $codebase->getCompletionDataAtPosition('somefile.php', new Position(8, 27)));
|
|
|
|
}
|
|
|
|
|
2021-02-15 21:32:35 +01:00
|
|
|
public function testCompletionOnSelfWithListBelow(): void
|
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace B;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var int|null */
|
|
|
|
protected static $a;
|
|
|
|
|
|
|
|
public function foo() : self {
|
|
|
|
A
|
|
|
|
|
|
|
|
list($a, $b) = $c;
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
|
|
|
$codebase->addTemporaryFileChanges(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace B;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var int|null */
|
|
|
|
protected static $a;
|
|
|
|
|
|
|
|
public function foo() : self {
|
|
|
|
A::
|
|
|
|
|
|
|
|
list($a, $b) = $c;
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
);
|
|
|
|
$codebase->reloadFiles($this->project_analyzer, ['somefile.php']);
|
|
|
|
$codebase->analyzer->analyzeFiles($this->project_analyzer, 1, false);
|
|
|
|
|
|
|
|
$this->assertSame(['B\A', '::', 223], $codebase->getCompletionDataAtPosition('somefile.php', new Position(8, 27)));
|
|
|
|
}
|
|
|
|
|
2020-09-12 17:24:05 +02:00
|
|
|
public function testCompletionOnThisProperty(): void
|
2018-10-26 22:17:15 +02:00
|
|
|
{
|
2018-11-11 18:01:14 +01:00
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
2018-10-26 22:17:15 +02:00
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace B;
|
|
|
|
|
|
|
|
class C {
|
|
|
|
public function otherFunction() : void
|
|
|
|
}
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var C */
|
|
|
|
protected $cee_me;
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
$this->cee_me = new C();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function foo() : void {
|
|
|
|
$this->cee_me->
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
);
|
|
|
|
|
2018-11-11 18:01:14 +01:00
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
2018-10-26 22:17:15 +02:00
|
|
|
|
2018-11-20 22:32:40 +01:00
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
2018-10-26 22:17:15 +02:00
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
2019-06-30 03:32:26 +02:00
|
|
|
$this->assertSame(['B\C', '->', 454], $codebase->getCompletionDataAtPosition('somefile.php', new Position(16, 39)));
|
2018-10-26 22:17:15 +02:00
|
|
|
}
|
2019-05-17 18:11:21 +02:00
|
|
|
|
2020-09-12 17:24:05 +02:00
|
|
|
public function testCompletionOnThisPropertyWithCharacter(): void
|
2019-05-17 18:38:29 +02:00
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace B;
|
|
|
|
|
|
|
|
class C {
|
|
|
|
public function otherFunction() : void
|
|
|
|
}
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var C */
|
|
|
|
protected $cee_me;
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
$this->cee_me = new C();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function foo() : void {
|
|
|
|
$this->cee_me->o
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
2019-06-30 03:32:26 +02:00
|
|
|
$this->assertSame(['B\C', '->', 455], $codebase->getCompletionDataAtPosition('somefile.php', new Position(16, 40)));
|
2019-05-17 18:38:29 +02:00
|
|
|
}
|
|
|
|
|
2020-09-12 17:24:05 +02:00
|
|
|
public function testCompletionOnThisPropertyWithAnotherCharacter(): void
|
2019-05-17 18:38:29 +02:00
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace B;
|
|
|
|
|
|
|
|
class C {
|
|
|
|
public function otherFunction() : void
|
|
|
|
}
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var C */
|
|
|
|
protected $cee_me;
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
$this->cee_me = new C();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function foo() : void {
|
|
|
|
$this->cee_me->ot
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
2019-07-05 22:24:00 +02:00
|
|
|
$this->assertNull($codebase->getCompletionDataAtPosition('somefile.php', new Position(16, 41)));
|
2019-05-17 18:38:29 +02:00
|
|
|
}
|
|
|
|
|
2020-09-12 17:24:05 +02:00
|
|
|
public function testCompletionOnTemplatedThisProperty(): void
|
2019-05-17 18:11:21 +02:00
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace B;
|
|
|
|
|
|
|
|
/** @template T */
|
|
|
|
class C {
|
|
|
|
/** @var T */
|
|
|
|
private $t;
|
|
|
|
|
|
|
|
/** @param T $t */
|
|
|
|
public function __construct($t) {
|
|
|
|
$this->t = $t;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function otherFunction() : void
|
|
|
|
}
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var C<string> */
|
|
|
|
protected $cee_me;
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
$this->cee_me = new C("hello");
|
|
|
|
}
|
|
|
|
|
|
|
|
public function foo() : void {
|
|
|
|
$this->cee_me->
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
|
|
|
$completion_data = $codebase->getCompletionDataAtPosition('somefile.php', new Position(25, 39));
|
|
|
|
|
2019-06-30 03:32:26 +02:00
|
|
|
$this->assertSame(['B\C<string>', '->', 726], $completion_data);
|
2019-05-17 18:11:21 +02:00
|
|
|
|
|
|
|
$completion_items = $codebase->getCompletionItemsForClassishThing($completion_data[0], $completion_data[1]);
|
|
|
|
|
|
|
|
$this->assertCount(3, $completion_items);
|
|
|
|
}
|
2019-05-17 18:38:29 +02:00
|
|
|
|
2020-09-12 17:24:05 +02:00
|
|
|
public function testCompletionOnMethodReturnValue(): void
|
2019-05-17 18:38:29 +02:00
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace B;
|
|
|
|
class A {
|
|
|
|
public function foo() : self {
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-12 19:34:49 +02:00
|
|
|
function foo(A $a) {
|
2019-05-17 18:38:29 +02:00
|
|
|
$a->foo()->
|
|
|
|
}
|
|
|
|
'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
2019-06-30 03:32:26 +02:00
|
|
|
$this->assertSame(['B\A', '->', 259], $codebase->getCompletionDataAtPosition('somefile.php', new Position(9, 31)));
|
2019-05-17 18:38:29 +02:00
|
|
|
}
|
|
|
|
|
2020-09-12 17:24:05 +02:00
|
|
|
public function testCompletionOnMethodArgument(): void
|
2019-05-17 18:38:29 +02:00
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace B;
|
|
|
|
class A {
|
|
|
|
public function foo(A $a) : self {
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class C {}
|
|
|
|
|
2019-06-12 19:34:49 +02:00
|
|
|
function bar(A $a, C $c) {
|
2019-05-17 18:38:29 +02:00
|
|
|
$a->foo($c->)
|
|
|
|
}
|
|
|
|
'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
2019-06-30 03:32:26 +02:00
|
|
|
$this->assertSame(['B\C', '->', 298], $codebase->getCompletionDataAtPosition('somefile.php', new Position(11, 32)));
|
2019-05-17 18:38:29 +02:00
|
|
|
}
|
|
|
|
|
2020-09-12 17:24:05 +02:00
|
|
|
public function testCompletionOnMethodReturnValueWithArgument(): void
|
2019-05-17 18:38:29 +02:00
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace B;
|
|
|
|
class A {
|
|
|
|
public function foo(A $a) : self {
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class C {}
|
|
|
|
|
2019-06-12 19:34:49 +02:00
|
|
|
function bar(A $a, C $c) {
|
2019-05-17 18:38:29 +02:00
|
|
|
$a->foo($c)->
|
|
|
|
}
|
|
|
|
'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
2019-06-30 03:32:26 +02:00
|
|
|
$this->assertSame(['B\A', '->', 299], $codebase->getCompletionDataAtPosition('somefile.php', new Position(11, 33)));
|
2019-05-17 18:38:29 +02:00
|
|
|
}
|
2019-06-12 12:30:48 +02:00
|
|
|
|
2020-09-12 17:24:05 +02:00
|
|
|
public function testCompletionOnVariableWithWhitespace(): void
|
2019-06-12 12:30:48 +02:00
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace B;
|
|
|
|
|
|
|
|
class A {}
|
|
|
|
|
2019-06-12 19:34:49 +02:00
|
|
|
function bar(A $a) {
|
2019-06-12 12:30:48 +02:00
|
|
|
$a ->
|
2019-06-12 19:34:49 +02:00
|
|
|
}'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
2019-06-30 03:32:26 +02:00
|
|
|
$this->assertSame(['B\A', '->', 126], $codebase->getCompletionDataAtPosition('somefile.php', new Position(6, 25)));
|
2019-06-12 19:34:49 +02:00
|
|
|
}
|
|
|
|
|
2020-09-12 17:24:05 +02:00
|
|
|
public function testCompletionOnVariableWithWhitespaceAndReturn(): void
|
2019-06-12 19:34:49 +02:00
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace B;
|
|
|
|
|
|
|
|
class A {}
|
2019-06-12 12:30:48 +02:00
|
|
|
|
2019-06-12 19:34:49 +02:00
|
|
|
function baz(A $a) {
|
2019-06-12 12:30:48 +02:00
|
|
|
$a
|
|
|
|
->
|
|
|
|
}
|
|
|
|
'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
2019-06-30 03:32:26 +02:00
|
|
|
$this->assertSame(['B\A', '->', 150], $codebase->getCompletionDataAtPosition('somefile.php', new Position(7, 26)));
|
2019-06-12 12:30:48 +02:00
|
|
|
}
|
|
|
|
|
2020-09-12 17:24:05 +02:00
|
|
|
public function testCompletionOnMethodReturnValueWithWhitespace(): void
|
2019-06-12 12:30:48 +02:00
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace B;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : self {
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-12 19:34:49 +02:00
|
|
|
function bar(A $a) {
|
2019-06-12 12:30:48 +02:00
|
|
|
$a->foo() ->
|
|
|
|
}
|
2019-06-12 19:34:49 +02:00
|
|
|
'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
2019-06-30 03:32:26 +02:00
|
|
|
$this->assertSame(['B\A', '->', 261], $codebase->getCompletionDataAtPosition('somefile.php', new Position(10, 32)));
|
2019-06-12 19:34:49 +02:00
|
|
|
}
|
|
|
|
|
2020-09-12 17:24:05 +02:00
|
|
|
public function testCompletionOnMethodReturnValueWithWhitespaceAndReturn(): void
|
2019-06-12 19:34:49 +02:00
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace B;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : self {
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|
2019-06-12 12:30:48 +02:00
|
|
|
|
2019-06-12 19:34:49 +02:00
|
|
|
function baz(A $a) {
|
2019-06-12 12:30:48 +02:00
|
|
|
$a->foo()
|
|
|
|
->
|
|
|
|
}
|
|
|
|
'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
2019-06-30 03:32:26 +02:00
|
|
|
$this->assertSame(['B\A', '->', 285], $codebase->getCompletionDataAtPosition('somefile.php', new Position(11, 26)));
|
2019-06-12 19:34:49 +02:00
|
|
|
}
|
|
|
|
|
2020-09-12 17:24:05 +02:00
|
|
|
public function testCompletionOnMethodReturnValueWhereParamIsClosure(): void
|
2019-06-12 19:34:49 +02:00
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace B;
|
|
|
|
|
|
|
|
class Collection {
|
|
|
|
public function map(callable $mapper) : self {
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function bar(Collection $a) {
|
|
|
|
$a->map(function ($foo) {})->
|
|
|
|
}'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
2019-06-30 03:32:26 +02:00
|
|
|
$this->assertSame(['B\Collection', '->', 312], $codebase->getCompletionDataAtPosition('somefile.php', new Position(10, 49)));
|
2019-06-12 19:34:49 +02:00
|
|
|
}
|
|
|
|
|
2020-09-12 17:24:05 +02:00
|
|
|
public function testCompletionOnMethodReturnValueWhereParamIsClosureWithStmt(): void
|
2019-06-12 19:34:49 +02:00
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace B;
|
|
|
|
|
|
|
|
class Collection {
|
|
|
|
public function map(callable $mapper) : self {
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function baz(Collection $a) {
|
|
|
|
$a->map(function ($foo) {return $foo;})->
|
|
|
|
}'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
2019-06-30 03:32:26 +02:00
|
|
|
$this->assertSame(['B\Collection', '->', 324], $codebase->getCompletionDataAtPosition('somefile.php', new Position(10, 61)));
|
2019-06-21 23:10:35 +02:00
|
|
|
}
|
|
|
|
|
2019-06-24 13:51:12 +02:00
|
|
|
public function testCursorPositionOnMethodCompletion(): void
|
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace B;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function bar(string $a) {
|
|
|
|
$this->
|
|
|
|
}
|
|
|
|
|
|
|
|
public function baz() {}
|
|
|
|
}'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
|
|
|
$completion_data = $codebase->getCompletionDataAtPosition('somefile.php', new Position(5, 31));
|
|
|
|
|
2020-03-25 14:18:49 +01:00
|
|
|
$this->assertSame(['B\A&static', '->', 146], $completion_data);
|
2019-06-24 13:51:12 +02:00
|
|
|
|
|
|
|
$completion_items = $codebase->getCompletionItemsForClassishThing($completion_data[0], $completion_data[1]);
|
|
|
|
|
|
|
|
$this->assertCount(2, $completion_items);
|
|
|
|
|
2019-07-05 22:24:00 +02:00
|
|
|
$this->assertSame('bar($0)', $completion_items[0]->insertText);
|
|
|
|
$this->assertSame('baz()', $completion_items[1]->insertText);
|
2019-06-24 13:51:12 +02:00
|
|
|
}
|
|
|
|
|
2020-09-12 17:24:05 +02:00
|
|
|
public function testCompletionOnNewExceptionWithoutNamespace(): void
|
2019-06-21 23:10:35 +02:00
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
function foo() : void {
|
|
|
|
throw new Ex
|
|
|
|
}'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
2021-02-15 05:25:13 +01:00
|
|
|
$this->assertSame(['*-Ex', 'symbol', 78], $codebase->getCompletionDataAtPosition('somefile.php', new Position(2, 32)));
|
2019-06-21 23:10:35 +02:00
|
|
|
}
|
|
|
|
|
2020-09-12 17:24:05 +02:00
|
|
|
public function testCompletionOnNewExceptionWithNamespaceNoUse(): void
|
2019-06-21 23:10:35 +02:00
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace Bar;
|
|
|
|
|
|
|
|
function foo() : void {
|
|
|
|
throw new Ex
|
|
|
|
}'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
2019-06-30 03:32:26 +02:00
|
|
|
$completion_data = $codebase->getCompletionDataAtPosition('somefile.php', new Position(4, 32));
|
|
|
|
|
|
|
|
$this->assertSame(
|
|
|
|
[
|
2021-02-15 05:25:13 +01:00
|
|
|
'*Bar-Ex',
|
2019-06-30 03:32:26 +02:00
|
|
|
'symbol',
|
2019-07-05 22:24:00 +02:00
|
|
|
110,
|
2019-06-30 03:32:26 +02:00
|
|
|
],
|
|
|
|
$completion_data
|
|
|
|
);
|
|
|
|
|
|
|
|
$completion_items = $codebase->getCompletionItemsForPartialSymbol($completion_data[0], $completion_data[2], 'somefile.php');
|
|
|
|
|
2019-09-22 06:58:30 +02:00
|
|
|
$this->assertNotEmpty($completion_items);
|
2019-06-30 03:32:26 +02:00
|
|
|
|
|
|
|
$this->assertSame('Exception', $completion_items[0]->label);
|
2019-06-30 17:12:50 +02:00
|
|
|
$this->assertSame('Exception', $completion_items[0]->insertText);
|
|
|
|
|
|
|
|
$this->assertNotNull($completion_items[0]->additionalTextEdits);
|
|
|
|
$this->assertCount(1, $completion_items[0]->additionalTextEdits);
|
2019-07-03 22:58:27 +02:00
|
|
|
$this->assertSame('use Exception;' . "\n" . "\n", $completion_items[0]->additionalTextEdits[0]->newText);
|
2019-06-30 17:12:50 +02:00
|
|
|
$this->assertSame(3, $completion_items[0]->additionalTextEdits[0]->range->start->line);
|
|
|
|
$this->assertSame(16, $completion_items[0]->additionalTextEdits[0]->range->start->character);
|
|
|
|
$this->assertSame(3, $completion_items[0]->additionalTextEdits[0]->range->end->line);
|
|
|
|
$this->assertSame(16, $completion_items[0]->additionalTextEdits[0]->range->end->character);
|
2019-06-21 23:10:35 +02:00
|
|
|
}
|
|
|
|
|
2020-09-12 17:24:05 +02:00
|
|
|
public function testCompletionOnNewExceptionWithNamespaceAndUse(): void
|
2019-06-21 23:10:35 +02:00
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace Bar;
|
|
|
|
|
|
|
|
use LogicException as LogEx;
|
|
|
|
|
|
|
|
class Alpha {}
|
|
|
|
class Antelope {}
|
|
|
|
|
|
|
|
function foo() : void {
|
2019-07-18 04:50:57 +02:00
|
|
|
new ArrayO
|
2019-06-21 23:10:35 +02:00
|
|
|
}'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
2019-07-18 04:50:57 +02:00
|
|
|
$completion_data = $codebase->getCompletionDataAtPosition('somefile.php', new Position(9, 30));
|
2019-06-21 23:10:35 +02:00
|
|
|
|
|
|
|
$this->assertSame(
|
|
|
|
[
|
2021-02-15 05:25:13 +01:00
|
|
|
'*Bar-ArrayO',
|
2019-06-21 23:10:35 +02:00
|
|
|
'symbol',
|
2019-07-18 04:50:57 +02:00
|
|
|
220,
|
2019-06-30 03:32:26 +02:00
|
|
|
],
|
|
|
|
$completion_data
|
|
|
|
);
|
|
|
|
|
|
|
|
$completion_items = $codebase->getCompletionItemsForPartialSymbol($completion_data[0], $completion_data[2], 'somefile.php');
|
|
|
|
|
2019-07-18 04:50:57 +02:00
|
|
|
$this->assertCount(1, $completion_items);
|
2019-06-30 17:12:50 +02:00
|
|
|
|
|
|
|
$this->assertNotNull($completion_items[0]->additionalTextEdits);
|
|
|
|
$this->assertCount(1, $completion_items[0]->additionalTextEdits);
|
2019-07-03 22:58:27 +02:00
|
|
|
$this->assertSame("\n" . 'use ArrayObject;', $completion_items[0]->additionalTextEdits[0]->newText);
|
2019-06-30 17:12:50 +02:00
|
|
|
$this->assertSame(3, $completion_items[0]->additionalTextEdits[0]->range->start->line);
|
|
|
|
$this->assertSame(44, $completion_items[0]->additionalTextEdits[0]->range->start->character);
|
|
|
|
$this->assertSame(3, $completion_items[0]->additionalTextEdits[0]->range->end->line);
|
|
|
|
$this->assertSame(44, $completion_items[0]->additionalTextEdits[0]->range->end->character);
|
2019-06-30 03:32:26 +02:00
|
|
|
}
|
|
|
|
|
2021-02-15 05:25:13 +01:00
|
|
|
public function testCompletionOnNamespaceWithFullyQualified(): void
|
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace Bar\Baz\Bat;
|
|
|
|
|
|
|
|
class B {
|
|
|
|
public function foo() : void {
|
|
|
|
\Ex
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
|
|
|
$completion_data = $codebase->getCompletionDataAtPosition('somefile.php', new Position(5, 27));
|
|
|
|
|
|
|
|
$this->assertSame(
|
|
|
|
[
|
|
|
|
'*\Ex',
|
|
|
|
'symbol',
|
|
|
|
150,
|
|
|
|
],
|
|
|
|
$completion_data
|
|
|
|
);
|
|
|
|
|
|
|
|
$completion_items = $codebase->getCompletionItemsForPartialSymbol($completion_data[0], $completion_data[2], 'somefile.php');
|
|
|
|
|
|
|
|
$this->assertNotEmpty($completion_items);
|
|
|
|
|
|
|
|
$this->assertSame('Exception', $completion_items[0]->label);
|
|
|
|
$this->assertSame('\Exception', $completion_items[0]->insertText);
|
|
|
|
|
|
|
|
$this->assertEmpty($completion_items[0]->additionalTextEdits);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testCompletionOnExceptionWithNamespaceAndUseInClass(): void
|
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace Bar\Baz\Bat;
|
|
|
|
|
|
|
|
class B {
|
|
|
|
public function foo() : void {
|
|
|
|
Ex
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
|
|
|
$completion_data = $codebase->getCompletionDataAtPosition('somefile.php', new Position(5, 26));
|
|
|
|
|
|
|
|
$this->assertSame(
|
|
|
|
[
|
|
|
|
'*Bar\Baz\Bat-Ex',
|
|
|
|
'symbol',
|
|
|
|
149,
|
|
|
|
],
|
|
|
|
$completion_data
|
|
|
|
);
|
|
|
|
|
|
|
|
$completion_items = $codebase->getCompletionItemsForPartialSymbol($completion_data[0], $completion_data[2], 'somefile.php');
|
|
|
|
|
|
|
|
$this->assertNotEmpty($completion_items);
|
|
|
|
|
|
|
|
$this->assertSame('Exception', $completion_items[0]->label);
|
|
|
|
$this->assertSame('Exception', $completion_items[0]->insertText);
|
|
|
|
|
|
|
|
$this->assertNotNull($completion_items[0]->additionalTextEdits);
|
|
|
|
$this->assertCount(1, $completion_items[0]->additionalTextEdits);
|
|
|
|
}
|
|
|
|
|
2021-02-12 22:59:47 +01:00
|
|
|
public function testCompletionForFunctionNames(): void
|
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace Bar;
|
|
|
|
|
2021-02-24 16:14:04 +01:00
|
|
|
/**
|
|
|
|
* My Function in a Bar
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2021-02-12 22:59:47 +01:00
|
|
|
function my_function_in_bar() : void {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
my_function_in'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
2021-02-24 16:14:04 +01:00
|
|
|
$completion_data = $codebase->getCompletionDataAtPosition('somefile.php', new Position(12, 30));
|
2021-02-12 22:59:47 +01:00
|
|
|
$this->assertNotNull($completion_data);
|
2021-02-15 05:25:13 +01:00
|
|
|
$this->assertSame('*Bar-my_function_in', $completion_data[0]);
|
2021-02-12 22:59:47 +01:00
|
|
|
|
|
|
|
$completion_items = $codebase->getCompletionItemsForPartialSymbol($completion_data[0], $completion_data[2], 'somefile.php');
|
|
|
|
$this->assertSame(1, count($completion_items));
|
2021-02-24 16:14:04 +01:00
|
|
|
$this->assertEquals('My Function in a Bar', $completion_items[0]->documentation);
|
2021-02-12 22:59:47 +01:00
|
|
|
}
|
|
|
|
|
2021-02-15 05:25:13 +01:00
|
|
|
public function testCompletionForNamespacedOverriddenFunctionNames(): void
|
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace Bar;
|
|
|
|
|
|
|
|
function strlen() : void {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
strlen'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
|
|
|
$completion_data = $codebase->getCompletionDataAtPosition('somefile.php', new Position(7, 22));
|
|
|
|
$this->assertNotNull($completion_data);
|
|
|
|
$this->assertSame('*Bar-strlen', $completion_data[0]);
|
|
|
|
|
|
|
|
$completion_items = $codebase->getCompletionItemsForPartialSymbol($completion_data[0], $completion_data[2], 'somefile.php');
|
|
|
|
$this->assertSame(2, count($completion_items));
|
|
|
|
}
|
|
|
|
|
2021-02-12 22:59:47 +01:00
|
|
|
public function testCompletionForFunctionNamesRespectUsedNamespaces(): void
|
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace Bar;
|
|
|
|
use phpunit\framework as phpf;
|
|
|
|
atleaston'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
|
|
|
$completion_data = $codebase->getCompletionDataAtPosition('somefile.php', new Position(3, 25));
|
|
|
|
$this->assertNotNull($completion_data);
|
2021-02-15 05:25:13 +01:00
|
|
|
$this->assertSame('*Bar-atleaston', $completion_data[0]);
|
2021-02-12 22:59:47 +01:00
|
|
|
|
|
|
|
$completion_items = $codebase->getCompletionItemsForPartialSymbol($completion_data[0], $completion_data[2], 'somefile.php');
|
|
|
|
$this->assertSame(1, count($completion_items));
|
|
|
|
$this->assertSame('phpf\\atLeastOnce', $completion_items[0]->label);
|
|
|
|
}
|
|
|
|
|
2021-02-15 02:08:31 +01:00
|
|
|
public function testCompletionForFunctionNamesRespectCase(): void
|
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace Bar;
|
|
|
|
use phpunit\framework as phpf;
|
|
|
|
Atleaston'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
|
|
|
$completion_data = $codebase->getCompletionDataAtPosition('somefile.php', new Position(3, 25));
|
|
|
|
$this->assertNotNull($completion_data);
|
2021-02-15 05:25:13 +01:00
|
|
|
$this->assertSame('*Bar-Atleaston', $completion_data[0]);
|
2021-02-15 02:08:31 +01:00
|
|
|
|
|
|
|
$completion_items = $codebase->getCompletionItemsForPartialSymbol($completion_data[0], $completion_data[2], 'somefile.php');
|
|
|
|
$this->assertSame(0, count($completion_items));
|
|
|
|
}
|
|
|
|
|
2021-02-12 22:59:47 +01:00
|
|
|
public function testGetMatchingFunctionNames(): void
|
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
|
|
|
|
function my_function() {
|
|
|
|
}'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
2021-02-15 05:25:13 +01:00
|
|
|
$functions = $codebase->functions->getMatchingFunctionNames('*-array_su', 0, 'somefile.php', $codebase);
|
2021-02-12 22:59:47 +01:00
|
|
|
$this->assertSame(1, count($functions));
|
|
|
|
|
2021-02-15 05:25:13 +01:00
|
|
|
$functions = $codebase->functions->getMatchingFunctionNames('*-my_funct', 0, 'somefile.php', $codebase);
|
2021-02-12 22:59:47 +01:00
|
|
|
$this->assertSame(1, count($functions));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetMatchingFunctionNamesFromPredefinedFunctions(): void
|
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
2021-02-15 05:25:13 +01:00
|
|
|
$functions = $codebase->functions->getMatchingFunctionNames('*-urlencod', 0, 'somefile.php', $codebase);
|
2021-02-12 22:59:47 +01:00
|
|
|
$this->assertSame(1, count($functions));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetMatchingFunctionNamesFromUsedFunction(): void
|
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
|
|
|
|
namespace Foo;
|
|
|
|
use function phpunit\framework\atleastonce;
|
|
|
|
'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
2021-02-15 05:25:13 +01:00
|
|
|
$functions = $codebase->functions->getMatchingFunctionNames('*Foo-atleaston', 81, 'somefile.php', $codebase);
|
2021-02-12 22:59:47 +01:00
|
|
|
$this->assertSame(1, count($functions));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetMatchingFunctionNamesFromUsedNamespace(): void
|
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
|
|
|
|
namespace Foo;
|
|
|
|
use phpunit\framework;
|
|
|
|
'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
2021-02-15 05:25:13 +01:00
|
|
|
$functions = $codebase->functions->getMatchingFunctionNames('*Foo-atleaston', 81, 'somefile.php', $codebase);
|
2021-02-12 22:59:47 +01:00
|
|
|
$this->assertSame(1, count($functions));
|
|
|
|
}
|
2021-02-15 02:08:31 +01:00
|
|
|
|
|
|
|
public function testGetMatchingFunctionNamesFromUsedNamespaceRespectFirstCharCase(): void
|
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
|
|
|
|
namespace Foo;
|
|
|
|
use phpunit\framework;
|
|
|
|
'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
2021-02-15 05:25:13 +01:00
|
|
|
$functions = $codebase->functions->getMatchingFunctionNames('*Foo-Atleaston', 81, 'somefile.php', $codebase);
|
2021-02-15 02:08:31 +01:00
|
|
|
$this->assertSame(0, count($functions));
|
|
|
|
}
|
2021-02-12 22:59:47 +01:00
|
|
|
|
|
|
|
public function testGetMatchingFunctionNamesWithNamespace(): void
|
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
function my_function() {
|
|
|
|
}'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
2021-02-15 05:25:13 +01:00
|
|
|
$functions = $codebase->functions->getMatchingFunctionNames('*Foo-array_su', 45, 'somefile.php', $codebase);
|
2021-02-12 22:59:47 +01:00
|
|
|
$this->assertSame(1, count($functions));
|
|
|
|
|
2021-02-15 05:25:13 +01:00
|
|
|
$functions = $codebase->functions->getMatchingFunctionNames('Foo-my_funct', 45, 'somefile.php', $codebase);
|
2021-02-12 22:59:47 +01:00
|
|
|
$this->assertSame(1, count($functions));
|
|
|
|
}
|
|
|
|
|
2020-09-12 17:24:05 +02:00
|
|
|
public function testCompletionOnInstanceofWithNamespaceAndUse(): void
|
2019-06-30 03:32:26 +02:00
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace Bar;
|
|
|
|
|
|
|
|
use LogicException as LogEx;
|
|
|
|
|
|
|
|
class Alpha {}
|
|
|
|
class Antelope {}
|
2019-07-18 04:50:57 +02:00
|
|
|
class Anteater {}
|
2019-06-30 03:32:26 +02:00
|
|
|
|
|
|
|
function foo($a) : void {
|
2019-07-18 04:50:57 +02:00
|
|
|
if ($a instanceof Ant) {}
|
2019-06-30 03:32:26 +02:00
|
|
|
}'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
2019-07-18 04:50:57 +02:00
|
|
|
$completion_data = $codebase->getCompletionDataAtPosition('somefile.php', new Position(10, 41));
|
2019-06-30 03:32:26 +02:00
|
|
|
|
|
|
|
$this->assertSame(
|
|
|
|
[
|
2021-02-15 05:25:13 +01:00
|
|
|
'*Bar-Ant',
|
2019-06-30 03:32:26 +02:00
|
|
|
'symbol',
|
2019-07-18 04:50:57 +02:00
|
|
|
267,
|
2019-06-21 23:10:35 +02:00
|
|
|
],
|
|
|
|
$completion_data
|
|
|
|
);
|
|
|
|
|
2019-06-30 03:32:26 +02:00
|
|
|
$completion_items = $codebase->getCompletionItemsForPartialSymbol($completion_data[0], $completion_data[2], 'somefile.php');
|
2019-06-21 23:10:35 +02:00
|
|
|
|
2019-07-18 04:50:57 +02:00
|
|
|
$this->assertCount(2, $completion_items);
|
2019-06-12 12:30:48 +02:00
|
|
|
}
|
2021-01-24 19:29:21 +01:00
|
|
|
|
|
|
|
public function testCompletionOnClassReference(): void
|
|
|
|
{
|
|
|
|
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace Bar;
|
|
|
|
|
|
|
|
class Alpha {
|
|
|
|
const FOO = "123";
|
|
|
|
static function add() : void {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Alpha::'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
|
|
|
$completion_data = $codebase->getCompletionDataAtPosition('somefile.php', new Position(8, 23));
|
|
|
|
|
|
|
|
$this->assertSame(['Bar\Alpha', '::', 221], $completion_data);
|
|
|
|
|
2021-02-15 06:45:39 +01:00
|
|
|
$completion_items = $codebase->getCompletionItemsForClassishThing($completion_data[0], $completion_data[1]);
|
|
|
|
$this->assertCount(2, $completion_items);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testCompletionOnClassInstanceReferenceWithAssignmentAfter(): void
|
|
|
|
{
|
|
|
|
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace Bar;
|
|
|
|
|
|
|
|
class Alpha {
|
|
|
|
public function add() : void {}
|
|
|
|
}
|
|
|
|
|
|
|
|
$alpha = new Alpha;
|
|
|
|
|
|
|
|
$alpha->
|
|
|
|
|
|
|
|
$a = 5;'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
|
|
|
$completion_data = $codebase->getCompletionDataAtPosition('somefile.php', new Position(9, 24));
|
|
|
|
|
|
|
|
$this->assertSame(['Bar\Alpha', '->', 200], $completion_data);
|
|
|
|
|
|
|
|
$completion_items = $codebase->getCompletionItemsForClassishThing($completion_data[0], $completion_data[1]);
|
|
|
|
$this->assertCount(1, $completion_items);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testCompletionOnClassStaticReferenceWithAssignmentAfter(): void
|
|
|
|
{
|
|
|
|
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace Bar;
|
|
|
|
|
|
|
|
class Alpha {
|
|
|
|
const FOO = "123";
|
|
|
|
static function add() : void {}
|
|
|
|
}
|
|
|
|
|
|
|
|
Alpha::
|
|
|
|
|
|
|
|
$a = 5;'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
|
|
|
$completion_data = $codebase->getCompletionDataAtPosition('somefile.php', new Position(8, 23));
|
|
|
|
|
|
|
|
$this->assertSame(['Bar\Alpha', '::', 201], $completion_data);
|
|
|
|
|
2021-01-24 19:29:21 +01:00
|
|
|
$completion_items = $codebase->getCompletionItemsForClassishThing($completion_data[0], $completion_data[1]);
|
|
|
|
$this->assertCount(2, $completion_items);
|
|
|
|
}
|
2021-01-26 20:06:43 +01:00
|
|
|
|
|
|
|
public function testNoCrashOnLoopId(): void
|
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
for ($x = 0; $x <= 10; $x++) {}'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
}
|
2021-01-27 03:34:46 +01:00
|
|
|
|
|
|
|
public function testCompletionOnArrayKey(): void
|
|
|
|
{
|
|
|
|
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
$my_array = ["foo" => 1, "bar" => 2];
|
|
|
|
$my_array[]
|
|
|
|
'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
|
|
|
$completion_data = $codebase->getCompletionDataAtPosition('somefile.php', new Position(2, 26));
|
|
|
|
$this->assertSame(
|
|
|
|
[
|
|
|
|
'array{bar: 2, foo: 1}',
|
|
|
|
'[',
|
|
|
|
86,
|
|
|
|
],
|
|
|
|
$completion_data
|
|
|
|
);
|
|
|
|
|
|
|
|
$completion_items = $codebase->getCompletionItemsForArrayKeys($completion_data[0]);
|
|
|
|
|
|
|
|
$this->assertCount(2, $completion_items);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testTypeContextForFunctionArgument(): void
|
|
|
|
{
|
|
|
|
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace Bar;
|
|
|
|
function my_func(string $arg_a, bool $arg_b) : string {
|
|
|
|
}
|
|
|
|
|
|
|
|
my_func()'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
|
|
|
$type = $codebase->getTypeContextAtPosition('somefile.php', new Position(5, 24));
|
|
|
|
$this->assertSame('string', (string) $type);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testTypeContextForFunctionArgumentWithWhiteSpace(): void
|
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace Bar;
|
|
|
|
function my_func(string $arg_a, bool $arg_b) : string {
|
|
|
|
}
|
|
|
|
|
|
|
|
my_func( "yes", )'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
|
|
|
$type = $codebase->getTypeContextAtPosition('somefile.php', new Position(5, 32));
|
|
|
|
$this->assertSame('bool', (string) $type);
|
|
|
|
}
|
|
|
|
|
2021-02-27 17:36:19 +01:00
|
|
|
public function testCallStaticInInstance(): void
|
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
class Foo
|
|
|
|
{
|
|
|
|
public function testFoo() {
|
|
|
|
$this->
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function bar() : void {}
|
|
|
|
|
|
|
|
public function baz() : void {}
|
|
|
|
}'
|
|
|
|
);
|
|
|
|
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
|
|
|
|
$codebase->file_provider->openFile('somefile.php');
|
|
|
|
$codebase->scanFiles();
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
|
|
|
|
$completion_data = $codebase->getCompletionDataAtPosition('somefile.php', new Position(4, 31));
|
|
|
|
|
|
|
|
$this->assertSame(['Foo&static', '->', 129], $completion_data);
|
|
|
|
|
|
|
|
$completion_items = $codebase->getCompletionItemsForClassishThing($completion_data[0], $completion_data[1]);
|
|
|
|
|
|
|
|
$this->assertCount(3, $completion_items);
|
|
|
|
}
|
|
|
|
|
2021-01-27 03:34:46 +01:00
|
|
|
public function testCompletionsForType(): void
|
|
|
|
{
|
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
|
|
|
$config = $codebase->config;
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$completion_items = $codebase->getCompletionItemsForType(Type::parseString('bool'));
|
|
|
|
$this->assertCount(2, $completion_items);
|
|
|
|
|
|
|
|
$completion_items = $codebase->getCompletionItemsForType(Type::parseString('true'));
|
|
|
|
$this->assertCount(1, $completion_items);
|
|
|
|
|
|
|
|
$completion_items = $codebase->getCompletionItemsForType(Type::parseString("'yes'|'no'"));
|
|
|
|
$this->assertCount(2, $completion_items);
|
|
|
|
|
|
|
|
$completion_items = $codebase->getCompletionItemsForType(Type::parseString("1|2|3"));
|
|
|
|
$this->assertCount(3, $completion_items);
|
|
|
|
|
|
|
|
// Floats not supported.
|
|
|
|
$completion_items = $codebase->getCompletionItemsForType(Type::parseString("1.0"));
|
|
|
|
$this->assertCount(0, $completion_items);
|
|
|
|
|
|
|
|
$completion_items = $codebase->getCompletionItemsForType(Type::parseString("DateTime::RFC3339"));
|
|
|
|
$this->assertCount(1, $completion_items);
|
|
|
|
}
|
2018-10-26 22:17:15 +02:00
|
|
|
}
|