From fe4af85871f6b5a9e42cda0690af524ae2a06d58 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sat, 22 Aug 2026 05:05:26 +0900 Subject: [PATCH] Add phpantom and php-lsp to php-ide preset Language servers --- CHANGELOG.md | 4 ++++ README.ja.md | 4 ++-- README.md | 4 ++-- lisp/php-ide.el | 6 +++++- tests/php-mode-test.el | 8 ++++++++ 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e9a41d4..b3a848d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this * Shows whether it is on, what is configured, and what is available * Add `php-ide-eglot-activate`, which registers `php-ide-eglot-executable` into `eglot-server-programs` * Buffer-local, so only buffers that set the variable are affected; previously the variable had no effect on Eglot at all + * Add a `phpantom` preset to `php-ide-lsp-command-alist` for the [PHPantom](https://github.com/PHPantom-dev/phpantom_lsp) PHP language server + * Set `php-ide-eglot-executable` to `'phpantom` (safe for `.dir-locals.el`) to run `phpantom_lsp` under Eglot + * Add a `php-lsp` preset to `php-ide-lsp-command-alist` for the [php-lsp](https://github.com/jorgsowa/php-lsp) PHP language server + * Set `php-ide-eglot-executable` to `'php-lsp` (safe for `.dir-locals.el`) to run `php-lsp` under Eglot * Add `php-cc-mode` as a forward-compatible alias for the CC Mode based `php-mode` * Lets configuration and third-party code refer to the CC Mode implementation by the name it will keep once `php-mode` becomes cc-mode independent; loading it has no effect on `php-mode` itself * `php-cc-mode-hook`, `php-cc-mode-lineup-cascaded-calls` and `php-cc-mode-enable-backup-style-variables` are provided as aliases of their current `php-mode-*` counterparts diff --git a/README.ja.md b/README.ja.md index 83b9ebdf..d09a65e8 100644 --- a/README.ja.md +++ b/README.ja.md @@ -86,7 +86,7 @@ M-x package-install php-mode (with-eval-after-load 'php-ide (custom-set-variables '(php-ide-features '(eglot)) ;; '(phpactor)、'(lsp-mode)、'(lsp-bridge)も可 - '(php-ide-eglot-executable 'intelephense) ;; 'phpactor、パス文字列、文字列のリストも可 + '(php-ide-eglot-executable 'intelephense) ;; 'phpantom、'php-lsp、'phpactor、パス文字列、文字列のリストも可 '(php-ide-mode-lighter ""))) ;; モードラインからPHP-IDEを隠す ``` @@ -106,7 +106,7 @@ M-x package-install php-mode (php-ide-features . (eglot)))) ``` -`php-ide-features`と`php-ide-eglot-executable`は、PHP-IDE組み込みの機能名やバンドル済み実行ファイルのプリセット(`intelephense`、`phpactor`など)を指す場合に限り、`.dir-locals.el`での設定が安全とみなされます。それ以外の値——生の実行ファイルパス、明示的なコマンド引数、カスタムの`php-ide-mode-functions`フックなど——は、これまで通りEmacsの「危険な変数」に対する通常の確認を経ます。そうしないと、ファイルを開くだけで任意のリポジトリが任意のコマンド(またはLisp関数)をあなたのEmacs上で実行できてしまうためです。 +`php-ide-features`と`php-ide-eglot-executable`は、PHP-IDE組み込みの機能名やバンドル済み実行ファイルのプリセット(`intelephense`、`phpantom`、`php-lsp`、`phpactor`など)を指す場合に限り、`.dir-locals.el`での設定が安全とみなされます。それ以外の値——生の実行ファイルパス、明示的なコマンド引数、カスタムの`php-ide-mode-functions`フックなど——は、これまで通りEmacsの「危険な変数」に対する通常の確認を経ます。そうしないと、ファイルを開くだけで任意のリポジトリが任意のコマンド(またはLisp関数)をあなたのEmacs上で実行できてしまうためです。 ### `project.el`・Projectileとの連携 diff --git a/README.md b/README.md index b67db77f..9ed9ad8e 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ You can add project-specific settings by creating a `.dir-locals.el` or `.dir-lo (with-eval-after-load 'php-ide (custom-set-variables '(php-ide-features '(eglot)) ;; and/or '(phpactor), '(lsp-mode), '(lsp-bridge) - '(php-ide-eglot-executable 'intelephense) ;; or 'phpactor, a path string, or a list of strings + '(php-ide-eglot-executable 'intelephense) ;; or 'phpantom, 'php-lsp, 'phpactor, a path string, or a list of strings '(php-ide-mode-lighter ""))) ;; hide PHP-IDE from the mode line ``` @@ -108,7 +108,7 @@ Useful commands once `php-ide` is loaded: (php-ide-features . (eglot)))) ``` -`php-ide-features` and `php-ide-eglot-executable` are only treated as safe for `.dir-locals.el` when they name one of PHP-IDE's own built-in features or bundled executable presets (e.g. `intelephense`, `phpactor`). Anything else — a raw executable path, explicit command arguments, or a custom `php-ide-mode-functions` hook — still goes through Emacs's normal confirmation for risky directory-local variables, since applying those silently would let any repository run an arbitrary command (or Lisp function) in your Emacs just by having you open a file in it. +`php-ide-features` and `php-ide-eglot-executable` are only treated as safe for `.dir-locals.el` when they name one of PHP-IDE's own built-in features or bundled executable presets (e.g. `intelephense`, `phpantom`, `php-lsp`, `phpactor`). Anything else — a raw executable path, explicit command arguments, or a custom `php-ide-mode-functions` hook — still goes through Emacs's normal confirmation for risky directory-local variables, since applying those silently would let any repository run an arbitrary command (or Lisp function) in your Emacs just by having you open a file in it. ### Integration with `project.el` and Projectile diff --git a/lisp/php-ide.el b/lisp/php-ide.el index 1c185cb2..78fed583 100644 --- a/lisp/php-ide.el +++ b/lisp/php-ide.el @@ -82,7 +82,7 @@ ;; (with-eval-after-load 'php-ide ;; (custom-set-variables ;; '(php-ide-features '(eglot)) ;; and/or '(none), '(phpactor), '(lsp-mode) -;; '(php-ide-eglot-executable "psalm-language-server") ;; or "intelephense", '("php" "vendor/bin/path/to/server") +;; '(php-ide-eglot-executable 'phpantom) ;; or 'intelephense, 'php-lsp, 'phpactor, "psalm-language-server", '("php" "vendor/bin/path/to/server") ;; ;; If you want to hide php-ide-mode from the mode line, set an empty string ;; '(php-ide-mode-lighter "")) ;; @@ -180,6 +180,8 @@ each bound to a function called with no arguments: ;;;###autoload (defcustom php-ide-lsp-command-alist '((intelephense "intelephense" "--stdio") + (phpantom "phpantom_lsp") + (php-lsp "php-lsp") (phpactor . (lambda () (list (if (fboundp 'phpactor--find-executable) (phpactor--find-executable) "phpactor") @@ -229,6 +231,8 @@ without being asked to confirm an executable path." :tag "PHP-IDE Eglot Executable" :type '(choice (const intelephense) + (const phpantom) + (const php-lsp) (const phpactor) string (repeat string)) ;; Only a symbol naming one of the bundled presets in `php-ide-lsp-command-alist' diff --git a/tests/php-mode-test.el b/tests/php-mode-test.el index f86214ca..41c00be9 100644 --- a/tests/php-mode-test.el +++ b/tests/php-mode-test.el @@ -987,6 +987,10 @@ project setting this variable gets a confirmation prompt anyway." (should (equal '("php" "vendor/bin/path/to/server") (php-ide-eglot-server-program)))) (let ((php-ide-eglot-executable 'intelephense)) (should (equal '("intelephense" "--stdio") (php-ide-eglot-server-program)))) + (let ((php-ide-eglot-executable 'phpantom)) + (should (equal '("phpantom_lsp") (php-ide-eglot-server-program)))) + (let ((php-ide-eglot-executable 'php-lsp)) + (should (equal '("php-lsp") (php-ide-eglot-server-program)))) (let ((php-ide-eglot-executable 'phpactor)) (should (equal (list (if (fboundp 'phpactor--find-executable) (phpactor--find-executable) @@ -1178,6 +1182,8 @@ arbitrary function, path, or command list." (should (funcall features-safe '(none))) (should-not (funcall features-safe '(totally-bogus-feature))) (should (funcall eglot-exe-safe 'intelephense)) + (should (funcall eglot-exe-safe 'phpantom)) + (should (funcall eglot-exe-safe 'php-lsp)) (should (funcall eglot-exe-safe 'phpactor)) (should-not (funcall eglot-exe-safe "/bin/ls")) (should-not (funcall eglot-exe-safe '("curl" "https://example.com/x"))) @@ -1312,6 +1318,8 @@ project setting these variables gets a confirmation prompt anyway." (php-ide-features nil t) (php-ide-features (bogus-feature) nil) (php-ide-eglot-executable intelephense t) + (php-ide-eglot-executable phpantom t) + (php-ide-eglot-executable php-lsp t) (php-ide-eglot-executable phpactor t) (php-ide-eglot-executable "/bin/ls" nil))) (let* ((pred (get (nth 0 c) 'safe-local-variable))