update of packages
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
;;; php-align.el --- Alignment configuration for PHP -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2011 tetsujin (Yusuke Segawa)
|
||||
;; Copyright (C) 2022 Friends of Emacs-PHP development
|
||||
;; Copyright (C) 2023 Friends of Emacs-PHP development
|
||||
|
||||
;; Author: tetsujin (Yusuke Segawa) <tetsujin85 (at) gmail.com>
|
||||
;; Maintainer: USAMI Kenta <tadsan@zonu.me>
|
||||
;; Keywords: php languages convenience align
|
||||
;; Homepage: https://github.com/emacs-php/php-mode
|
||||
;; Version: 1.24.2
|
||||
;; Version: 1.25.0
|
||||
;; License: GPL-3.0-or-later
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
;;; php-complete.el --- PHP auto-compiletion functions -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2022 Friends of Emacs-PHP development
|
||||
;; Copyright (C) 2023 Friends of Emacs-PHP development
|
||||
;; Copyright (C) 2021, 2022 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: USAMI Kenta <tadsan@zonu.me>
|
||||
|
||||
;; Created: 18 Sep 2022
|
||||
;; Version: 1.24.2
|
||||
;; Version: 1.25.0
|
||||
;; Keywords: languages, php
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
;;; php-defs.el --- Provide PHP keyword definitions -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2022 Friends of Emacs-PHP development
|
||||
;; Copyright (C) 2023 Friends of Emacs-PHP development
|
||||
|
||||
;; Author: USAMI Kenta <tadsan@zonu.me>
|
||||
;; Created: 5 Mar 2022
|
||||
;; Version: 1.24.2
|
||||
;; Version: 1.25.0
|
||||
;; Keywords: languages, php
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
;;; php-face.el --- Face definitions for PHP script -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2022 Friends of Emacs-PHP development
|
||||
;; Copyright (C) 2023 Friends of Emacs-PHP development
|
||||
|
||||
;; Author: USAMI Kenta <tadsan@zonu.me>
|
||||
;; Created: 5 May 2019
|
||||
;; Version: 1.24.2
|
||||
;; Version: 1.25.0
|
||||
;; Keywords: faces, php
|
||||
;; Homepage: https://github.com/emacs-php/php-mode
|
||||
;; License: GPL-3.0-or-later
|
||||
@@ -126,7 +126,8 @@
|
||||
:tag "PHP Object Op")
|
||||
|
||||
(defface php-paamayim-nekudotayim '((t ()))
|
||||
"PHP Mode face used to highlight \"Paamayim Nekudotayim\" scope resolution operators (::)."
|
||||
"PHP Mode face used to highlight scope resolution operators (::).
|
||||
The operator is also knows as \"Paamayim Nekudotayim\"."
|
||||
:group 'php-faces
|
||||
:tag "PHP Paamayim Nekudotayim")
|
||||
|
||||
@@ -145,7 +146,7 @@
|
||||
:group 'php-faces
|
||||
:tag "PHP Constant")
|
||||
|
||||
(defface php-constant-assign '((t (:inherit font-lock-type-face)))
|
||||
(defface php-constant-assign '((t (:inherit php-constant)))
|
||||
"PHP Mode face used to highlight constant assigning (\"const\" statement)."
|
||||
:group 'php-faces
|
||||
:tag "PHP Constant Assign")
|
||||
@@ -209,7 +210,8 @@
|
||||
:tag "PHP Class Declaration")
|
||||
|
||||
(defface php-class-declaration-spec '((t (:inherit php-keyword)))
|
||||
"PHP Mode Face used to highlight class declaration specification keywords (implements, extends)."
|
||||
"PHP Mode Face used to highlight class declaration specification keywords.
|
||||
The keywords include: implements, extends."
|
||||
:group 'php-faces
|
||||
:tag "PHP Class Declaration Specification")
|
||||
|
||||
@@ -239,7 +241,8 @@
|
||||
:tag "PHP Visibility Modifier")
|
||||
|
||||
(defface php-control-structure '((t (:inherit php-keyword)))
|
||||
"PHP Mode Face used to highlight control structures (if, foreach, while, switch, catch...)."
|
||||
"PHP Mode Face used to highlight control structures.
|
||||
The control structures include: if, foreach, while, switch, catch."
|
||||
:group 'php-faces
|
||||
:tag "PHP Control Structure")
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
;;; php-flymake.el --- Flymake backend for PHP -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2022 Friends of Emacs-PHP development
|
||||
;; Copyright (C) 2023 Friends of Emacs-PHP development
|
||||
|
||||
;; Author: USAMI Kenta <tadsan@zonu.me>
|
||||
;; Created: 5 Mar 2022
|
||||
;; Version: 1.24.2
|
||||
;; Version: 1.25.0
|
||||
;; Keywords: tools, languages, php
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'flymake)
|
||||
(require 'flymake-proc)
|
||||
(require 'cl-lib)
|
||||
(eval-when-compile
|
||||
(require 'pcase)
|
||||
|
||||
236
lisp/php-mode/php-format.el
Normal file
236
lisp/php-mode/php-format.el
Normal file
@@ -0,0 +1,236 @@
|
||||
;;; php-format.el --- Code reformatter for PHP buffer -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2020 Friends of Emacs-PHP development
|
||||
|
||||
;; Author: USAMI Kenta <tadsan@zonu.me>
|
||||
;; Created: 5 Mar 2023
|
||||
;; Version: 0.1.0
|
||||
;; Keywords: tools, php
|
||||
;; URL: https://github.com/emacs-php/php-mode.el
|
||||
;; License: GPL-3.0-or-later
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This feature is for execute PHP code formatting tools.
|
||||
|
||||
;; ## Supported tools:
|
||||
;;
|
||||
;; - Easy Coding Standard (ecs) https://github.com/easy-coding-standard/easy-coding-standard
|
||||
;; - PHP-CS-Fixer (php-cs-fixer) https://github.com/PHP-CS-Fixer/PHP-CS-Fixer
|
||||
;; - PHP_CodeSniffer (phpcbf) https://github.com/squizlabs/PHP_CodeSniffer
|
||||
;;
|
||||
;; It supports both per-project and globally installed ones.
|
||||
;;
|
||||
;; ## How to use
|
||||
;;
|
||||
;; Add following line to setup function for php-mode.
|
||||
;;
|
||||
;; (php-format-auto-mode +1)
|
||||
;;
|
||||
;; ## Customization
|
||||
;;
|
||||
;; These variables can be set either by dir-locals.el or by custom-set-variable.
|
||||
;;
|
||||
;; - php-format-auto-mode-hook-depth
|
||||
;; - php-format-command
|
||||
;; - php-format-command-dir
|
||||
;; - php-format-default-idle-time
|
||||
;; - php-format-result-display-method-alist
|
||||
;;
|
||||
;; ## Display methods
|
||||
;;
|
||||
;; How formatting is performed and how the results are displayed can be controlled
|
||||
;; by the following keywords.
|
||||
;;
|
||||
;; - idle: Asynchronously apply formatting to idle time in Emacs using `run-with-idle-timer'
|
||||
;; - async: Immediately execute an asynchronous process to apply formatting
|
||||
;; - compile: Apply formatting using the compile command. Doesn't lock, but results pop up
|
||||
;; - silent: Apply formatting immediately and synchronously.
|
||||
;; No message is displayed, but Emacs is locked while it is being processed.
|
||||
;; - nil: Apply formatting immediately and synchronously.
|
||||
;; Emacs will be locked until formatting is done and the result will pop up.
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
(require 'cl-lib)
|
||||
(require 'php-project)
|
||||
|
||||
(defvar php-format-formatter-alist
|
||||
'((ecs :marker ("ecs.php")
|
||||
:command ("ecs" "check" "--fix" "--no-progress-bar" "--"))
|
||||
(php-cs-fixer :marker (".php-cs-fixer.dist.php" ".php-cs-fixer.php")
|
||||
:command ("php-cs-fixer" "fix" "--show-progress=none"))
|
||||
(phpcbf :marker ("phpcs.xml.dist" "phpcs.xml")
|
||||
:command ("phpcbf"))))
|
||||
|
||||
(defvar php-format-lighter " phpf")
|
||||
(defvar php-format-output-buffer " *PHP Format*")
|
||||
(defvar php-format--exec-method nil)
|
||||
(defvar php-format--idle-timer nil)
|
||||
|
||||
;; Customize variables
|
||||
(defgroup php-format nil
|
||||
"Apply code reformat."
|
||||
:tag "PHP Format"
|
||||
:group 'php)
|
||||
|
||||
(defcustom php-format-auto-mode-hook-depth -50
|
||||
"A depth number in the range -100..100 for `add-hook'."
|
||||
:tag "PHP Format Auto Mode Hook Depth"
|
||||
:type 'integer
|
||||
:safe #'integerp
|
||||
:group 'php)
|
||||
|
||||
(defcustom php-format-command 'auto
|
||||
"A formatter symbol, or a list of command and arguments."
|
||||
:tag "PHP Format Command"
|
||||
:type '(choice (const :tag "Disabled reformat codes" nil)
|
||||
(const :tag "Auto" auto)
|
||||
(const :tag "Easy Coding Standard" ecs)
|
||||
(const :tag "PHP-CS-Fixer" php-cs-fixer)
|
||||
(const :tag "PHP Code Beautifier and Fixer" phpcbf)
|
||||
(repeat :tag "Command and arguments" string))
|
||||
:safe (lambda (v) (or (symbolp v) (listp v)))
|
||||
:group 'php-format)
|
||||
|
||||
(defcustom php-format-command-dir "vendor/bin"
|
||||
"A relative path to the directory where formatting tool is installed."
|
||||
:tag "PHP Format Command"
|
||||
:type 'string
|
||||
:safe #'stringp
|
||||
:group 'php-format)
|
||||
|
||||
(defcustom php-format-default-idle-time 3
|
||||
"Number of seconds to wait idle before formatting."
|
||||
:tag "PHP Format Auto Mode Hook Depth"
|
||||
:type 'integer
|
||||
:safe #'integerp
|
||||
:group 'php)
|
||||
|
||||
(defcustom php-format-result-display-method-alist '((php-format-on-after-save-hook . idle)
|
||||
(php-format-this-buffer-file . silent)
|
||||
(php-format-project . compile))
|
||||
"An alist of misplay the result method of the formatting process."
|
||||
:tag "PHP Format Result Display Method"
|
||||
:type '(alist :key-type function
|
||||
:value-type symbol)
|
||||
:group 'php-format)
|
||||
|
||||
(defcustom php-format-disable-async-format-buffer-has-modified t
|
||||
"When set to non-NIL, disables async formatting if buffer is modified (unsaved)."
|
||||
:tag "PHP Format Disable Async Format Buffer Has Modified"
|
||||
:type 'boolean
|
||||
:group 'php-format)
|
||||
|
||||
;; Internal functions
|
||||
(defsubst php-format--register-timer (sec command-args)
|
||||
"Register idle-timer with SEC and COMMAND-ARGS."
|
||||
(unless php-format--idle-timer
|
||||
(setq php-format--idle-timer
|
||||
(run-with-idle-timer sec nil #'php-format--execute-delayed-format
|
||||
default-directory command-args))))
|
||||
|
||||
(defun php-format--execute-format (files)
|
||||
"Execute PHP formatter with FILES."
|
||||
(let* ((default-directory (php-project-get-root-dir))
|
||||
(command-args (php-format--get-command-args))
|
||||
command-line)
|
||||
(when (null command-args)
|
||||
(user-error "No available PHP formatter settings detected"))
|
||||
(setq command-args (append command-args files))
|
||||
(setq command-line (mapconcat #'shell-quote-argument command-args " "))
|
||||
(pcase php-format--exec-method
|
||||
(`(idle ,sec) (php-format--register-timer sec command-args))
|
||||
('idle (php-format--register-timer php-format-default-idle-time command-args))
|
||||
('async (apply #'call-process-shell-command (car command-args) nil nil nil
|
||||
(append (cdr command-args) (list "&"))))
|
||||
('compile (compile command-line))
|
||||
('silent (shell-command-to-string command-line))
|
||||
('nil (shell-command command-line))
|
||||
(_ (user-error "`%s' is unexpected php-format--exec-method" php-format--exec-method)))))
|
||||
|
||||
(defun php-format--get-command-args ()
|
||||
"Return a list of command and arguments."
|
||||
(if (listp php-format-command)
|
||||
php-format-command
|
||||
(let ((cmd php-format-command)
|
||||
args executable vendor)
|
||||
(when (eq 'auto cmd)
|
||||
(setq cmd (cl-loop for (sym . plist) in php-format-formatter-alist
|
||||
for files = (plist-get plist :marker)
|
||||
if (cl-find-if
|
||||
(lambda (file) (file-exists-p (expand-file-name file default-directory)))
|
||||
files)
|
||||
return sym))
|
||||
(setq-local php-format-command cmd))
|
||||
(when-let (tup (plist-get (cdr-safe (assq cmd php-format-formatter-alist)) :command))
|
||||
(setq executable (car tup))
|
||||
(setq args (cdr tup))
|
||||
(setq vendor (expand-file-name executable (expand-file-name php-format-command-dir default-directory)))
|
||||
(cond
|
||||
((file-exists-p vendor) (cons vendor args))
|
||||
((executable-find executable) (cons executable args)))))))
|
||||
|
||||
(defun php-format--execute-delayed-format (dir command-args)
|
||||
"Asynchronously execute PHP format with COMMAND-ARGS in DIR."
|
||||
(setq php-format--idle-timer nil)
|
||||
(let ((default-directory dir))
|
||||
(when (not (and php-format-disable-async-format-buffer-has-modified
|
||||
(buffer-modified-p)))
|
||||
(apply #'call-process-shell-command (car command-args) nil nil nil
|
||||
(append (cdr command-args) (list "&"))))))
|
||||
|
||||
;; Public functions and minor mode
|
||||
|
||||
;;;###autoload
|
||||
(defun php-format-this-buffer-file ()
|
||||
"Apply format this buffer file."
|
||||
(interactive)
|
||||
(when php-format-command
|
||||
(when (null buffer-file-name)
|
||||
(user-error "This file has not yet been saved"))
|
||||
(when (file-remote-p buffer-file-name)
|
||||
(user-error "PHP Format feature does not yet support remote files"))
|
||||
(let ((php-format--exec-method (cdr-safe (assq 'php-format-this-buffer-file php-format-result-display-method-alist))))
|
||||
(php-format--execute-format (list buffer-file-name)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun php-format-project ()
|
||||
"Apply format this buffer file."
|
||||
(interactive)
|
||||
(unless php-format-command
|
||||
(user-error "Disabled `php-format-command' in this project"))
|
||||
(let ((php-format--exec-method (cdr-safe (assq 'php-format-project php-format-result-display-method-alist))))
|
||||
(php-format--execute-format nil)))
|
||||
|
||||
;;;###autoload
|
||||
(defun php-format-on-after-save-hook ()
|
||||
"Apply format on after save hook."
|
||||
(when (and php-format-command buffer-file-name (not (file-remote-p buffer-file-name)))
|
||||
(let ((php-format--exec-method (cdr-safe (assq 'php-format-on-after-save-hook php-format-result-display-method-alist))))
|
||||
(php-format--execute-format nil))))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode php-format-auto-mode
|
||||
"Automatically apply formatting when saving an edited file."
|
||||
:group 'php-format
|
||||
:lighter php-format-lighter
|
||||
(if php-format-auto-mode
|
||||
(add-hook 'after-save-hook 'php-format-on-after-save-hook php-format-auto-mode-hook-depth t)
|
||||
(remove-hook 'after-save-hook 'php-format-on-after-save-hook t)))
|
||||
|
||||
(provide 'php-format)
|
||||
;;; php-format.el ends here
|
||||
127
lisp/php-mode/php-ide-phpactor.el
Normal file
127
lisp/php-mode/php-ide-phpactor.el
Normal file
@@ -0,0 +1,127 @@
|
||||
;;; php-ide-phpactor.el --- PHP-IDE feature using Phpactor RPC -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2023 Friends of Emacs-PHP development
|
||||
|
||||
;; Author: USAMI Kenta <tadsan@zonu.me>
|
||||
;; Keywords: tools, files
|
||||
;; URL: https://github.com/emacs-php/php-mode
|
||||
;; Version: 1.25.0
|
||||
;; License: GPL-3.0-or-later
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; PHP-IDE implementation to integrate Phpactor (phpactor.el).
|
||||
;; This feature depends on <https://github.com/emacs-php/phpactor.el>.
|
||||
|
||||
;;; Code:
|
||||
(require 'phpactor nil t)
|
||||
(require 'popup nil t)
|
||||
(require 'smart-jump nil t)
|
||||
(eval-when-compile
|
||||
(require 'cl-lib))
|
||||
|
||||
(defvar-local php-ide-phpactor-buffer nil)
|
||||
(defvar-local php-ide-phpactor-hover-last-pos nil)
|
||||
(defvar-local php-ide-phpactor-hover-last-msg nil)
|
||||
|
||||
(declare-function phpactor--command-argments "ext:phpactor" (&rest arg-keys))
|
||||
(declare-function phpactor--parse-json "ext:phpactor" (buffer))
|
||||
(declare-function phpactor--rpc-async "ext:phpactor" (action arguments callback))
|
||||
(declare-function phpactor-goto-definition "ext:phpactor" ())
|
||||
(declare-function popup-tip "ext:popup" (string))
|
||||
(declare-function smart-jump-back "ext:smart-jump" ())
|
||||
(declare-function smart-jump-go "ext:smart-jump" (&optional smart-list continue))
|
||||
(declare-function smart-jump-references "ext:smart-jump" (&optional smart-list continue))
|
||||
|
||||
(defgroup php-ide-phpactor nil
|
||||
"UI support for PHP developing."
|
||||
:tag "PHP-IDE Phpactor"
|
||||
:prefix "php-ide-phpactor-"
|
||||
:group 'php-ide)
|
||||
|
||||
(defcustom php-ide-phpactor-activate-features '(all)
|
||||
"A set of Phpactor features you want to enable."
|
||||
:tag "PHP-IDE Phpactor Activate Features"
|
||||
:type '(set (const all :tag "All")
|
||||
(const hover)
|
||||
(const navigation))
|
||||
:safe (lambda (v) (and (listp v)))
|
||||
:group 'php-ide-phpactor)
|
||||
|
||||
(defvar php-ide-phpactor-timer nil
|
||||
"Timer object for execute Phpactor and display hover message.")
|
||||
|
||||
(defvar php-ide-phpactor-disable-hover-at-point-functions
|
||||
'(php-in-string-or-comment-p))
|
||||
|
||||
(defun php-ide-phpactor--disable-hover-at-point-p ()
|
||||
"Return non-NIL if any function return non-NIL for disable to hover at point."
|
||||
(cl-loop for f in php-ide-phpactor-disable-hover-at-point-functions
|
||||
never (not (funcall f))))
|
||||
|
||||
(defun php-ide-phpactor-hover ()
|
||||
"Show brief information about the symbol underneath the cursor."
|
||||
(interactive)
|
||||
(when (and php-ide-phpactor-buffer (not (php-ide-phpactor--disable-hover-at-point-p)))
|
||||
(if (eq (point) php-ide-phpactor-hover-last-pos)
|
||||
(when php-ide-phpactor-hover-last-msg
|
||||
(let ((msg php-ide-phpactor-hover-last-msg))
|
||||
(setq php-ide-phpactor-hover-last-msg nil)
|
||||
(popup-tip msg)))
|
||||
(setq php-ide-phpactor-hover-last-pos (point))
|
||||
(let ((main-buffer (current-buffer)))
|
||||
(phpactor--rpc-async "hover" (phpactor--command-argments :source :offset)
|
||||
(lambda (proc)
|
||||
(let* ((response (phpactor--parse-json (process-buffer proc)))
|
||||
(msg (plist-get (plist-get response :parameters) :message)))
|
||||
(with-current-buffer main-buffer
|
||||
(setq php-ide-phpactor-hover-last-msg msg)))))))))
|
||||
|
||||
(defsubst php-ide-phpactor--feature-activated-p (feature)
|
||||
"Is FEATURE activated in `php-ide-phpactor-activate-features'."
|
||||
(or (memq 'all php-ide-phpactor-activate-features)
|
||||
(memq feature php-ide-phpactor-activate-features)))
|
||||
|
||||
;;;###autoload
|
||||
(defun php-ide-phpactor-activate ()
|
||||
"Activate PHP-IDE using phpactor.el."
|
||||
(interactive)
|
||||
(when (php-ide-phpactor--feature-activated-p 'navigation)
|
||||
(if (not (bound-and-true-p phpactor-smart-jump-initialized))
|
||||
(local-set-key [remap xref-find-definitions] #'phpactor-goto-definition)
|
||||
(local-set-key [remap xref-find-definitions] #'smart-jump-go)
|
||||
(local-set-key [remap xref-pop-marker-stack] #'smart-jump-back)
|
||||
(local-set-key [remap xref-find-references] #'smart-jump-references)))
|
||||
(when (php-ide-phpactor--feature-activated-p 'hover)
|
||||
(unless php-ide-phpactor-timer
|
||||
(setq php-ide-phpactor-timer (run-with-timer 0.8 0.8 #'php-ide-phpactor-hover))))
|
||||
(setq php-ide-phpactor-buffer t))
|
||||
|
||||
;;;###autoload
|
||||
(defun php-ide-phpactor-deactivate ()
|
||||
"Dectivate PHP-IDE using phpactor.el."
|
||||
(interactive)
|
||||
(local-unset-key [remap xref-find-definitions])
|
||||
(local-unset-key [remap xref-pop-marker-stack])
|
||||
(local-unset-key [remap xref-find-references])
|
||||
|
||||
(when php-ide-phpactor-timer
|
||||
(cancel-timer php-ide-phpactor-timer)
|
||||
(setq php-ide-phpactor-timer nil))
|
||||
(setq php-ide-phpactor-buffer nil))
|
||||
|
||||
(provide 'php-ide-phpactor)
|
||||
;;; php-ide-phpactor.el ends here
|
||||
240
lisp/php-mode/php-ide.el
Normal file
240
lisp/php-mode/php-ide.el
Normal file
@@ -0,0 +1,240 @@
|
||||
;;; php-ide.el --- IDE-like UI support for PHP development -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2023 Friends of Emacs-PHP development
|
||||
|
||||
;; Author: USAMI Kenta <tadsan@zonu.me>
|
||||
;; Keywords: tools, files
|
||||
;; URL: https://github.com/emacs-php/php-mode
|
||||
;; Version: 1.25.0
|
||||
;; License: GPL-3.0-or-later
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; PHP Mode integrates LSP Mode (lsp-mode), Phpactor (phpactor.el) and IDE-like tools.
|
||||
;;
|
||||
;; **Note**:
|
||||
;; This feature is under development and experimental.
|
||||
;; All of these functions, modes and terms are subject to change without notice.
|
||||
;;
|
||||
;; ## Motivations
|
||||
;;
|
||||
;; There are some IDE-like features / packages for PHP development.
|
||||
;; PHP-IDE bridges projects and their IDE-like features.
|
||||
;;
|
||||
;; ## IDE Features
|
||||
;;
|
||||
;; We don't recommend features, but bundle some feature bridges.
|
||||
;; They are sorted alphabetically except "none."
|
||||
;;
|
||||
;; - none
|
||||
;; Does not launch any IDE features.
|
||||
;; - eglot
|
||||
;; https://github.com/joaotavora/eglot
|
||||
;; - lsp-bridge
|
||||
;; https://github.com/manateelazycat/lsp-bridge
|
||||
;; - lsp-mode
|
||||
;; https://emacs-lsp.github.io/lsp-mode/
|
||||
;; https://github.com/emacs-lsp/lsp-mode
|
||||
;; - phpactor
|
||||
;; https://phpactor.readthedocs.io/
|
||||
;; https://github.com/phpactor/phpactor
|
||||
;; https://github.com/emacs-php/phpactor.el
|
||||
;;
|
||||
;; ## Configuration
|
||||
;;
|
||||
;; Put follows code into your .emacs (~/.emacs.d/init.el) file:
|
||||
;;
|
||||
;; (defun init-php-mode-setup ()
|
||||
;; (add-hook 'hack-local-variables-hook #'php-ide-mode t t))
|
||||
;;
|
||||
;; (defun init-php-ide-mode-setup (feature activate)
|
||||
;; (pcase feature
|
||||
;; (`lsp-bridge
|
||||
;; (if activate
|
||||
;; (progn (yas-minor-mode +1)
|
||||
;; (corfu-mode -1))
|
||||
;; (yas-minor-mode -1)
|
||||
;; (corfu-mode +1)))))
|
||||
;;
|
||||
;; (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")
|
||||
;; ;; If you want to hide php-ide-mode from the mode line, set an empty string
|
||||
;; '(php-ide-mode-lighter ""))
|
||||
;;
|
||||
;; (add-hook 'php-mode-hook #'init-php-mode-setup)
|
||||
;; (add-hook 'php-ide-mode-functions #'init-php-ide-mode-setup))
|
||||
;;
|
||||
;; If you don't enable IDE support by default, set '(php-ide-feature 'none)
|
||||
;;
|
||||
;; ### For per project configuration
|
||||
;;
|
||||
;; Put follows code into .dir-locals.el in project directory:
|
||||
;;
|
||||
;; ((nil (php-project-root . git)
|
||||
;; (php-ide-features . (lsp-mode))))
|
||||
;;
|
||||
;; If you can't put .dir-locals.el in your project directory, consider the sidecar-locals package.
|
||||
;; https://melpa.org/#/sidecar-locals
|
||||
;; https://codeberg.org/ideasman42/emacs-sidecar-locals
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
(require 'cl-lib)
|
||||
(require 'php-project)
|
||||
|
||||
(eval-when-compile
|
||||
(require 'php-ide-phpactor)
|
||||
(defvar eglot-server-programs)
|
||||
(declare-function lsp-bridge-mode "ext:lsp-bridge" ())
|
||||
(declare-function eglot-ensure "ext:eglot" ())
|
||||
(declare-function eglot--managed-mode-off "ext:eglot" ())
|
||||
(declare-function phpactor--find-executable "ext:phpactor" ()))
|
||||
|
||||
(defvar php-ide-feature-alist
|
||||
'((none :test (lambda () t)
|
||||
:activate (lambda () t)
|
||||
:deactivate (lambda () t))
|
||||
(phpactor :test (lambda () (and (require 'phpactor nil t) (featurep 'phpactor)))
|
||||
:activate php-ide-phpactor-activate
|
||||
:deactivate php-ide-phpactor-activate)
|
||||
(eglot :test (lambda () (and (require 'eglot nil t) (featurep 'eglot)))
|
||||
:activate eglot-ensure
|
||||
:deactivate eglot--managed-mode-off)
|
||||
(lsp-bridge :test (lambda () (and (require 'lsp-bridge nil t) (featurep 'lsp-bridge)))
|
||||
:activate (lambda () (lsp-bridge-mode +1))
|
||||
:deactivate (lambda () (lsp-bridge-mode -1)))
|
||||
(lsp-mode :test (lambda () (and (require 'lsp nil t) (featurep 'lsp)))
|
||||
:activate lsp
|
||||
:deactivate lsp-workspace-shutdown)))
|
||||
|
||||
(defvar php-ide-lsp-command-alist
|
||||
'((intelephense "intelephense" "--stdio")
|
||||
(phpactor . (lambda () (list (if (fboundp 'phpactor--find-executable)
|
||||
(phpactor--find-executable)
|
||||
"phpactor")
|
||||
"language-server")))))
|
||||
|
||||
(defgroup php-ide nil
|
||||
"IDE-like support for PHP developing."
|
||||
:tag "PHP-IDE"
|
||||
:prefix "php-ide-"
|
||||
:group 'php)
|
||||
|
||||
;;;###autoload
|
||||
(defcustom php-ide-features nil
|
||||
"A set of PHP-IDE features symbol."
|
||||
:tag "PHP-IDE Feature"
|
||||
:group 'php-ide
|
||||
:type `(set ,@(mapcar (lambda (feature) (list 'const (car feature)))
|
||||
php-ide-feature-alist)
|
||||
symbol)
|
||||
:safe (lambda (v) (cl-loop for feature in (if (listp v) v (list v))
|
||||
always (symbolp feature))))
|
||||
|
||||
;;;###autoload
|
||||
(defcustom php-ide-eglot-executable nil
|
||||
"Command name or path to the command of Eglot LSP executable."
|
||||
:tag "PHP-IDE Eglot Executable"
|
||||
:group 'php-ide
|
||||
:type '(choice
|
||||
(const intelephense)
|
||||
(const phpactor)
|
||||
string (repeat string))
|
||||
:safe (lambda (v) (cond
|
||||
((stringp v) (file-exists-p v))
|
||||
((listp v) (cl-every #'stringp v))
|
||||
((assq v php-ide-lsp-command-alist)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun php-ide-eglot-server-program ()
|
||||
"Return a list of command to execute LSP Server."
|
||||
(cond
|
||||
((stringp php-ide-eglot-executable) (list php-ide-eglot-executable))
|
||||
((listp php-ide-eglot-executable) php-ide-eglot-executable)
|
||||
((when-let (command (assq php-ide-eglot-executable php-ide-lsp-command-alist))
|
||||
(cond
|
||||
((functionp command) (funcall command))
|
||||
((listp command) command))))))
|
||||
|
||||
(defcustom php-ide-mode-lighter " PHP-IDE"
|
||||
"A symbol of PHP-IDE feature."
|
||||
:tag "PHP-IDE Mode Lighter"
|
||||
:group 'php-ide
|
||||
:type 'string
|
||||
:safe #'stringp)
|
||||
|
||||
(defcustom php-ide-mode-functions nil
|
||||
"Hook functions called when before activating or deactivating PHP-IDE.
|
||||
Notice that two arguments (FEATURE ACTIVATE) are given.
|
||||
|
||||
FEATURE: A symbol, like \\='lsp-mode.
|
||||
ACTIVATE: T is given when activeting, NIL when deactivating PHP-IDE."
|
||||
:tag "PHP-IDE Mode Functions"
|
||||
:group 'php-ide
|
||||
:type '(repeat function)
|
||||
:safe (lambda (functions)
|
||||
(and (listp functions)
|
||||
(cl-loop for function in functions
|
||||
always (functionp function)))))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode php-ide-mode
|
||||
"Minor mode for integrate IDE-like tools."
|
||||
:lighter php-ide-mode-lighter
|
||||
(let ((ide-features php-ide-features))
|
||||
(when-let (unavailable-features (cl-loop for feature in ide-features
|
||||
unless (assq feature php-ide-feature-alist)
|
||||
collect feature))
|
||||
(user-error "%s includes unavailable PHP-IDE features. (available features are: %s)"
|
||||
ide-features
|
||||
(mapconcat (lambda (feature) (concat "'" (symbol-name feature)))
|
||||
(php-ide--avilable-features) ", ")))
|
||||
(cl-loop for feature in ide-features
|
||||
for ide-plist = (cdr-safe (assq feature php-ide-feature-alist))
|
||||
do (if (null ide-plist)
|
||||
(message "Please set `php-ide-feature' variable in .dir-locals.el or custom variable")
|
||||
(run-hook-with-args 'php-ide-mode-functions feature php-ide-mode)
|
||||
(if php-ide-mode
|
||||
(php-ide--activate-buffer feature ide-plist)
|
||||
(php-ide--deactivate-buffer ide-plist))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun php-ide-turn-on ()
|
||||
"Turn on PHP IDE-FEATURES and execute `php-ide-mode'."
|
||||
(unless php-ide-features
|
||||
(user-error "No PHP-IDE feature is installed. Install the lsp-mode, lsp-bridge, eglot or phpactor package"))
|
||||
(php-ide-mode +1))
|
||||
|
||||
(defun php-ide--activate-buffer (name ide-plist)
|
||||
"Activate php-ide implementation by NAME and IDE-PLIST."
|
||||
(unless (funcall (plist-get ide-plist :test))
|
||||
(user-error "PHP-IDE feature `%s' is not available" name))
|
||||
(funcall (plist-get ide-plist :activate)))
|
||||
|
||||
(defun php-ide--deactivate-buffer (ide-plist)
|
||||
"Deactivate php-ide implementation by IDE-PLIST."
|
||||
(funcall (plist-get ide-plist :deactivate)))
|
||||
|
||||
(defun php-ide--avilable-features ()
|
||||
"Return list of available PHP-IDE features."
|
||||
(cl-loop for (ide . plist) in php-ide-feature-alist
|
||||
if (funcall (plist-get plist :test))
|
||||
collect ide))
|
||||
|
||||
(provide 'php-ide)
|
||||
;;; php-ide.el ends here
|
||||
@@ -1,6 +1,6 @@
|
||||
;;; php-local-manual.el --- Tools for local PHP manual -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2022 Friends of Emacs-PHP development
|
||||
;; Copyright (C) 2023 Friends of Emacs-PHP development
|
||||
|
||||
;; Author: phil-s
|
||||
;; Maintainer: USAMI Kenta <tadsan@zonu.me>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
;;; php-mode-debug.el --- Debug functions for PHP Mode -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2022 Friends of Emacs-PHP development
|
||||
;; Copyright (C) 2023 Friends of Emacs-PHP development
|
||||
|
||||
;; Author: USAMI Kenta <tadsan@zonu.me>
|
||||
;; URL: https://github.com/emacs-php/php-mode
|
||||
;; Keywords: maint
|
||||
;; Version: 1.24.2
|
||||
;; Version: 1.25.0
|
||||
;; License: GPL-3.0-or-later
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
(define-package "php-mode" "20221112.1616" "Major mode for editing PHP code"
|
||||
'((emacs "25.2"))
|
||||
:commit "d01cfc9cd51706e076bf7e5cbf0cfa7ee885efb4" :maintainer
|
||||
(define-package "php-mode" "20230929.123" "Major mode for editing PHP code"
|
||||
'((emacs "26.1"))
|
||||
:commit "4a29636243ba7f4afba476348587713531d994bc" :maintainers
|
||||
'(("USAMI Kenta" . "tadsan@zonu.me"))
|
||||
:maintainer
|
||||
'("USAMI Kenta" . "tadsan@zonu.me")
|
||||
:keywords
|
||||
'("languages" "php")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
;;; php-mode.el --- Major mode for editing PHP code -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2022 Friends of Emacs-PHP development
|
||||
;; Copyright (C) 2023 Friends of Emacs-PHP development
|
||||
;; Copyright (C) 1999, 2000, 2001, 2003, 2004 Turadg Aleahmad
|
||||
;; 2008 Aaron S. Hawley
|
||||
;; 2011, 2012, 2013, 2014, 2015, 2016, 2017 Eric James Michael Ritz
|
||||
@@ -9,13 +9,13 @@
|
||||
;; Maintainer: USAMI Kenta <tadsan@zonu.me>
|
||||
;; URL: https://github.com/emacs-php/php-mode
|
||||
;; Keywords: languages php
|
||||
;; Version: 1.24.2
|
||||
;; Package-Requires: ((emacs "25.2"))
|
||||
;; Version: 1.25.0
|
||||
;; Package-Requires: ((emacs "26.1"))
|
||||
;; License: GPL-3.0-or-later
|
||||
|
||||
(eval-and-compile
|
||||
(make-obsolete-variable
|
||||
(defconst php-mode-version-number "1.24.2" "PHP Mode version number.")
|
||||
(defconst php-mode-version-number "1.25.0" "PHP Mode version number.")
|
||||
"Please call (php-mode-version :as-number t) for compatibility." "1.24.2"))
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
@@ -73,6 +73,7 @@
|
||||
(require 'custom)
|
||||
(require 'speedbar)
|
||||
(require 'imenu)
|
||||
(require 'consult-imenu nil t)
|
||||
(require 'package)
|
||||
(require 'nadvice)
|
||||
(require 'mode-local)
|
||||
@@ -82,6 +83,7 @@
|
||||
(require 'rx)
|
||||
(require 'cl-lib)
|
||||
(require 'flymake)
|
||||
(require 'flymake-proc)
|
||||
(require 'php-flymake)
|
||||
(require 'regexp-opt)
|
||||
(declare-function acm-backend-tabnine-candidate-expand "ext:acm-backend-tabnine"
|
||||
@@ -138,7 +140,6 @@ When CALLED-INTERACTIVE then message the result." t)
|
||||
(define-obsolete-variable-alias 'php-default-face 'php-mode-default-face "1.20.0")
|
||||
(defcustom php-mode-default-face 'default
|
||||
"Default face in `php-mode' buffers."
|
||||
:group 'php-mode
|
||||
:tag "PHP Mode Default Face"
|
||||
:type 'face)
|
||||
|
||||
@@ -146,7 +147,6 @@ When CALLED-INTERACTIVE then message the result." t)
|
||||
(defcustom php-mode-speedbar-config t
|
||||
"When set to true automatically configures Speedbar to observe PHP files.
|
||||
Ignores php-file patterns option; fixed to expression \"\\.\\(inc\\|php[s345]?\\)\""
|
||||
:group 'php-mode
|
||||
:tag "PHP Mode Speedbar Config"
|
||||
:type 'boolean
|
||||
:set (lambda (sym val)
|
||||
@@ -158,7 +158,6 @@ Ignores php-file patterns option; fixed to expression \"\\.\\(inc\\|php[s345]?\\
|
||||
(defcustom php-mode-speedbar-open nil
|
||||
"Normally `php-mode' starts with the speedbar closed.
|
||||
Turning this on will open it whenever `php-mode' is loaded."
|
||||
:group 'php-mode
|
||||
:tag "PHP Mode Speedbar Open"
|
||||
:type 'boolean
|
||||
:set (lambda (sym val)
|
||||
@@ -169,14 +168,12 @@ Turning this on will open it whenever `php-mode' is loaded."
|
||||
(define-obsolete-variable-alias 'php-template-compatibility 'php-mode-template-compatibility "1.20.0")
|
||||
(defcustom php-mode-template-compatibility t
|
||||
"Should detect presence of html tags."
|
||||
:group 'php-mode
|
||||
:tag "PHP Mode Template Compatibility"
|
||||
:type 'boolean)
|
||||
|
||||
(define-obsolete-variable-alias 'php-lineup-cascaded-calls 'php-mode-lineup-cascaded-calls "1.20.0")
|
||||
(defcustom php-mode-lineup-cascaded-calls nil
|
||||
"Indent chained method calls to the previous line."
|
||||
:group 'php-mode
|
||||
:tag "PHP Mode Lineup Cascaded Calls"
|
||||
:type 'boolean)
|
||||
|
||||
@@ -186,7 +183,6 @@ Turning this on will open it whenever `php-mode' is loaded."
|
||||
(or "namespace" "function" "class" "trait" "interface")
|
||||
symbol-end))
|
||||
"Regexp describing line-beginnings that PHP declaration statements."
|
||||
:group 'php-mode
|
||||
:tag "PHP Mode Page Delimiter"
|
||||
:type 'regexp)
|
||||
|
||||
@@ -194,7 +190,6 @@ Turning this on will open it whenever `php-mode' is loaded."
|
||||
(eval-when-compile (when (boundp 'flymake-diagnostic-functions)
|
||||
#'php-flymake))
|
||||
"Flymake function to replace, if NIL do not replace."
|
||||
:group 'php-mode
|
||||
:tag "PHP Mode Replace Flymake Diag Function"
|
||||
:type '(choice 'function
|
||||
(const :tag "Disable to replace" nil)))
|
||||
@@ -208,7 +203,6 @@ set to `semantic-create-imenu-index' due to `c-mode' being its
|
||||
parent. Set this variable to t if you want to use
|
||||
`imenu-default-create-index-function' even with `semantic-mode'
|
||||
enabled."
|
||||
:group 'php-mode
|
||||
:tag "PHP Mode Do Not Use Semantic Imenu"
|
||||
:type 'boolean)
|
||||
|
||||
@@ -219,44 +213,37 @@ enabled."
|
||||
|
||||
(defcustom php-mode-hook nil
|
||||
"List of functions to be executed on entry to `php-mode'."
|
||||
:group 'php-mode
|
||||
:tag "PHP Mode Hook"
|
||||
:type 'hook)
|
||||
|
||||
(defcustom php-mode-pear-hook nil
|
||||
"Hook called when a PHP PEAR file is opened with `php-mode'."
|
||||
:group 'php-mode
|
||||
:tag "PHP Mode Pear Hook"
|
||||
:type 'hook)
|
||||
|
||||
(defcustom php-mode-drupal-hook nil
|
||||
"Hook called when a Drupal file is opened with `php-mode'."
|
||||
:group 'php-mode
|
||||
:tag "PHP Mode Drupal Hook"
|
||||
:type 'hook)
|
||||
|
||||
(defcustom php-mode-wordpress-hook nil
|
||||
"Hook called when a WordPress file is opened with `php-mode'."
|
||||
:group 'php-mode
|
||||
:tag "PHP Mode WordPress Hook"
|
||||
:type 'hook)
|
||||
|
||||
(defcustom php-mode-symfony2-hook nil
|
||||
"Hook called when a Symfony2 file is opened with `php-mode'."
|
||||
:group 'php-mode
|
||||
:tag "PHP Mode Symfony2 Hook"
|
||||
:type 'hook)
|
||||
|
||||
(defcustom php-mode-psr2-hook nil
|
||||
"Hook called when a PSR-2 file is opened with `php-mode'."
|
||||
:group 'php-mode
|
||||
:tag "PHP Mode PSR-2 Hook"
|
||||
:type 'hook)
|
||||
|
||||
(defcustom php-mode-force-pear nil
|
||||
"Normally PEAR coding rules are enforced only when the filename contains \"PEAR\".
|
||||
Turning this on will force PEAR rules on all PHP files."
|
||||
:group 'php-mode
|
||||
:tag "PHP Mode Force Pear"
|
||||
:type 'boolean)
|
||||
|
||||
@@ -265,7 +252,6 @@ Turning this on will force PEAR rules on all PHP files."
|
||||
mumamo-mode turned on. Detects if there are any HTML tags in the
|
||||
buffer before warning, but this is is not very smart; e.g. if you
|
||||
have any tags inside a PHP string, it will be fooled."
|
||||
:group 'php-mode
|
||||
:tag "PHP Mode Warn If MuMaMo Off"
|
||||
:type '(choice (const :tag "Warn" t) (const "Don't warn" nil)))
|
||||
|
||||
@@ -279,7 +265,6 @@ This variable can take one of the following symbol values:
|
||||
`Drupal' - use coding styles preferred for working with Drupal projects.
|
||||
`WordPress' - use coding styles preferred for working with WordPress projects.
|
||||
`Symfony2' - use coding styles preferred for working with Symfony2 projects."
|
||||
:group 'php-mode
|
||||
:tag "PHP Mode Coding Style"
|
||||
:type '(choice (const :tag "Default" php)
|
||||
(const :tag "PEAR" pear)
|
||||
@@ -287,7 +272,7 @@ This variable can take one of the following symbol values:
|
||||
(const :tag "WordPress" wordpress)
|
||||
(const :tag "Symfony2" symfony2)
|
||||
(const :tag "PSR-2" psr2))
|
||||
:initialize 'custom-initialize-default)
|
||||
:initialize #'custom-initialize-default)
|
||||
|
||||
;; Since this function has a bad influence on the environment of many users,
|
||||
;; temporarily disable it
|
||||
@@ -296,7 +281,6 @@ This variable can take one of the following symbol values:
|
||||
|
||||
If you want to suppress styles from being overwritten by directory / file
|
||||
local variables, set NIL."
|
||||
:group 'php-mode
|
||||
:tag "PHP Mode Enable Project Coding Style"
|
||||
:type 'boolean)
|
||||
|
||||
@@ -305,21 +289,18 @@ local variables, set NIL."
|
||||
|
||||
This function may interfere with other hooks and other behaviors.
|
||||
In that case set to `NIL'."
|
||||
:group 'php-mode
|
||||
:tag "PHP Mode Enable Backup Style Variables"
|
||||
:type 'boolean)
|
||||
|
||||
(define-obsolete-variable-alias 'php-mode-disable-parent-mode-hooks 'php-mode-disable-c-mode-hook "1.21.0")
|
||||
(defcustom php-mode-disable-c-mode-hook t
|
||||
"When set to `T', do not run hooks of parent modes (`java-mode', `c-mode')."
|
||||
:group 'php-mode
|
||||
:tag "PHP Mode Disable C Mode Hook"
|
||||
:type 'boolean)
|
||||
(make-obsolete-variable 'php-mode-disable-c-mode-hook nil "1.24.2")
|
||||
|
||||
(defcustom php-mode-enable-project-local-variable t
|
||||
"When set to `T', apply project local variable to buffer local variable."
|
||||
:group 'php-mode
|
||||
:tag "PHP Mode Enable Project Local Variable"
|
||||
:type 'boolean)
|
||||
|
||||
@@ -358,7 +339,7 @@ as a function. Call with AS-NUMBER keyword to compare by `version<'.
|
||||
;;
|
||||
;; Changing the default to mark-defun provides behavior that users
|
||||
;; are more likely to expect.
|
||||
(define-key map (kbd "C-M-h") 'mark-defun)
|
||||
(define-key map (kbd "C-M-h") #'mark-defun)
|
||||
|
||||
;; Many packages based on cc-mode provide the 'C-c C-w' binding
|
||||
;; to toggle Subword Mode. See the page
|
||||
@@ -366,7 +347,7 @@ as a function. Call with AS-NUMBER keyword to compare by `version<'.
|
||||
;; https://www.gnu.org/software/emacs/manual/html_node/ccmode/Subword-Movement.html
|
||||
;;
|
||||
;; for more information about Subword mode.
|
||||
(define-key map (kbd "C-c C-w") 'subword-mode)
|
||||
(define-key map (kbd "C-c C-w") #'subword-mode)
|
||||
|
||||
;; We inherit c-beginning-of-defun and c-end-of-defun from CC Mode
|
||||
;; but we have two replacement functions specifically for PHP. We
|
||||
@@ -374,19 +355,19 @@ as a function. Call with AS-NUMBER keyword to compare by `version<'.
|
||||
;; key-bindings so that our PHP-specific versions will work even
|
||||
;; if the user has reconfigured their keys, e.g. if they rebind
|
||||
;; c-end-of-defun to something other than C-M-e.
|
||||
(define-key map [remap c-beginning-of-defun] 'php-beginning-of-defun)
|
||||
(define-key map [remap c-end-of-defun] 'php-end-of-defun)
|
||||
(define-key map [remap c-set-style] 'php-set-style)
|
||||
(define-key map [remap c-beginning-of-defun] #'php-beginning-of-defun)
|
||||
(define-key map [remap c-end-of-defun] #'php-end-of-defun)
|
||||
(define-key map [remap c-set-style] #'php-set-style)
|
||||
|
||||
(define-key map [(control c) (control f)] 'php-search-documentation)
|
||||
(define-key map [(meta tab)] 'php-complete-function)
|
||||
(define-key map [(control c) (control m)] 'php-browse-manual)
|
||||
(define-key map [(control .)] 'php-show-arglist)
|
||||
(define-key map [(control c) (control r)] 'php-send-region)
|
||||
(define-key map [(control c) (control f)] #'php-search-documentation)
|
||||
(define-key map [(meta tab)] #'php-complete-function)
|
||||
(define-key map [(control c) (control m)] #'php-browse-manual)
|
||||
(define-key map [(control .)] #'php-show-arglist)
|
||||
(define-key map [(control c) (control r)] #'php-send-region)
|
||||
;; Use the Emacs standard indentation binding. This may upset c-mode
|
||||
;; which does not follow this at the moment, but I see no better
|
||||
;; choice.
|
||||
(define-key map [tab] 'indent-for-tab-command)
|
||||
(define-key map "\t" nil) ;Hide CC-mode's `TAB' binding.
|
||||
map)
|
||||
"Keymap for `php-mode'.")
|
||||
|
||||
@@ -496,10 +477,10 @@ PHP does not have an C-like \"enum\" keyword."
|
||||
php nil)
|
||||
|
||||
(c-lang-defconst c-typeless-decl-kwds
|
||||
php (append (c-lang-const c-class-decl-kwds) '("function")))
|
||||
php (append (c-lang-const c-class-decl-kwds php) '("function" "const")))
|
||||
|
||||
(c-lang-defconst c-modifier-kwds
|
||||
php '("abstract" "const" "final" "static" "case" "readonly"))
|
||||
php '("abstract" "final" "static" "case" "readonly"))
|
||||
|
||||
(c-lang-defconst c-protection-kwds
|
||||
"Access protection label keywords in classes."
|
||||
@@ -663,6 +644,7 @@ but only if the setting is enabled."
|
||||
((looking-at-p "->") '+)
|
||||
((looking-at-p "[:?]") '+)
|
||||
((looking-at-p "[,;]") nil)
|
||||
((looking-at-p "//") nil)
|
||||
;; Is the previous line terminated with `,' ?
|
||||
((progn
|
||||
(forward-line -1)
|
||||
@@ -672,7 +654,7 @@ but only if the setting is enabled."
|
||||
(while (and (< beginning-of-langelem (point))
|
||||
(setq start (php-in-string-or-comment-p)))
|
||||
(goto-char start)
|
||||
(skip-chars-backward " ")
|
||||
(skip-chars-backward " \r\n")
|
||||
(backward-char 1))
|
||||
(and (not (eq (point) beginning-of-current-line))
|
||||
(not (looking-at-p ","))
|
||||
@@ -680,13 +662,14 @@ but only if the setting is enabled."
|
||||
'+)
|
||||
(t nil)))))))
|
||||
|
||||
(defun php-c-looking-at-or-maybe-in-bracelist (&optional _containing-sexp lim)
|
||||
(defun php-c-looking-at-or-maybe-in-bracelist (orig-fun &optional containing-sexp lim &rest args)
|
||||
"Replace `c-looking-at-or-maybe-in-bracelist'.
|
||||
|
||||
CONTAINING-SEXP is the position of the brace/paren/bracket enclosing
|
||||
POINT, or nil if there is no such position, or we do not know it. LIM is
|
||||
a backward search limit."
|
||||
(cond
|
||||
((not (derived-mode-p 'php-mode)) (apply orig-fun containing-sexp lim args))
|
||||
((looking-at-p "{")
|
||||
(save-excursion
|
||||
(c-backward-token-2 2 t lim)
|
||||
@@ -733,7 +716,8 @@ a backward search limit."
|
||||
'("php"
|
||||
(c-basic-offset . 4)
|
||||
(c-offsets-alist . ((case-label . 0)))
|
||||
(tab-width . 4)))
|
||||
(tab-width . 4)
|
||||
(php-mode-lineup-cascaded-calls . nil)))
|
||||
|
||||
(defun php-enable-pear-coding-style ()
|
||||
"Set up `php-mode' to use the coding styles preferred for PEAR code and modules."
|
||||
@@ -862,12 +846,12 @@ plain `php-mode'. To get indentation to work you must use an
|
||||
Emacs library that supports 'multiple major modes' in a buffer.
|
||||
Parts of the buffer will then be in `php-mode' and parts in for
|
||||
example `html-mode'. Known such libraries are:\n\t"
|
||||
(mapconcat 'identity known-names ", ")
|
||||
(mapconcat #'identity known-names ", ")
|
||||
"\n"
|
||||
(if available-multi-libs
|
||||
(concat
|
||||
"You have these available in your `load-path':\n\t"
|
||||
(mapconcat 'identity available-names ", ")
|
||||
(mapconcat #'identity available-names ", ")
|
||||
"\n\n"
|
||||
"Do you want to turn any of those on? ")
|
||||
"You do not have any of those in your `load-path'.")))
|
||||
@@ -963,8 +947,8 @@ This is was done due to the problem reported here:
|
||||
(defun php-lineup-string-cont (langelem)
|
||||
"Line up string toward equal sign or dot.
|
||||
e.g.
|
||||
$str \= \'some\'
|
||||
. \'string\';
|
||||
$str = \\='some'
|
||||
. \\='string';
|
||||
this ^ lineup"
|
||||
(save-excursion
|
||||
(goto-char (cdr langelem))
|
||||
@@ -1014,20 +998,19 @@ HEREDOC-START."
|
||||
|
||||
(eval-and-compile
|
||||
(defconst php-syntax-propertize-rules
|
||||
`((php-heredoc-start-re
|
||||
(0 (ignore (php--syntax-propertize-heredoc
|
||||
(match-beginning 0)
|
||||
(or (match-string 1) (match-string 2) (match-string 3))
|
||||
(null (match-string 3))))))
|
||||
(,(rx "#[")
|
||||
(0 (ignore (php--syntax-propertize-attributes (match-beginning 0)))))
|
||||
(,(rx (or "'" "\"" ))
|
||||
(0 (ignore (php--syntax-propertize-quotes-in-comment (match-beginning 0)))))))
|
||||
(syntax-propertize-precompile-rules
|
||||
(php-heredoc-start-re
|
||||
(0 (ignore (php--syntax-propertize-heredoc
|
||||
(match-beginning 0)
|
||||
(or (match-string 1) (match-string 2) (match-string 3))
|
||||
(null (match-string 3))))))
|
||||
((rx "#[")
|
||||
(0 (ignore (php--syntax-propertize-attributes (match-beginning 0)))))
|
||||
((rx (or "'" "\""))
|
||||
(0 (ignore (php--syntax-propertize-quotes-in-comment (match-beginning 0))))))))
|
||||
|
||||
(defmacro php-build-propertize-function ()
|
||||
`(byte-compile (syntax-propertize-rules ,@php-syntax-propertize-rules)))
|
||||
|
||||
(defalias 'php-syntax-propertize-function (php-build-propertize-function)))
|
||||
(defalias 'php-syntax-propertize-function
|
||||
(syntax-propertize-rules php-syntax-propertize-rules))
|
||||
|
||||
(defun php--syntax-propertize-heredoc (start id _is-heredoc)
|
||||
"Apply propertize Heredoc and Nowdoc from START, with ID and IS-HEREDOC."
|
||||
@@ -1100,13 +1083,7 @@ Borrow the `interactive-form' from `c-set-style' and use the original
|
||||
`c-set-style' function to set all declared stylevars.
|
||||
For compatibility with `c-set-style' pass DONT-OVERRIDE to it.
|
||||
|
||||
After setting the stylevars run hooks according to STYLENAME
|
||||
|
||||
\"pear\" `php-mode-pear-hook'
|
||||
\"drupal\" `php-mode-drupal-hook'
|
||||
\"wordpress\" `php-mode-wordpress-hook'
|
||||
\"symfony2\" `php-mode-symfony2-hook'
|
||||
\"psr2\" `php-mode-psr2-hook'"
|
||||
After setting the stylevars run hook `php-mode-STYLENAME-hook'."
|
||||
(interactive
|
||||
(list (let ((completion-ignore-case t)
|
||||
(prompt (format "Which %s indentation style? "
|
||||
@@ -1130,15 +1107,10 @@ After setting the stylevars run hooks according to STYLENAME
|
||||
;; Restore variables
|
||||
(cl-loop for (name . value) in backup-vars
|
||||
do (set (make-local-variable name) value)))
|
||||
|
||||
(if (eq (symbol-value 'php-style-delete-trailing-whitespace) t)
|
||||
(add-hook 'before-save-hook 'delete-trailing-whitespace nil t)
|
||||
(remove-hook 'before-save-hook 'delete-trailing-whitespace t))
|
||||
(cond ((equal stylename "pear") (run-hooks 'php-mode-pear-hook))
|
||||
((equal stylename "drupal") (run-hooks 'php-mode-drupal-hook))
|
||||
((equal stylename "wordpress") (run-hooks 'php-mode-wordpress-hook))
|
||||
((equal stylename "symfony2") (run-hooks 'php-mode-symfony2-hook))
|
||||
((equal stylename "psr2") (run-hooks 'php-mode-psr2-hook))))
|
||||
(if (eq php-style-delete-trailing-whitespace t)
|
||||
(add-hook 'before-save-hook #'delete-trailing-whitespace nil t)
|
||||
(remove-hook 'before-save-hook #'delete-trailing-whitespace t))
|
||||
(run-hooks (intern (format "php-mode-%s-hook" stylename))))
|
||||
|
||||
(defun php-mode--disable-delay-set-style (&rest _args)
|
||||
"Disable `php-mode-set-style-delay' on after hook. ARGS be ignore."
|
||||
@@ -1163,8 +1135,7 @@ After setting the stylevars run hooks according to STYLENAME
|
||||
"Reset PHP-irrelevant variables set by Cc Mode initialization."
|
||||
(setq-local c-mode-hook nil)
|
||||
(setq-local java-mode-hook nil)
|
||||
(when (eval-when-compile (boundp 'flymake-diagnostic-functions))
|
||||
(remove-hook 'flymake-diagnostic-functions 'flymake-cc t))
|
||||
(remove-hook 'flymake-diagnostic-functions 'flymake-cc t)
|
||||
t)
|
||||
|
||||
(defvar php-mode-syntax-table
|
||||
@@ -1188,7 +1159,7 @@ After setting the stylevars run hooks according to STYLENAME
|
||||
;; (setq abbrev-mode t)
|
||||
|
||||
(unless (string= php-mode-cc-version c-version)
|
||||
(php-mode-debug-reinstall))
|
||||
(php-mode-debug-reinstall nil))
|
||||
|
||||
(if php-mode-disable-c-mode-hook
|
||||
(php-mode-neutralize-cc-mode-effect)
|
||||
@@ -1240,7 +1211,7 @@ After setting the stylevars run hooks according to STYLENAME
|
||||
(progn
|
||||
(add-hook 'hack-local-variables-hook #'php-mode-set-style-delay t t)
|
||||
(setq php-mode--delayed-set-style t)
|
||||
(advice-add #'c-set-style :after #'php-mode--disable-delay-set-style '(local)))
|
||||
(advice-add 'c-set-style :after #'php-mode--disable-delay-set-style))
|
||||
(let ((php-mode-enable-backup-style-variables nil))
|
||||
(php-set-style (symbol-name php-mode-coding-style))))
|
||||
|
||||
@@ -1250,8 +1221,8 @@ After setting the stylevars run hooks according to STYLENAME
|
||||
(string-match "\\.php\\'" buffer-file-name)))
|
||||
(php-set-style "pear"))
|
||||
|
||||
(setq indent-line-function 'php-cautious-indent-line)
|
||||
(setq indent-region-function 'php-cautious-indent-region)
|
||||
(setq indent-line-function #'php-cautious-indent-line)
|
||||
(setq indent-region-function #'php-cautious-indent-region)
|
||||
(setq c-at-vsemi-p-fn #'php-c-at-vsemi-p)
|
||||
(setq c-vsemi-status-unknown-p-fn #'php-c-vsemi-status-unknown-p)
|
||||
|
||||
@@ -1261,8 +1232,8 @@ After setting the stylevars run hooks according to STYLENAME
|
||||
;; following two local variables, but we keep them for now until we
|
||||
;; are completely sure their removal will not break any current
|
||||
;; behavior or backwards compatibility.
|
||||
(setq-local beginning-of-defun-function 'php-beginning-of-defun)
|
||||
(setq-local end-of-defun-function 'php-end-of-defun)
|
||||
(setq-local beginning-of-defun-function #'php-beginning-of-defun)
|
||||
(setq-local end-of-defun-function #'php-end-of-defun)
|
||||
|
||||
(setq-local open-paren-in-column-0-is-defun-start nil)
|
||||
(setq-local defun-prompt-regexp
|
||||
@@ -1274,15 +1245,12 @@ After setting the stylevars run hooks according to STYLENAME
|
||||
php-mode-replace-flymake-diag-function)
|
||||
(add-hook 'flymake-diagnostic-functions php-mode-replace-flymake-diag-function nil t))
|
||||
|
||||
(when (fboundp 'c-looking-at-or-maybe-in-bracelist)
|
||||
(advice-add #'c-looking-at-or-maybe-in-bracelist
|
||||
:override 'php-c-looking-at-or-maybe-in-bracelist '(local)))
|
||||
(advice-add #'fixup-whitespace :after #'php-mode--fixup-whitespace-after '(local))
|
||||
(advice-add 'c-looking-at-or-maybe-in-bracelist
|
||||
:around 'php-c-looking-at-or-maybe-in-bracelist)
|
||||
(advice-add 'fixup-whitespace :after #'php-mode--fixup-whitespace-after)
|
||||
|
||||
(when (fboundp #'acm-backend-tabnine-candidate-expand)
|
||||
(advice-add #'acm-backend-tabnine-candidate-expand
|
||||
:filter-args #'php-acm-backend-tabnine-candidate-expand-filter-args
|
||||
'(local)))
|
||||
(advice-add 'acm-backend-tabnine-candidate-expand
|
||||
:filter-args #'php-acm-backend-tabnine-candidate-expand-filter-args)
|
||||
|
||||
(when (>= emacs-major-version 25)
|
||||
(with-silent-modifications
|
||||
@@ -1301,6 +1269,16 @@ After setting the stylevars run hooks according to STYLENAME
|
||||
#'semantic-create-imenu-index)
|
||||
"Imenu index function for PHP.")
|
||||
|
||||
(when (bound-and-true-p consult-imenu-config)
|
||||
(add-to-list 'consult-imenu-config '(php-mode :toplevel "Namespace"
|
||||
:types ((?n "Namespace" font-lock-function-name-face)
|
||||
(?p "Properties" font-lock-type-face)
|
||||
(?o "Constants" font-lock-type-face)
|
||||
(?c "Classes" font-lock-type-face)
|
||||
(?f "Functions" font-lock-function-name-face)
|
||||
(?i "Imports" font-lock-type-face)
|
||||
(?m "Methods" font-lock-function-name-face)))))
|
||||
|
||||
(autoload 'php-local-manual-complete-function "php-local-manual")
|
||||
|
||||
(defun php-complete-function ()
|
||||
@@ -1371,8 +1349,6 @@ for \\[find-tag] (which see)."
|
||||
(regexp-opt php-phpdoc-type-names 'words)
|
||||
"\\)")
|
||||
1 font-lock-type-face prepend nil)
|
||||
("https?://[^\n\t ]+"
|
||||
0 'link prepend nil)
|
||||
("^\\(?:/\\*\\)?\\(?:\\s \\|\\*\\)*\\(@[[:alpha:]][-[:alpha:]\\]*\\)" ; "@foo ..." markup.
|
||||
1 'php-doc-annotation-tag prepend nil)))
|
||||
|
||||
@@ -1480,6 +1456,16 @@ for \\[find-tag] (which see)."
|
||||
;; is usually overkill.
|
||||
`(
|
||||
("\\<\\(@\\)" 1 'php-errorcontrol-op)
|
||||
;; import function statement
|
||||
(,(rx symbol-start (group "use" (+ (syntax whitespace)) "function")
|
||||
(+ (syntax whitespace)))
|
||||
(1 'php-import-declaration)
|
||||
(,(rx (group (+ (or (syntax word) (syntax symbol) "\\" "{" "}")))) nil nil (1 'php-function-name t)))
|
||||
;; import constant statement
|
||||
(,(rx symbol-start (group "use" (+ (syntax whitespace)) "const")
|
||||
(+ (syntax whitespace)))
|
||||
(1 'php-import-declaration)
|
||||
(,(rx (group (+ (or (syntax word) (syntax symbol) "\\" "{" "}")))) nil nil (1 'php-constant-assign t)))
|
||||
;; Highlight function calls
|
||||
("\\(\\_<\\(?:\\sw\\|\\s_\\)+?\\_>\\)\\s-*(" 1 'php-function-call)
|
||||
;; Highlight all upper-cased symbols as constant
|
||||
@@ -1582,22 +1568,25 @@ The output will appear in the buffer *PHP*."
|
||||
;;; logic of `fixup-whitespace'.
|
||||
(defun php-mode--fixup-whitespace-after ()
|
||||
"Remove whitespace before certain characters in PHP Mode."
|
||||
(when (or (looking-at-p " \\(?:;\\|,\\|->\\|::\\)")
|
||||
(save-excursion
|
||||
(forward-char -2)
|
||||
(looking-at-p "->\\|::")))
|
||||
(when (and (derived-mode-p 'php-mode)
|
||||
(or (looking-at-p " \\(?:;\\|,\\|->\\|::\\)")
|
||||
(save-excursion
|
||||
(forward-char -2)
|
||||
(looking-at-p "->\\|::"))))
|
||||
(delete-char 1)))
|
||||
|
||||
;; Advice for lsp-bridge' acm-backend-tabnine
|
||||
;; see https://github.com/manateelazycat/lsp-bridge/issues/402#issuecomment-1305653058
|
||||
(defun php-acm-backend-tabnine-candidate-expand-filter-args (args)
|
||||
"Adjust to replace bound-start ARGS for Tabnine in PHP."
|
||||
(cl-multiple-value-bind (candidate-info bound-start) args
|
||||
(save-excursion
|
||||
(goto-char bound-start)
|
||||
(when (looking-at-p (eval-when-compile (regexp-quote "$")))
|
||||
(setq bound-start (1+ bound-start))))
|
||||
(list candidate-info bound-start)))
|
||||
(if (not (derived-mode-p 'php-mode))
|
||||
args
|
||||
(cl-multiple-value-bind (candidate-info bound-start) args
|
||||
(save-excursion
|
||||
(goto-char bound-start)
|
||||
(when (looking-at-p (eval-when-compile (regexp-quote "$")))
|
||||
(setq bound-start (1+ bound-start))))
|
||||
(list candidate-info bound-start))))
|
||||
|
||||
;;;###autoload
|
||||
(progn
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
;;; php-project.el --- Project support for PHP application -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2022 Friends of Emacs-PHP development
|
||||
;; Copyright (C) 2023 Friends of Emacs-PHP development
|
||||
|
||||
;; Author: USAMI Kenta <tadsan@zonu.me>
|
||||
;; Keywords: tools, files
|
||||
;; URL: https://github.com/emacs-php/php-mode
|
||||
;; Version: 1.24.2
|
||||
;; Version: 1.25.0
|
||||
;; License: GPL-3.0-or-later
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
@@ -40,12 +40,6 @@
|
||||
;;
|
||||
;; Return path to PHP executable file with the project settings overriding.
|
||||
;;
|
||||
;; ### `php-project-get-phan-executable()'
|
||||
;;
|
||||
;; Return path to Phan executable file with the project settings overriding.
|
||||
;; Phan is a static analyzer and LSP server implementation for PHP.
|
||||
;; See https://github.com/phan/phan
|
||||
;;
|
||||
;; ## `.dir-locals.el' support
|
||||
;;
|
||||
;; - `php-project-coding-style'
|
||||
@@ -59,10 +53,6 @@
|
||||
;; - `php-project-php-executable'
|
||||
;; - Path to project specific PHP executable file.
|
||||
;; - If you want to use a file different from the system wide `php' command.
|
||||
;; - `php-project-phan-executable'
|
||||
;; - Path to project specific Phan executable file.
|
||||
;; - When not specified explicitly, it is automatically searched from
|
||||
;; Composer's dependency of the project and `exec-path'.
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
@@ -142,10 +132,6 @@ defines constants, and sets the class loaders.")
|
||||
(put 'php-project-php-executable 'safe-local-variable
|
||||
#'(lambda (v) (and (stringp v) (file-executable-p v))))
|
||||
|
||||
(defvar-local php-project-phan-executable nil
|
||||
"Path to phan executable file.")
|
||||
(put 'php-project-phan-executable 'safe-local-variable #'php-project--eval-bootstrap-scripts)
|
||||
|
||||
(defvar-local php-project-coding-style nil
|
||||
"Symbol value of the coding style of the project that PHP major mode refers to.
|
||||
|
||||
@@ -240,13 +226,6 @@ Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.")
|
||||
((boundp 'php-executable) php-executable)
|
||||
(t (executable-find "php"))))
|
||||
|
||||
(defun php-project-get-phan-executable ()
|
||||
"Return path to phan executable file."
|
||||
(or (car-safe (php-project--eval-bootstrap-scripts
|
||||
(list php-project-phan-executable
|
||||
(cons 'root "vendor/bin/phan"))))
|
||||
(executable-find "phan")))
|
||||
|
||||
(defun php-project-get-file-html-template-type (filename)
|
||||
"Return symbol T, NIL or `auto' by `FILENAME'."
|
||||
(cond
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
;;; php.el --- PHP support for friends -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2022 Friends of Emacs-PHP development
|
||||
;; Copyright (C) 2023 Friends of Emacs-PHP development
|
||||
;; Copyright (C) 1985, 1987, 1992-2022 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: USAMI Kenta <tadsan@zonu.me>
|
||||
;; Created: 5 Dec 2018
|
||||
;; Version: 1.24.2
|
||||
;; Version: 1.25.0
|
||||
;; Keywords: languages, php
|
||||
;; Homepage: https://github.com/emacs-php/php-mode
|
||||
;; License: GPL-3.0-or-later
|
||||
@@ -206,7 +206,8 @@ a completion list."
|
||||
|
||||
;;; PHP Keywords
|
||||
(defconst php-magical-constants
|
||||
(list "__LINE__" "__FILE__" "__FUNCTION__" "__CLASS__" "__TRAIT__" "__METHOD__" "__NAMESPACE__")
|
||||
'("__CLASS__" "__DIR__" "__FILE__" "__FUNCTION__" "__LINE__"
|
||||
"__METHOD__" "__NAMESPACE__" "__TRAIT__")
|
||||
"Magical keyword that is expanded at compile time.
|
||||
|
||||
These are different from \"constants\" in strict terms.
|
||||
@@ -261,12 +262,12 @@ an integer (the current comment nesting)."
|
||||
"Make a regular expression for methods with the given VISIBILITY.
|
||||
|
||||
VISIBILITY must be a string that names the visibility for a PHP
|
||||
method, e.g. \'public\'. The parameter VISIBILITY can itself also
|
||||
method, e.g. `public'. The parameter VISIBILITY can itself also
|
||||
be a regular expression.
|
||||
|
||||
The regular expression this function returns will check for other
|
||||
keywords that can appear in method signatures, e.g. \'final\' and
|
||||
\'static\'. The regular expression will have one capture group
|
||||
keywords that can appear in method signatures, e.g. `final' and
|
||||
`static'. The regular expression will have one capture group
|
||||
which will be the name of the method."
|
||||
(when (stringp visibility)
|
||||
(setq visibility (list visibility)))
|
||||
@@ -293,8 +294,8 @@ which will be the name of the method."
|
||||
'((* any) line-end))))))
|
||||
|
||||
(defun php-create-regexp-for-classlike (type)
|
||||
"Accepts a `TYPE' of a \'classlike\' object as a string, such as
|
||||
\'class\' or \'interface\', and returns a regexp as a string which
|
||||
"Accepts a `TYPE' of a `classlike' object as a string, such as
|
||||
`class' or `interface', and returns a regexp as a string which
|
||||
can be used to match against definitions for that classlike."
|
||||
(concat
|
||||
;; First see if 'abstract' or 'final' appear, although really these
|
||||
|
||||
Reference in New Issue
Block a user