Skip to content

Commit 14fa528

Browse files
committed
Refactor: clean types
1 parent 72437b1 commit 14fa528

File tree

55 files changed

+131
-334
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+131
-334
lines changed

bin/serve.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@
4848

4949
if (($argc ?? 0) === 1) {
5050
echo <<<DOC
51-
Usage: serve.php --address=127.0.0.1:9000 --type=tcp
52-
53-
Parameters:
54-
-a --address
55-
Address of the server. (needs to be set for a tcp server)
56-
-t --type
57-
Type of server (optional, default is tcp)
58-
DOC;
51+
Usage: serve.php --address=127.0.0.1:9000 --type=tcp
52+
53+
Parameters:
54+
-a --address
55+
Address of the server. (needs to be set for a tcp server)
56+
-t --type
57+
Type of server (optional, default is tcp)
58+
DOC;
5959
exit(1);
6060
}
6161

@@ -83,7 +83,7 @@ public function __construct()
8383
$this->log = fopen('phpactor-lsp.log', 'w');
8484
}
8585

86-
public function log($level, $message, array $context = [])
86+
public function log($level, $message, array $context = []): void
8787
{
8888
$message = json_encode(
8989
[

example/server/acme-ls/AcmeLsDispatcherFactory.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Phpactor\LanguageServer\Core\Dispatcher\Dispatcher;
1616
use Phpactor\LanguageServer\Core\Handler\HandlerMethodRunner;
1717
use Phpactor\LanguageServer\Core\Dispatcher\DispatcherFactory;
18-
use Phpactor\LanguageServer\Handler\System\ExitHandler;
1918
use Phpactor\LanguageServer\Handler\Workspace\CommandHandler;
2019
use Phpactor\LanguageServer\Middleware\ResponseHandlingMiddleware;
2120
use Phpactor\LanguageServer\Core\Command\CommandDispatcher;
@@ -37,14 +36,8 @@
3736

3837
class AcmeLsDispatcherFactory implements DispatcherFactory
3938
{
40-
/**
41-
* @var LoggerInterface
42-
*/
43-
private $logger;
44-
45-
public function __construct(LoggerInterface $logger)
39+
public function __construct(private LoggerInterface $logger)
4640
{
47-
$this->logger = $logger;
4841
}
4942

5043
public function create(MessageTransmitter $transmitter, InitializeParams $initializeParams): Dispatcher

lib/Adapter/Psr/AggregateEventDispatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class AggregateEventDispatcher implements EventDispatcherInterface
1010
/**
1111
* @var array<ListenerProviderInterface>
1212
*/
13-
private $listnerProviders;
13+
private array $listnerProviders;
1414

1515
public function __construct(ListenerProviderInterface ...$listnerProviders)
1616
{

lib/Core/CodeAction/AggregateCodeActionProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function kinds(): array
4848
return array_values(
4949
array_reduce(
5050
$this->providers,
51-
function (array $kinds, CodeActionProvider $provider) {
51+
function (array $kinds, CodeActionProvider $provider): array {
5252
return array_merge(
5353
$kinds,
5454
(array)array_combine($provider->kinds(), $provider->kinds())

lib/Core/Command/CommandDispatcher.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,10 @@
1010
*/
1111
class CommandDispatcher
1212
{
13-
/**
14-
* @var array
15-
*/
16-
private $commandMap = [];
17-
1813
/**
1914
* @param array<string,Command> $commandMap Map of command names to invokable objects
2015
*/
21-
public function __construct(array $commandMap)
16+
public function __construct(private array $commandMap = [])
2217
{
2318
foreach ($commandMap as $id => $command) {
2419
$this->addCommand($id, $command);

lib/Core/Diagnostics/AggregateDiagnosticsProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class AggregateDiagnosticsProvider implements DiagnosticsProvider
1414
/**
1515
* @var array<DiagnosticsProvider>
1616
*/
17-
private $providers;
17+
private array $providers;
1818

1919
public function __construct(private LoggerInterface $logger, DiagnosticsProvider ...$providers)
2020
{
@@ -65,7 +65,7 @@ public function provideDiagnostics(TextDocumentItem $textDocument, CancellationT
6565
public function names(): array
6666
{
6767
return array_map(
68-
fn (DiagnosticsProvider $provider) => $provider->name(),
68+
fn (DiagnosticsProvider $provider): string => $provider->name(),
6969
$this->providers
7070
);
7171
}

lib/Core/Diagnostics/DiagnosticsEngine.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,9 @@ private function isDocumentCurrent(TextDocumentItem $textDocument): bool
189189
}
190190

191191
/**
192-
* @param string|int $providerId
193192
* @return Promise<bool>
194193
*/
195-
private function awaitProviderLock($providerId): Promise
194+
private function awaitProviderLock(int|string $providerId): Promise
196195
{
197196
if (!array_key_exists($providerId, $this->locks)) {
198197
return new Success(true);

lib/Core/Dispatcher/ArgumentResolver/ChainArgumentResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ final class ChainArgumentResolver implements ArgumentResolver
1111
/**
1212
* @var array<ArgumentResolver>
1313
*/
14-
private $resolvers;
14+
private array $resolvers;
1515

1616
public function __construct(ArgumentResolver ...$resolvers)
1717
{

lib/Core/Dispatcher/Dispatcher/MiddlewareDispatcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
final class MiddlewareDispatcher implements Dispatcher
1212
{
1313
/**
14-
* @var array
14+
* @var Middleware[]
1515
*/
16-
private $middleware;
16+
private array $middleware;
1717

1818
public function __construct(Middleware ...$middleware)
1919
{

lib/Core/Handler/ClosureHandler.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ public function methods(): array
2020
];
2121
}
2222

23-
/**
24-
* @return mixed
25-
*/
26-
public function handle()
23+
public function handle(): mixed
2724
{
2825
$args = func_get_args();
2926
return $this->closure->__invoke(...$args);

0 commit comments

Comments
 (0)