From e1a30a20a1e00ee87671d6d3077a12e4c3e66530 Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Tue, 25 Jul 2023 00:11:35 +0200 Subject: [PATCH 1/2] Map special RPC paths Now `$/cancelRequest` will be resolved to `$server->cancelRequest()` and `$/textDocument/whatever` to `$server->textDocument->whatever()` --- .../Internal/LanguageServer/LanguageServer.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Psalm/Internal/LanguageServer/LanguageServer.php b/src/Psalm/Internal/LanguageServer/LanguageServer.php index 54009b9cc..aa7095038 100644 --- a/src/Psalm/Internal/LanguageServer/LanguageServer.php +++ b/src/Psalm/Internal/LanguageServer/LanguageServer.php @@ -997,4 +997,19 @@ class LanguageServer extends Dispatcher return $filepath; } + + // the methods below forward special paths + // like `$/cancelRequest` to `$this->cancelRequest()` + // and `$/a/b/c` to `$this->a->b->c()` + + public function __isset(string $prop_name): bool + { + return $prop_name === '$'; + } + + /** @return static */ + public function __get(string $prop_name): self + { + return $this; + } } From 4a0a12d9e23e28ccda9b05a8461893f82c5ccd04 Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Tue, 25 Jul 2023 00:17:12 +0200 Subject: [PATCH 2/2] Fix unused var --- src/Psalm/Internal/LanguageServer/LanguageServer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Psalm/Internal/LanguageServer/LanguageServer.php b/src/Psalm/Internal/LanguageServer/LanguageServer.php index aa7095038..4edcc7449 100644 --- a/src/Psalm/Internal/LanguageServer/LanguageServer.php +++ b/src/Psalm/Internal/LanguageServer/LanguageServer.php @@ -1008,7 +1008,7 @@ class LanguageServer extends Dispatcher } /** @return static */ - public function __get(string $prop_name): self + public function __get(string $_prop_name): self { return $this; }