mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
fix some tests
This commit is contained in:
parent
a13ad3cf4a
commit
b9791d24dc
@ -3,9 +3,9 @@
|
||||
namespace Psalm\Tests\LanguageServer;
|
||||
|
||||
use LanguageServerProtocol\Position;
|
||||
use Psalm\Codebase;
|
||||
use Psalm\Context;
|
||||
use Psalm\Internal\Analyzer\ProjectAnalyzer;
|
||||
use Psalm\Internal\LanguageServer\Codebase;
|
||||
use Psalm\Internal\Provider\FakeFileProvider;
|
||||
use Psalm\Internal\Provider\Providers;
|
||||
use Psalm\Tests\Internal\Provider\FakeFileReferenceCacheProvider;
|
||||
@ -19,8 +19,7 @@ use function count;
|
||||
|
||||
class CompletionTest extends TestCase
|
||||
{
|
||||
/** @var Codebase */
|
||||
protected $codebase;
|
||||
protected Codebase $codebase;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
@ -48,7 +47,7 @@ class CompletionTest extends TestCase
|
||||
[],
|
||||
1,
|
||||
null,
|
||||
$this->codebase
|
||||
$this->codebase,
|
||||
);
|
||||
|
||||
$this->project_analyzer->setPhpVersion('7.3', 'tests');
|
||||
|
@ -3,10 +3,10 @@
|
||||
namespace Psalm\Tests\LanguageServer;
|
||||
|
||||
use Amp\Deferred;
|
||||
use Psalm\Codebase;
|
||||
use Psalm\Internal\Analyzer\IssueData;
|
||||
use Psalm\Internal\Analyzer\ProjectAnalyzer;
|
||||
use Psalm\Internal\LanguageServer\ClientConfiguration;
|
||||
use Psalm\Internal\LanguageServer\Codebase;
|
||||
use Psalm\Internal\LanguageServer\LanguageServer;
|
||||
use Psalm\Internal\LanguageServer\Message;
|
||||
use Psalm\Internal\LanguageServer\Progress;
|
||||
@ -26,20 +26,11 @@ use function rand;
|
||||
|
||||
class DiagnosticTest extends AsyncTestCase
|
||||
{
|
||||
/** @var Codebase */
|
||||
protected $codebase;
|
||||
|
||||
/** @var int */
|
||||
private $increment = 0;
|
||||
|
||||
/** @var ProjectAnalyzer */
|
||||
protected $project_analyzer;
|
||||
|
||||
/** @var FakeFileProvider */
|
||||
protected $file_provider;
|
||||
|
||||
/** @var string */
|
||||
protected static $src_dir_path;
|
||||
protected Codebase $codebase;
|
||||
private int $increment = 0;
|
||||
protected ProjectAnalyzer $project_analyzer;
|
||||
protected FakeFileProvider $file_provider;
|
||||
protected static string $src_dir_path;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
@ -67,7 +58,7 @@ class DiagnosticTest extends AsyncTestCase
|
||||
[],
|
||||
1,
|
||||
null,
|
||||
$this->codebase
|
||||
$this->codebase,
|
||||
);
|
||||
|
||||
$this->project_analyzer->setPhpVersion('7.4', 'tests');
|
||||
@ -96,7 +87,7 @@ class DiagnosticTest extends AsyncTestCase
|
||||
$this->project_analyzer,
|
||||
$this->codebase,
|
||||
$clientConfiguration,
|
||||
new Progress
|
||||
new Progress,
|
||||
);
|
||||
|
||||
$write->on('message', function (Message $message) use ($deferred, $server): void {
|
||||
@ -120,7 +111,7 @@ class DiagnosticTest extends AsyncTestCase
|
||||
|
||||
$this->addFile(
|
||||
'somefile.php',
|
||||
''
|
||||
'',
|
||||
);
|
||||
|
||||
$issues = $this->changeFile(
|
||||
@ -131,7 +122,7 @@ class DiagnosticTest extends AsyncTestCase
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
}'
|
||||
}',
|
||||
);
|
||||
|
||||
$this->assertEmpty($issues);
|
||||
@ -145,7 +136,7 @@ class DiagnosticTest extends AsyncTestCase
|
||||
{
|
||||
strpos("", "");
|
||||
}
|
||||
}'
|
||||
}',
|
||||
);
|
||||
|
||||
$this->assertArrayHasKey('somefile.php', $issues);
|
||||
@ -164,7 +155,7 @@ class DiagnosticTest extends AsyncTestCase
|
||||
}
|
||||
|
||||
public function foobar(): void {}
|
||||
}'
|
||||
}',
|
||||
);
|
||||
|
||||
$this->assertArrayHasKey('somefile.php', $issues);
|
||||
@ -187,7 +178,7 @@ class DiagnosticTest extends AsyncTestCase
|
||||
}
|
||||
|
||||
public function foobar(): void {}
|
||||
}'
|
||||
}',
|
||||
);
|
||||
|
||||
$this->assertArrayHasKey('somefile.php', $issues);
|
||||
@ -208,7 +199,7 @@ class DiagnosticTest extends AsyncTestCase
|
||||
}
|
||||
|
||||
public function foobar(): void {}
|
||||
}'
|
||||
}',
|
||||
);
|
||||
|
||||
$this->assertArrayHasKey('somefile.php', $issues);
|
||||
@ -226,7 +217,7 @@ class DiagnosticTest extends AsyncTestCase
|
||||
}
|
||||
|
||||
public function foobar(): void {}
|
||||
}'
|
||||
}',
|
||||
);
|
||||
|
||||
$this->assertArrayHasKey('somefile.php', $issues);
|
||||
@ -247,7 +238,7 @@ class DiagnosticTest extends AsyncTestCase
|
||||
}
|
||||
|
||||
public function foobar(): void {}
|
||||
}'
|
||||
}',
|
||||
);
|
||||
|
||||
$this->assertEmpty($issues);
|
||||
@ -261,15 +252,15 @@ class DiagnosticTest extends AsyncTestCase
|
||||
$this->codebase->addTemporaryFileChanges(
|
||||
$file_path,
|
||||
$contents,
|
||||
$this->increment
|
||||
$this->increment,
|
||||
);
|
||||
|
||||
$this->codebase->reloadFiles(
|
||||
$this->project_analyzer,
|
||||
[$file_path]
|
||||
[$file_path],
|
||||
);
|
||||
$this->codebase->analyzer->addFilesToAnalyze(
|
||||
[$file_path => $file_path]
|
||||
[$file_path => $file_path],
|
||||
);
|
||||
$this->codebase->analyzer->analyzeFiles($this->project_analyzer, 1, false);
|
||||
|
||||
@ -669,7 +660,7 @@ class DiagnosticTest extends AsyncTestCase
|
||||
],
|
||||
],
|
||||
'trace' => 'off',
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace Psalm\Tests\LanguageServer;
|
||||
|
||||
use Psalm\Codebase;
|
||||
use Psalm\Context;
|
||||
use Psalm\Internal\Analyzer\ProjectAnalyzer;
|
||||
use Psalm\Internal\LanguageServer\Codebase;
|
||||
use Psalm\Internal\Provider\FakeFileProvider;
|
||||
use Psalm\Internal\Provider\Providers;
|
||||
use Psalm\Tests\Internal\Provider\FakeFileReferenceCacheProvider;
|
||||
@ -17,8 +17,7 @@ use function count;
|
||||
|
||||
class FileMapTest extends TestCase
|
||||
{
|
||||
/** @var Codebase */
|
||||
protected $codebase;
|
||||
protected Codebase $codebase;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
@ -46,7 +45,7 @@ class FileMapTest extends TestCase
|
||||
[],
|
||||
1,
|
||||
null,
|
||||
$this->codebase
|
||||
$this->codebase,
|
||||
);
|
||||
|
||||
$this->project_analyzer->setPhpVersion('7.3', 'tests');
|
||||
|
@ -22,7 +22,6 @@ class MockProtocolStream implements ProtocolReader, ProtocolWriter, EmitterInter
|
||||
/**
|
||||
* Sends a Message to the client
|
||||
*
|
||||
* @param Message $msg
|
||||
* @psalm-suppress PossiblyUnusedReturnValue
|
||||
*/
|
||||
public function write(Message $msg): Promise
|
||||
|
@ -4,10 +4,10 @@ namespace Psalm\Tests\LanguageServer;
|
||||
|
||||
use LanguageServerProtocol\Position;
|
||||
use LanguageServerProtocol\Range;
|
||||
use Psalm\Codebase;
|
||||
use Psalm\Context;
|
||||
use Psalm\Internal\Analyzer\FileAnalyzer;
|
||||
use Psalm\Internal\Analyzer\ProjectAnalyzer;
|
||||
use Psalm\Internal\LanguageServer\Codebase;
|
||||
use Psalm\Internal\LanguageServer\Reference;
|
||||
use Psalm\Internal\Provider\FakeFileProvider;
|
||||
use Psalm\Internal\Provider\Providers;
|
||||
@ -19,8 +19,7 @@ use Psalm\Tests\TestConfig;
|
||||
|
||||
class SymbolLookupTest extends TestCase
|
||||
{
|
||||
/** @var Codebase */
|
||||
protected $codebase;
|
||||
protected Codebase $codebase;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
@ -48,7 +47,7 @@ class SymbolLookupTest extends TestCase
|
||||
[],
|
||||
1,
|
||||
null,
|
||||
$this->codebase
|
||||
$this->codebase,
|
||||
);
|
||||
|
||||
$this->project_analyzer->setPhpVersion('7.3', 'tests');
|
||||
@ -103,8 +102,8 @@ class SymbolLookupTest extends TestCase
|
||||
new Reference(
|
||||
'somefile.php',
|
||||
'B\A::foo()',
|
||||
$range
|
||||
)
|
||||
$range,
|
||||
),
|
||||
);
|
||||
$this->assertNotNull($information);
|
||||
$this->assertSame("public function foo(): void", $information->code);
|
||||
@ -115,8 +114,8 @@ class SymbolLookupTest extends TestCase
|
||||
new Reference(
|
||||
'somefile.php',
|
||||
'B\A::$a',
|
||||
$range
|
||||
)
|
||||
$range,
|
||||
),
|
||||
);
|
||||
$this->assertNotNull($information);
|
||||
$this->assertSame('protected int|null $a', $information->code);
|
||||
@ -127,8 +126,8 @@ class SymbolLookupTest extends TestCase
|
||||
new Reference(
|
||||
'somefile.php',
|
||||
'B\bar()',
|
||||
$range
|
||||
)
|
||||
$range,
|
||||
),
|
||||
);
|
||||
$this->assertNotNull($information);
|
||||
$this->assertSame('function B\bar(): int', $information->code);
|
||||
@ -139,8 +138,8 @@ class SymbolLookupTest extends TestCase
|
||||
new Reference(
|
||||
'somefile.php',
|
||||
'B\A::BANANA',
|
||||
$range
|
||||
)
|
||||
$range,
|
||||
),
|
||||
);
|
||||
$this->assertNotNull($information);
|
||||
$this->assertSame('public const BANANA = 🍌;', $information->code);
|
||||
@ -151,8 +150,8 @@ class SymbolLookupTest extends TestCase
|
||||
new Reference(
|
||||
'somefile.php',
|
||||
'B\baz()',
|
||||
$range
|
||||
)
|
||||
$range,
|
||||
),
|
||||
);
|
||||
$this->assertNotNull($information);
|
||||
$this->assertSame("function B\baz(\n int \$a\n): int", $information->code);
|
||||
@ -163,8 +162,8 @@ class SymbolLookupTest extends TestCase
|
||||
new Reference(
|
||||
'somefile.php',
|
||||
'B\qux()',
|
||||
$range
|
||||
)
|
||||
$range,
|
||||
),
|
||||
);
|
||||
$this->assertNotNull($information);
|
||||
$this->assertSame("function B\qux(\n int \$a,\n int \$b\n): int", $information->code);
|
||||
@ -175,8 +174,8 @@ class SymbolLookupTest extends TestCase
|
||||
new Reference(
|
||||
'somefile.php',
|
||||
'$_SESSION',
|
||||
$range
|
||||
)
|
||||
$range,
|
||||
),
|
||||
);
|
||||
$this->assertNotNull($information);
|
||||
$this->assertSame("array<string, mixed>", $information->code);
|
||||
@ -187,8 +186,8 @@ class SymbolLookupTest extends TestCase
|
||||
new Reference(
|
||||
'somefile.php',
|
||||
'$my_global',
|
||||
$range
|
||||
)
|
||||
$range,
|
||||
),
|
||||
);
|
||||
$this->assertNotNull($information);
|
||||
$this->assertSame("string", $information->code);
|
||||
@ -215,8 +214,8 @@ class SymbolLookupTest extends TestCase
|
||||
new Reference(
|
||||
'somefile.php',
|
||||
'APPLE',
|
||||
$range
|
||||
)
|
||||
$range,
|
||||
),
|
||||
);
|
||||
$this->assertNotNull($information);
|
||||
$this->assertSame("const APPLE string", $information->code);
|
||||
@ -227,8 +226,8 @@ class SymbolLookupTest extends TestCase
|
||||
new Reference(
|
||||
'somefile.php',
|
||||
'BANANA',
|
||||
$range
|
||||
)
|
||||
$range,
|
||||
),
|
||||
);
|
||||
$this->assertNotNull($information);
|
||||
$this->assertSame("const BANANA string", $information->code);
|
||||
@ -270,7 +269,7 @@ class SymbolLookupTest extends TestCase
|
||||
$method_symbol_location = $this->codebase->getSymbolLocation(new Reference(
|
||||
'somefile.php',
|
||||
'B\A::foo()',
|
||||
$range
|
||||
$range,
|
||||
));
|
||||
|
||||
$this->assertNotNull($method_symbol_location);
|
||||
@ -280,7 +279,7 @@ class SymbolLookupTest extends TestCase
|
||||
$property_symbol_location = $this->codebase->getSymbolLocation(new Reference(
|
||||
'somefile.php',
|
||||
'B\A::$a',
|
||||
$range
|
||||
$range,
|
||||
));
|
||||
|
||||
$this->assertNotNull($property_symbol_location);
|
||||
@ -290,7 +289,7 @@ class SymbolLookupTest extends TestCase
|
||||
$constant_symbol_location = $this->codebase->getSymbolLocation(new Reference(
|
||||
'somefile.php',
|
||||
'B\A::BANANA',
|
||||
$range
|
||||
$range,
|
||||
));
|
||||
|
||||
$this->assertNotNull($constant_symbol_location);
|
||||
@ -300,7 +299,7 @@ class SymbolLookupTest extends TestCase
|
||||
$function_symbol_location = $this->codebase->getSymbolLocation(new Reference(
|
||||
'somefile.php',
|
||||
'B\bar()',
|
||||
$range
|
||||
$range,
|
||||
));
|
||||
|
||||
$this->assertNotNull($function_symbol_location);
|
||||
@ -310,7 +309,7 @@ class SymbolLookupTest extends TestCase
|
||||
$function_symbol_location = $this->codebase->getSymbolLocation(new Reference(
|
||||
'somefile.php',
|
||||
'257-259',
|
||||
$range
|
||||
$range,
|
||||
));
|
||||
|
||||
$this->assertNotNull($function_symbol_location);
|
||||
|
Loading…
Reference in New Issue
Block a user