diff --git a/lib/Adapter/DTL/DTLArgumentResolver.php b/lib/Adapter/DTL/DTLArgumentResolver.php index 383d9b1..d80ade4 100644 --- a/lib/Adapter/DTL/DTLArgumentResolver.php +++ b/lib/Adapter/DTL/DTLArgumentResolver.php @@ -24,6 +24,6 @@ public function resolveArguments(object $object, string $method, Message $messag return []; } - return $this->dtlArgumnetResolver->resolveArguments(get_class($object), $method, $message->params ?? []); + return $this->dtlArgumnetResolver->resolveArguments($object::class, $method, $message->params ?? []); } } diff --git a/lib/Core/Command/CommandDispatcher.php b/lib/Core/Command/CommandDispatcher.php index 309bc41..9e56508 100644 --- a/lib/Core/Command/CommandDispatcher.php +++ b/lib/Core/Command/CommandDispatcher.php @@ -56,7 +56,7 @@ private function addCommand(string $id, Command $invokable): void if (!is_callable($invokable)) { throw new RuntimeException(sprintf( 'Object "%s" is not invokable', - get_class($invokable) + $invokable::class )); } diff --git a/lib/Core/Diagnostics/AggregateDiagnosticsProvider.php b/lib/Core/Diagnostics/AggregateDiagnosticsProvider.php index be373d0..e8f8773 100644 --- a/lib/Core/Diagnostics/AggregateDiagnosticsProvider.php +++ b/lib/Core/Diagnostics/AggregateDiagnosticsProvider.php @@ -42,12 +42,12 @@ public function provideDiagnostics(TextDocumentItem $textDocument, CancellationT $this->logger->debug(sprintf( 'Diagnostic finsihed in "%s" (%s)', number_format(microtime(true) - $start, 2), - get_class($provider) + $provider::class )); } catch (Throwable $throwable) { $this->logger->error(sprintf( 'Diagnostic error from provider "%s": %s', - get_class($provider), + $provider::class, $throwable->getMessage() ), [ 'trace' => $throwable->getTraceAsString() diff --git a/lib/Core/Dispatcher/ArgumentResolver/LanguageSeverProtocolParamsResolver.php b/lib/Core/Dispatcher/ArgumentResolver/LanguageSeverProtocolParamsResolver.php index 658ad6d..5bdce38 100644 --- a/lib/Core/Dispatcher/ArgumentResolver/LanguageSeverProtocolParamsResolver.php +++ b/lib/Core/Dispatcher/ArgumentResolver/LanguageSeverProtocolParamsResolver.php @@ -27,7 +27,7 @@ public function resolveArguments(object $object, string $method, Message $messag if (!$reflection->hasMethod($method)) { throw new CouldNotResolveArguments(sprintf( 'Class "%s" has no method "%s"', - get_class($object), + $object::class, $method )); } @@ -60,7 +60,7 @@ public function resolveArguments(object $object, string $method, Message $messag throw new CouldNotResolveArguments(sprintf( 'First argument of LSP class "%s" method "%s" must be the LSP param object, it is "%s"', - get_class($object), + $object::class, $method, $classFqn )); @@ -68,7 +68,7 @@ public function resolveArguments(object $object, string $method, Message $messag throw new CouldNotResolveArguments(sprintf( 'Class "%s" method "%s" is not a language server protocol-accepting method', - get_class($object), + $object::class, $method )); } diff --git a/lib/Core/Dispatcher/Factory/ClosureDispatcherFactory.php b/lib/Core/Dispatcher/Factory/ClosureDispatcherFactory.php index e561483..9d33f57 100644 --- a/lib/Core/Dispatcher/Factory/ClosureDispatcherFactory.php +++ b/lib/Core/Dispatcher/Factory/ClosureDispatcherFactory.php @@ -22,7 +22,7 @@ public function create(MessageTransmitter $transmitter, InitializeParams $initia if (!$dispatcher instanceof Dispatcher) { throw new RuntimeException(sprintf( 'Closure must return a "Dispatcher" instance got "%s"', - is_object($dispatcher) ? get_class($dispatcher) : gettype($dispatcher) + get_debug_type($dispatcher) )); } diff --git a/lib/Core/Handler/HandlerMethodResolver.php b/lib/Core/Handler/HandlerMethodResolver.php index 11f595d..c040c56 100644 --- a/lib/Core/Handler/HandlerMethodResolver.php +++ b/lib/Core/Handler/HandlerMethodResolver.php @@ -13,7 +13,7 @@ public function resolveHandlerMethod(Handler $handler, string $languageServerMet if (!array_key_exists($languageServerMethod, $handlerMap)) { throw new RuntimeException(sprintf( 'Resolved handler "%s" has not declared support for LSP method "%s", it declared support for "%s"', - get_class($handler), + $handler::class, $languageServerMethod, implode('", "', $handlerMap) )); @@ -24,7 +24,7 @@ public function resolveHandlerMethod(Handler $handler, string $languageServerMet if (!method_exists($handler, $method)) { throw new RuntimeException(sprintf( 'Handler "%s" for method "%s" does not have the "%s" method defined, it has "%s"', - get_class($handler), + $handler::class, $languageServerMethod, $method, implode('", "', get_class_methods($handler)) diff --git a/lib/Core/Handler/HandlerMethodRunner.php b/lib/Core/Handler/HandlerMethodRunner.php index ccbd975..5d54894 100644 --- a/lib/Core/Handler/HandlerMethodRunner.php +++ b/lib/Core/Handler/HandlerMethodRunner.php @@ -41,7 +41,7 @@ public function dispatch(Message $request): Promise ) { throw new RuntimeException(sprintf( 'Message must either be a Notification or a Request, got "%s"', - get_class($request) + $request::class )); } @@ -64,9 +64,9 @@ public function dispatch(Message $request): Promise if (!$promise instanceof Promise) { throw new RuntimeException(sprintf( 'Handler "%s:%s" must return instance of Amp\\Promise, got "%s"', - get_class($handler), + $handler::class, $method, - is_object($promise) ? get_class($promise) : gettype($promise) + get_debug_type($promise) )); } diff --git a/lib/Core/Server/Initializer/RequestInitializer.php b/lib/Core/Server/Initializer/RequestInitializer.php index 0b41529..fe753e7 100644 --- a/lib/Core/Server/Initializer/RequestInitializer.php +++ b/lib/Core/Server/Initializer/RequestInitializer.php @@ -15,7 +15,7 @@ public function provideInitializeParams(Message $request): InitializeParams if (!$request instanceof RequestMessage) { throw new RuntimeException(sprintf( 'First request must be a RequestMessage (to initialize), got "%s"', - get_class($request) + $request::class )); } diff --git a/lib/Core/Server/LanguageServer.php b/lib/Core/Server/LanguageServer.php index 3acc121..c3bfe97 100644 --- a/lib/Core/Server/LanguageServer.php +++ b/lib/Core/Server/LanguageServer.php @@ -97,7 +97,7 @@ public function address(): ?string if (!$this->streamProvider instanceof SocketStreamProvider) { throw new RuntimeException(sprintf( 'Cannot get address on non-socket stream provider, using "%s"', - get_class($this->streamProvider) + $this->streamProvider::class )); } diff --git a/lib/Core/Server/Transmitter/TestMessageTransmitter.php b/lib/Core/Server/Transmitter/TestMessageTransmitter.php index 5379269..b3d1957 100644 --- a/lib/Core/Server/Transmitter/TestMessageTransmitter.php +++ b/lib/Core/Server/Transmitter/TestMessageTransmitter.php @@ -55,7 +55,7 @@ public function shiftNotification(): ?NotificationMessage if (!$message instanceof NotificationMessage) { throw new RuntimeException(sprintf( 'Expected NotificationMessage, got "%s"', - get_class($message) + $message::class )); } @@ -73,7 +73,7 @@ public function shiftRequest(): ?RequestMessage if (!$message instanceof RequestMessage) { throw new RuntimeException(sprintf( 'Expected RequestMessage, got "%s"', - get_class($message) + $message::class )); } diff --git a/lib/Core/Service/ServiceManager.php b/lib/Core/Service/ServiceManager.php index 5c8c6ea..0ba74ec 100644 --- a/lib/Core/Service/ServiceManager.php +++ b/lib/Core/Service/ServiceManager.php @@ -47,12 +47,12 @@ public function start(string $serviceName): void )); } - $this->logger->info(sprintf('Starting service: %s (%s)', $serviceName, get_class($provider))); + $this->logger->info(sprintf('Starting service: %s (%s)', $serviceName, $provider::class)); if (!method_exists($provider, $serviceName)) { throw new RuntimeException(sprintf( 'Service provider "%s" has no service method "%s"', - get_class($provider), + $provider::class, $serviceName )); } @@ -67,8 +67,8 @@ public function start(string $serviceName): void if (!$promise instanceof Promise) { throw new RuntimeException(sprintf( 'Service method "%s" must return a Promise, got "%s"', - get_class($provider) . '::' . $serviceName, - is_object($promise) ? get_class($promise) : gettype($promise) + $provider::class . '::' . $serviceName, + get_debug_type($promise) )); } @@ -78,7 +78,7 @@ public function start(string $serviceName): void $this->logger->error(sprintf( 'Error in service "%s" "%s:%s": %s', $serviceName, - get_class($provider), + $provider::class, __FUNCTION__, $error->getMessage() )); diff --git a/lib/Middleware/ErrorHandlingMiddleware.php b/lib/Middleware/ErrorHandlingMiddleware.php index 5c1c12f..a78b1cf 100644 --- a/lib/Middleware/ErrorHandlingMiddleware.php +++ b/lib/Middleware/ErrorHandlingMiddleware.php @@ -45,10 +45,10 @@ public function process(Message $request, RequestHandler $handler): Promise ) )); } catch (Throwable $error) { - $message = sprintf('Exception [%s] %s', get_class($error), $error->getMessage()); + $message = sprintf('Exception [%s] %s', $error::class, $error->getMessage()); $this->logger->error(sprintf( 'Error when handling "%s" (%s): %s', - get_class($request), + $request::class, json_encode($request), $message )); diff --git a/lib/Test/LanguageServerTester.php b/lib/Test/LanguageServerTester.php index c2bdc85..039fd46 100644 --- a/lib/Test/LanguageServerTester.php +++ b/lib/Test/LanguageServerTester.php @@ -148,7 +148,7 @@ public function initialize(): InitializeResult if (!$result instanceof InitializeResult) { throw new RuntimeException(sprintf( 'Initialize did not return an InitializeResult, got "%s"', - is_object($result) ? get_class($result) : gettype($result) + get_debug_type($result) )); } diff --git a/lib/Test/ListenerProvider/RecordingListenerProvider.php b/lib/Test/ListenerProvider/RecordingListenerProvider.php index b12e656..df89ca1 100644 --- a/lib/Test/ListenerProvider/RecordingListenerProvider.php +++ b/lib/Test/ListenerProvider/RecordingListenerProvider.php @@ -39,7 +39,7 @@ public function shift(string $type): object throw new RuntimeException(sprintf( 'Expected event of type "%s" but got "%s"', $type, - get_class($next) + $next::class )); }