From e1a30a20a1e00ee87671d6d3077a12e4c3e66530 Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Tue, 25 Jul 2023 00:11:35 +0200 Subject: [PATCH] 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 54009b9cc5a..aa709503831 100644 --- a/src/Psalm/Internal/LanguageServer/LanguageServer.php +++ b/src/Psalm/Internal/LanguageServer/LanguageServer.php @@ -997,4 +997,19 @@ public static function uriToPath(string $uri): string 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; + } }