Skip to content

Commit 72437b1

Browse files
przepompowniadantleech
authored andcommitted
Refactor: use ::class or get_debug_type
by Rector rules: Rector\Php80\Rector\FuncCall\ClassOnObjectRector; Rector\Php80\Rector\Ternary\GetDebugTypeRector;
1 parent 3f3d9ab commit 72437b1

File tree

14 files changed

+26
-26
lines changed

14 files changed

+26
-26
lines changed

lib/Adapter/DTL/DTLArgumentResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ public function resolveArguments(object $object, string $method, Message $messag
2424
return [];
2525
}
2626

27-
return $this->dtlArgumnetResolver->resolveArguments(get_class($object), $method, $message->params ?? []);
27+
return $this->dtlArgumnetResolver->resolveArguments($object::class, $method, $message->params ?? []);
2828
}
2929
}

lib/Core/Command/CommandDispatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private function addCommand(string $id, Command $invokable): void
5656
if (!is_callable($invokable)) {
5757
throw new RuntimeException(sprintf(
5858
'Object "%s" is not invokable',
59-
get_class($invokable)
59+
$invokable::class
6060
));
6161
}
6262

lib/Core/Diagnostics/AggregateDiagnosticsProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ public function provideDiagnostics(TextDocumentItem $textDocument, CancellationT
4242
$this->logger->debug(sprintf(
4343
'Diagnostic finsihed in "%s" (%s)',
4444
number_format(microtime(true) - $start, 2),
45-
get_class($provider)
45+
$provider::class
4646
));
4747
} catch (Throwable $throwable) {
4848
$this->logger->error(sprintf(
4949
'Diagnostic error from provider "%s": %s',
50-
get_class($provider),
50+
$provider::class,
5151
$throwable->getMessage()
5252
), [
5353
'trace' => $throwable->getTraceAsString()

lib/Core/Dispatcher/ArgumentResolver/LanguageSeverProtocolParamsResolver.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function resolveArguments(object $object, string $method, Message $messag
2727
if (!$reflection->hasMethod($method)) {
2828
throw new CouldNotResolveArguments(sprintf(
2929
'Class "%s" has no method "%s"',
30-
get_class($object),
30+
$object::class,
3131
$method
3232
));
3333
}
@@ -60,15 +60,15 @@ public function resolveArguments(object $object, string $method, Message $messag
6060

6161
throw new CouldNotResolveArguments(sprintf(
6262
'First argument of LSP class "%s" method "%s" must be the LSP param object, it is "%s"',
63-
get_class($object),
63+
$object::class,
6464
$method,
6565
$classFqn
6666
));
6767
}
6868

6969
throw new CouldNotResolveArguments(sprintf(
7070
'Class "%s" method "%s" is not a language server protocol-accepting method',
71-
get_class($object),
71+
$object::class,
7272
$method
7373
));
7474
}

lib/Core/Dispatcher/Factory/ClosureDispatcherFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function create(MessageTransmitter $transmitter, InitializeParams $initia
2222
if (!$dispatcher instanceof Dispatcher) {
2323
throw new RuntimeException(sprintf(
2424
'Closure must return a "Dispatcher" instance got "%s"',
25-
is_object($dispatcher) ? get_class($dispatcher) : gettype($dispatcher)
25+
get_debug_type($dispatcher)
2626
));
2727
}
2828

lib/Core/Handler/HandlerMethodResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function resolveHandlerMethod(Handler $handler, string $languageServerMet
1313
if (!array_key_exists($languageServerMethod, $handlerMap)) {
1414
throw new RuntimeException(sprintf(
1515
'Resolved handler "%s" has not declared support for LSP method "%s", it declared support for "%s"',
16-
get_class($handler),
16+
$handler::class,
1717
$languageServerMethod,
1818
implode('", "', $handlerMap)
1919
));
@@ -24,7 +24,7 @@ public function resolveHandlerMethod(Handler $handler, string $languageServerMet
2424
if (!method_exists($handler, $method)) {
2525
throw new RuntimeException(sprintf(
2626
'Handler "%s" for method "%s" does not have the "%s" method defined, it has "%s"',
27-
get_class($handler),
27+
$handler::class,
2828
$languageServerMethod,
2929
$method,
3030
implode('", "', get_class_methods($handler))

lib/Core/Handler/HandlerMethodRunner.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function dispatch(Message $request): Promise
4141
) {
4242
throw new RuntimeException(sprintf(
4343
'Message must either be a Notification or a Request, got "%s"',
44-
get_class($request)
44+
$request::class
4545
));
4646
}
4747

@@ -64,9 +64,9 @@ public function dispatch(Message $request): Promise
6464
if (!$promise instanceof Promise) {
6565
throw new RuntimeException(sprintf(
6666
'Handler "%s:%s" must return instance of Amp\\Promise, got "%s"',
67-
get_class($handler),
67+
$handler::class,
6868
$method,
69-
is_object($promise) ? get_class($promise) : gettype($promise)
69+
get_debug_type($promise)
7070
));
7171
}
7272

lib/Core/Server/Initializer/RequestInitializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function provideInitializeParams(Message $request): InitializeParams
1515
if (!$request instanceof RequestMessage) {
1616
throw new RuntimeException(sprintf(
1717
'First request must be a RequestMessage (to initialize), got "%s"',
18-
get_class($request)
18+
$request::class
1919
));
2020
}
2121

lib/Core/Server/LanguageServer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function address(): ?string
9797
if (!$this->streamProvider instanceof SocketStreamProvider) {
9898
throw new RuntimeException(sprintf(
9999
'Cannot get address on non-socket stream provider, using "%s"',
100-
get_class($this->streamProvider)
100+
$this->streamProvider::class
101101
));
102102
}
103103

lib/Core/Server/Transmitter/TestMessageTransmitter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function shiftNotification(): ?NotificationMessage
5555
if (!$message instanceof NotificationMessage) {
5656
throw new RuntimeException(sprintf(
5757
'Expected NotificationMessage, got "%s"',
58-
get_class($message)
58+
$message::class
5959
));
6060
}
6161

@@ -73,7 +73,7 @@ public function shiftRequest(): ?RequestMessage
7373
if (!$message instanceof RequestMessage) {
7474
throw new RuntimeException(sprintf(
7575
'Expected RequestMessage, got "%s"',
76-
get_class($message)
76+
$message::class
7777
));
7878
}
7979

0 commit comments

Comments
 (0)