Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -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を隠す
```

Expand All @@ -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との連携

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand All @@ -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

Expand Down
6 changes: 5 additions & 1 deletion lisp/php-ide.el
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""))
;;
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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'
Expand Down
8 changes: 8 additions & 0 deletions tests/php-mode-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")))
Expand Down Expand Up @@ -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))
Expand Down
Loading