From 239b5577f9076c9089a03c5743c5b7b2c180a036 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 2 Jan 2023 02:31:59 +0900 Subject: [PATCH 001/125] Remove 'link face to http addresses in PHPDoc --- lisp/php-mode.el | 2 -- tests/7.4/arrow-function.php.faces | 8 ++------ tests/issue-136.php.faces | 4 +--- tests/issue-197.php.faces | 4 +--- tests/issue-201.php.faces | 4 +--- tests/issue-305.php.faces | 4 +--- tests/issue-439.php.faces | 4 +--- tests/issue-443.php.27.faces | 4 +--- tests/issue-443.php.faces | 4 +--- tests/lang/doc-comment/comments.php.24.faces | 4 +--- tests/lang/doc-comment/comments.php.27.faces | 4 +--- tests/lang/doc-comment/comments.php.faces | 4 +--- tests/lang/doc-comment/issue-8.php.faces | 4 +--- tests/lang/doc-comment/return-type.php.faces | 4 +--- 14 files changed, 14 insertions(+), 44 deletions(-) diff --git a/lisp/php-mode.el b/lisp/php-mode.el index b6130ded..d55b8653 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -1371,8 +1371,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))) diff --git a/tests/7.4/arrow-function.php.faces b/tests/7.4/arrow-function.php.faces index acfcbc5d..a944ea2c 100644 --- a/tests/7.4/arrow-function.php.faces +++ b/tests/7.4/arrow-function.php.faces @@ -1,13 +1,9 @@ ;; -*- mode: emacs-lisp -*- (("\n * " . font-lock-doc-face) ("@link" php-doc-annotation-tag font-lock-doc-face) - (" " . font-lock-doc-face) - ("https://github.com/emacs-php/php-mode" link font-lock-doc-face) - ("\n * " . font-lock-doc-face) + (" https://github.com/emacs-php/php-mode\n * " . font-lock-doc-face) ("@package" php-doc-annotation-tag font-lock-doc-face) (" " . font-lock-doc-face) ("Emacs\\PHPMode" php-string font-lock-doc-face) diff --git a/tests/issue-197.php.faces b/tests/issue-197.php.faces index cd223c5b..94f2abef 100644 --- a/tests/issue-197.php.faces +++ b/tests/issue-197.php.faces @@ -1,9 +1,7 @@ ;; -*- mode: emacs-lisp -*- (("" . php-php-tag) ("\n") - ("/** GitHub Issue: " . font-lock-doc-face) - ("https://github.com/emacs-php/php-mode/issues/443" link font-lock-doc-face) - (" */" . font-lock-doc-face) + ("/** GitHub Issue: https://github.com/emacs-php/php-mode/issues/443 */" . font-lock-doc-face) ("\n") ("" . php-php-tag) ("\n") - ("/** GitHub Issue: " . font-lock-doc-face) - ("https://github.com/emacs-php/php-mode/issues/443" link font-lock-doc-face) - (" */" . font-lock-doc-face) + ("/** GitHub Issue: https://github.com/emacs-php/php-mode/issues/443 */" . font-lock-doc-face) ("\n") ("\n * " . font-lock-doc-face) ("@link" php-doc-annotation-tag font-lock-doc-face) - (" " . font-lock-doc-face) - ("https://github.com/emacs-php/php-mode" link font-lock-doc-face) - ("\n * " . font-lock-doc-face) + (" https://github.com/emacs-php/php-mode\n * " . font-lock-doc-face) ("@package" php-doc-annotation-tag font-lock-doc-face) (" " . font-lock-doc-face) ("Emacs\\PHPMode" php-string font-lock-doc-face) diff --git a/tests/lang/doc-comment/comments.php.27.faces b/tests/lang/doc-comment/comments.php.27.faces index e48028c8..b659a0ab 100644 --- a/tests/lang/doc-comment/comments.php.27.faces +++ b/tests/lang/doc-comment/comments.php.27.faces @@ -11,9 +11,7 @@ ("@author" php-doc-annotation-tag font-lock-doc-face) (" USAMI Kenta \n * " . font-lock-doc-face) ("@link" php-doc-annotation-tag font-lock-doc-face) - (" " . font-lock-doc-face) - ("https://github.com/emacs-php/php-mode" link font-lock-doc-face) - ("\n * " . font-lock-doc-face) + (" https://github.com/emacs-php/php-mode\n * " . font-lock-doc-face) ("@package" php-doc-annotation-tag font-lock-doc-face) (" " . font-lock-doc-face) ("Emacs\\PHPMode" php-string font-lock-doc-face) diff --git a/tests/lang/doc-comment/comments.php.faces b/tests/lang/doc-comment/comments.php.faces index e6748c07..c8491911 100644 --- a/tests/lang/doc-comment/comments.php.faces +++ b/tests/lang/doc-comment/comments.php.faces @@ -11,9 +11,7 @@ ("@author" php-doc-annotation-tag font-lock-doc-face) (" USAMI Kenta \n * " . font-lock-doc-face) ("@link" php-doc-annotation-tag font-lock-doc-face) - (" " . font-lock-doc-face) - ("https://github.com/emacs-php/php-mode" link font-lock-doc-face) - ("\n * " . font-lock-doc-face) + (" https://github.com/emacs-php/php-mode\n * " . font-lock-doc-face) ("@package" php-doc-annotation-tag font-lock-doc-face) (" " . font-lock-doc-face) ("Emacs\\PHPMode" php-string font-lock-doc-face) diff --git a/tests/lang/doc-comment/issue-8.php.faces b/tests/lang/doc-comment/issue-8.php.faces index 82ce4723..5a107591 100644 --- a/tests/lang/doc-comment/issue-8.php.faces +++ b/tests/lang/doc-comment/issue-8.php.faces @@ -1,9 +1,7 @@ ;; -*- mode: emacs-lisp -*- ((" Date: Mon, 2 Jan 2023 02:36:21 +0900 Subject: [PATCH 002/125] GitHub Actions: use Python 3.11 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6432169b..812bb683 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,7 +28,7 @@ jobs: steps: - uses: actions/setup-python@v2 with: - python-version: '3.6' + python-version: '3.11' architecture: 'x64' - uses: purcell/setup-emacs@master with: From 41acf76a2779cbdc4f46bf31fae198424d7f380c Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 2 Jan 2023 02:51:17 +0900 Subject: [PATCH 003/125] Update CHANGELOG --- CHANGELOG.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46645760..c2856de8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,14 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles. - +## Unreleased + +### Removed + + * No longer highlights `'link` in PHPDoc ([#724]) + * Please use `goto-address-prog-mode` minor mode + +[#724]: https://github.com/emacs-php/php-mode/pull/724 ## [1.24.2] - 2022-11-13 From cf9481ccb7fbd50847e5a8c1da37f68771c2532e Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Tue, 3 Jan 2023 21:26:02 +0900 Subject: [PATCH 004/125] Update copyright notation --- README.ja.md | 2 +- lisp/php-align.el | 2 +- lisp/php-complete.el | 2 +- lisp/php-defs.el | 2 +- lisp/php-face.el | 2 +- lisp/php-flymake.el | 2 +- lisp/php-local-manual.el | 2 +- lisp/php-mode-debug.el | 2 +- lisp/php-mode.el | 2 +- lisp/php-project.el | 2 +- lisp/php.el | 2 +- script/data/module_id_prefixes.php | 2 +- script/extract_functions.php | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.ja.md b/README.ja.md index ee1fcf0f..783eb3f2 100644 --- a/README.ja.md +++ b/README.ja.md @@ -310,7 +310,7 @@ PHP Modeは[GNU General Public License Version 3][gpl-v3] (GPLv3) でライセ このプロジェクトは2017年まで[Eric James Michael Ritz][@ejmr]によりメンテナンスされていました。現在は[Friends of Emacs-PHP Development][@emacs-php]コミュニティが引き継いで開発しています。 > ``` -> 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 diff --git a/lisp/php-align.el b/lisp/php-align.el index 6a326cd1..b1ea3bf4 100644 --- a/lisp/php-align.el +++ b/lisp/php-align.el @@ -1,7 +1,7 @@ ;;; 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) ;; Maintainer: USAMI Kenta diff --git a/lisp/php-complete.el b/lisp/php-complete.el index 00c8fdc9..e289943a 100644 --- a/lisp/php-complete.el +++ b/lisp/php-complete.el @@ -1,6 +1,6 @@ ;;; 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 diff --git a/lisp/php-defs.el b/lisp/php-defs.el index 3756fce7..fc9e59c8 100644 --- a/lisp/php-defs.el +++ b/lisp/php-defs.el @@ -1,6 +1,6 @@ ;;; 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 ;; Created: 5 Mar 2022 diff --git a/lisp/php-face.el b/lisp/php-face.el index ccbf416b..6fade240 100644 --- a/lisp/php-face.el +++ b/lisp/php-face.el @@ -1,6 +1,6 @@ ;;; 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 ;; Created: 5 May 2019 diff --git a/lisp/php-flymake.el b/lisp/php-flymake.el index 74198678..822336e5 100644 --- a/lisp/php-flymake.el +++ b/lisp/php-flymake.el @@ -1,6 +1,6 @@ ;;; 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 ;; Created: 5 Mar 2022 diff --git a/lisp/php-local-manual.el b/lisp/php-local-manual.el index dda26c5d..ba4f854e 100644 --- a/lisp/php-local-manual.el +++ b/lisp/php-local-manual.el @@ -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 diff --git a/lisp/php-mode-debug.el b/lisp/php-mode-debug.el index 31fd98d5..9c69e205 100644 --- a/lisp/php-mode-debug.el +++ b/lisp/php-mode-debug.el @@ -1,6 +1,6 @@ ;;; 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 ;; URL: https://github.com/emacs-php/php-mode diff --git a/lisp/php-mode.el b/lisp/php-mode.el index d55b8653..179d5c90 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -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 diff --git a/lisp/php-project.el b/lisp/php-project.el index 5154e7f3..f862a672 100644 --- a/lisp/php-project.el +++ b/lisp/php-project.el @@ -1,6 +1,6 @@ ;;; 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 ;; Keywords: tools, files diff --git a/lisp/php.el b/lisp/php.el index 3cf942f8..3bff893b 100644 --- a/lisp/php.el +++ b/lisp/php.el @@ -1,6 +1,6 @@ ;;; 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 diff --git a/script/data/module_id_prefixes.php b/script/data/module_id_prefixes.php index cef2a14a..bd379958 100644 --- a/script/data/module_id_prefixes.php +++ b/script/data/module_id_prefixes.php @@ -3,7 +3,7 @@ /** * Classify function modules by function-id * - * @copyright 2022 Friends of Emacs-PHP development + * @copyright 2023 Friends of Emacs-PHP development * @author USAMI Kenta * @license FSFAP https://spdx.org/licenses/FSFAP.html */ diff --git a/script/extract_functions.php b/script/extract_functions.php index d61a9a2a..791c19f7 100755 --- a/script/extract_functions.php +++ b/script/extract_functions.php @@ -4,7 +4,7 @@ /** * Extract PHP Functions * - * @copyright 2022 Friends of Emacs-PHP development + * @copyright 2023 Friends of Emacs-PHP development * @author USAMI Kenta * @license FSFAP https://spdx.org/licenses/FSFAP.html */ From d0949f1c17d1e72de1ac44ac72535c374ebf9e5a Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sun, 12 Feb 2023 02:10:36 +0900 Subject: [PATCH 005/125] Add "use function" and "use const" to font-lock-keyword --- lisp/php-mode.el | 10 ++++++ tests/lang/import/import-constant.php | 8 +++++ tests/lang/import/import-constant.php.faces | 31 +++++++++++++++++ tests/lang/import/import-function.php | 7 ++++ tests/lang/import/import-function.php.faces | 37 +++++++++++++++++++++ tests/php-mode-test.el | 2 ++ 6 files changed, 95 insertions(+) create mode 100644 tests/lang/import/import-constant.php create mode 100644 tests/lang/import/import-constant.php.faces create mode 100644 tests/lang/import/import-function.php create mode 100644 tests/lang/import/import-function.php.faces diff --git a/lisp/php-mode.el b/lisp/php-mode.el index 179d5c90..407745b3 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -1396,6 +1396,11 @@ for \\[find-tag] (which see)." ("\\_<\\(?:implements\\|extends\\)\\_>" . 'php-class-declaration-spec) ;; Namespace declaration ("\\_" . 'php-namespace-declaration) + ;; 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))) ;; import statement ("\\_" . 'php-import-declaration) ;; Class modifiers (abstract, final) @@ -1478,6 +1483,11 @@ 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))) ;; Highlight function calls ("\\(\\_<\\(?:\\sw\\|\\s_\\)+?\\_>\\)\\s-*(" 1 'php-function-call) ;; Highlight all upper-cased symbols as constant diff --git a/tests/lang/import/import-constant.php b/tests/lang/import/import-constant.php new file mode 100644 index 00000000..791e241a --- /dev/null +++ b/tests/lang/import/import-constant.php @@ -0,0 +1,8 @@ + Date: Sun, 12 Feb 2023 16:26:38 +0900 Subject: [PATCH 006/125] Fix "use const" font-lock --- lisp/php-face.el | 2 +- lisp/php-mode.el | 14 ++++++------- tests/lang/doc-comment/comments.php.27.faces | 2 +- tests/lang/doc-comment/comments.php.faces | 2 +- tests/lang/import/import-constant.php.faces | 22 ++++++++++++-------- 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/lisp/php-face.el b/lisp/php-face.el index 6fade240..1106035c 100644 --- a/lisp/php-face.el +++ b/lisp/php-face.el @@ -145,7 +145,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") diff --git a/lisp/php-mode.el b/lisp/php-mode.el index 407745b3..319e1d2a 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -496,10 +496,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." @@ -1396,11 +1396,6 @@ for \\[find-tag] (which see)." ("\\_<\\(?:implements\\|extends\\)\\_>" . 'php-class-declaration-spec) ;; Namespace declaration ("\\_" . 'php-namespace-declaration) - ;; 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))) ;; import statement ("\\_" . 'php-import-declaration) ;; Class modifiers (abstract, final) @@ -1488,6 +1483,11 @@ for \\[find-tag] (which see)." (+ (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 diff --git a/tests/lang/doc-comment/comments.php.27.faces b/tests/lang/doc-comment/comments.php.27.faces index b659a0ab..8b3b78e5 100644 --- a/tests/lang/doc-comment/comments.php.27.faces +++ b/tests/lang/doc-comment/comments.php.27.faces @@ -71,7 +71,7 @@ ("\n ") ("const" . php-keyword) (" ") - ("SAMPLE" . font-lock-type-face) + ("SAMPLE" . php-constant-assign) (" ") ("=" . php-assignment-op) (" ") diff --git a/tests/lang/doc-comment/comments.php.faces b/tests/lang/doc-comment/comments.php.faces index c8491911..593bb49e 100644 --- a/tests/lang/doc-comment/comments.php.faces +++ b/tests/lang/doc-comment/comments.php.faces @@ -70,7 +70,7 @@ ("\n ") ("const" . php-keyword) (" ") - ("SAMPLE" . font-lock-type-face) + ("SAMPLE" . php-constant-assign) (" ") ("=" . php-assignment-op) (" ") diff --git a/tests/lang/import/import-constant.php.faces b/tests/lang/import/import-constant.php.faces index bef6797e..015e7494 100644 --- a/tests/lang/import/import-constant.php.faces +++ b/tests/lang/import/import-constant.php.faces @@ -5,25 +5,29 @@ (" ") ("Foo" . font-lock-type-face) (";\n\n") - ("use const" . php-import-declaration) + ("use" . php-import-declaration) (" ") - ("Foo\\" . php-constant-assign) - ("BAR" . font-lock-type-face) + ("const" . php-keyword) + (" ") + ("Foo\\BAR" . php-constant-assign) (";\n") - ("use const" . php-import-declaration) + ("use" . php-import-declaration) (" ") - ("Foo" . font-lock-type-face) - ("\\{BUZ" . php-constant-assign) + ("const" . php-keyword) + (" ") + ("Foo\\{BUZ" . php-constant-assign) (", ") ("BUZBUZ}" . php-constant-assign) (";\n") - ("use const" . php-import-declaration) + ("use" . php-import-declaration) + (" ") + ("const" . php-keyword) (" ") - ("PHP_VERSION" . font-lock-type-face) + ("PHP_VERSION" . php-constant-assign) (";\n\n") ("const" . php-keyword) (" ") - ("FOO" . font-lock-type-face) + ("FOO" . php-constant-assign) (" ") ("=" . php-assignment-op) (" ") From 558ec40668c48b9895d4c3e4b366db5db1ce36e8 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 6 Mar 2023 05:12:41 +0900 Subject: [PATCH 007/125] Add php-format.el --- CHANGELOG.md | 7 ++ Cask | 1 + Makefile | 1 + lisp/php-format.el | 228 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 237 insertions(+) create mode 100644 lisp/php-format.el diff --git a/CHANGELOG.md b/CHANGELOG.md index c2856de8..0fa4eb4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,19 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this ## Unreleased +### Added + + * **Net feature**: `php-format` ([#730]) + * Add `php-format-project` and `php-format-this-buffer-file` commands + * Add `php-format-auto-mode` minor mode + ### Removed * No longer highlights `'link` in PHPDoc ([#724]) * Please use `goto-address-prog-mode` minor mode [#724]: https://github.com/emacs-php/php-mode/pull/724 +[#730]: https://github.com/emacs-php/php-mode/pull/730 ## [1.24.2] - 2022-11-13 diff --git a/Cask b/Cask index ccc9b3d2..1d85fe49 100644 --- a/Cask +++ b/Cask @@ -8,6 +8,7 @@ "lisp/php-complete.el" "lisp/php-defs.el" "lisp/php-face.el" + "lisp/php-format.el" "lisp/php-project.el" "lisp/php-local-manual.el" "lisp/php-mode-debug.el") diff --git a/Makefile b/Makefile index 2d725b0a..12aadcda 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ ELS += lisp/php-complete.el ELS += lisp/php-defs.el ELS += lisp/php-face.el ELS += lisp/php-flymake.el +ELS += lisp/php-format.el ELS += lisp/php-local-manual.el ELS += lisp/php-mode-debug.el ELS += lisp/php-mode.el diff --git a/lisp/php-format.el b/lisp/php-format.el new file mode 100644 index 00000000..b213744a --- /dev/null +++ b/lisp/php-format.el @@ -0,0 +1,228 @@ +;;; php-format.el --- Code reformatter for PHP buffer -*- lexical-binding: t; -*- + +;; Copyright (C) 2020 Friends of Emacs-PHP development + +;; Author: USAMI Kenta +;; 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 . + +;;; 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 nil :tag "Disabled reformat codes") + (const 'auto :tag "Auto") + (const 'ecs :tag "Easy Coding Standard") + (const 'php-cs-fixer :tag "PHP-CS-Fixer") + (const 'phpcbf :tag "PHP Code Beautifier and Fixer") + (repeat string :tag "Command and arguments")) + :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) + +;; Internal functions +(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))))) + +(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--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)) + (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 From a51ff293d86162506d27553af7117119491497b3 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 6 Mar 2023 06:13:10 +0900 Subject: [PATCH 008/125] Fix defsubst position --- lisp/php-format.el | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lisp/php-format.el b/lisp/php-format.el index b213744a..3aafc278 100644 --- a/lisp/php-format.el +++ b/lisp/php-format.el @@ -130,6 +130,13 @@ :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)) @@ -143,19 +150,12 @@ (`(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 "&")))) + (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))))) -(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--get-command-args () "Return a list of command and arguments." (if (listp php-format-command) From 31220ab874be6faa796a2072c64a903e4f86854d Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 6 Mar 2023 06:14:28 +0900 Subject: [PATCH 009/125] Fix #726 indentation --- CHANGELOG.md | 10 ++++++++-- lisp/php-mode.el | 3 ++- tests/indent/issue-726.php | 13 +++++++++++++ tests/php-mode-test.el | 3 ++- 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 tests/indent/issue-726.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fa4eb4c..de0f8d11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,17 +6,23 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this ### Added - * **Net feature**: `php-format` ([#730]) + * **Net feature**: `php-format` ([#731]) * Add `php-format-project` and `php-format-this-buffer-file` commands * Add `php-format-auto-mode` minor mode +### Fixed + + * Fix array indentation broken by commenting out ([#726], [#732]) + ### Removed * No longer highlights `'link` in PHPDoc ([#724]) * Please use `goto-address-prog-mode` minor mode [#724]: https://github.com/emacs-php/php-mode/pull/724 -[#730]: https://github.com/emacs-php/php-mode/pull/730 +[#726]: https://github.com/emacs-php/php-mode/pull/726 +[#731]: https://github.com/emacs-php/php-mode/pull/731 +[#732]: https://github.com/emacs-php/php-mode/pull/732 ## [1.24.2] - 2022-11-13 diff --git a/lisp/php-mode.el b/lisp/php-mode.el index 319e1d2a..012f21ee 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -663,6 +663,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 +673,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 ",")) diff --git a/tests/indent/issue-726.php b/tests/indent/issue-726.php new file mode 100644 index 00000000..b48c6f04 --- /dev/null +++ b/tests/indent/issue-726.php @@ -0,0 +1,13 @@ + [ + 'bee' => 2, + ], + // 'foo' => [ + // 'bar' => 1, + // ], + // ###php-mode-test### ((indent 4)) + 'lee' => 2, + // 'dee' => 3 + 'gee' => 4, // ###php-mode-test### ((indent 4)) +]; // ###php-mode-test### ((indent 0)) diff --git a/tests/php-mode-test.el b/tests/php-mode-test.el index 79db0b8a..0dae822e 100644 --- a/tests/php-mode-test.el +++ b/tests/php-mode-test.el @@ -652,7 +652,8 @@ Meant for `php-mode-test-issue-503'." (ert-deftest php-mode-test-issue-702 () "Proper alignment arglist." - (with-php-mode-test ("indent/issue-702.php" :indent t :magic t))) + (with-php-mode-test ("indent/issue-702.php" :indent t :magic t)) + (with-php-mode-test ("indent/issue-726.php" :indent t :magic t))) (ert-deftest php-mode-test-php74 () "Test highlighting language constructs added in PHP 7.4." From e6e4ac5943eda648a68c7d1b3d2d996acd918518 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Tue, 7 Mar 2023 00:44:35 +0900 Subject: [PATCH 010/125] Update version badges --- .github/workflows/test.yml | 1 + README.ja.md | 4 ++-- README.md | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 812bb683..e9467d27 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,6 +21,7 @@ jobs: - "27.1" - "27.2" - "28.1" + - "28.2" - snapshot include: - emacs_version: snapshot diff --git a/README.ja.md b/README.ja.md index 783eb3f2..b97f06b8 100644 --- a/README.ja.md +++ b/README.ja.md @@ -1,8 +1,8 @@

Emacs PHP Mode

-[![Emacs: 28.1](https://img.shields.io/badge/Emacs-28.1-blue.svg)](https://www.gnu.org/software/emacs/) -[![lang: PHP 8.1](https://img.shields.io/badge/lang-PHP%208.1-brightgreen.svg)](https://php.net/manual/migration81.php) +[![Emacs: 28.2](https://img.shields.io/badge/Emacs-28.2-blue.svg)](https://www.gnu.org/software/emacs/) +[![lang: PHP 8.2](https://img.shields.io/badge/lang-PHP%208.2-brightgreen.svg)](https://php.net/manual/migration82.php) [![lang: PHP 7](https://img.shields.io/badge/lang-PHP%207-green.svg)](https://php.net/downloads.php) [![Build Status](https://github.com/emacs-php/php-mode/workflows/CI/badge.svg)](https://github.com/emacs-php/php-mode/actions) [![GPL v3](https://img.shields.io/badge/license-GPL_v3-green.svg)](http://www.gnu.org/licenses/gpl-3.0.txt)
diff --git a/README.md b/README.md index 54248ed4..8b94717a 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@

Emacs PHP Mode

-[![Emacs: 28.1](https://img.shields.io/badge/Emacs-28.1-blue.svg)](https://www.gnu.org/software/emacs/) -[![lang: PHP 8.1](https://img.shields.io/badge/lang-PHP%208.1-brightgreen.svg)](https://php.net/manual/migration81.php) +[![Emacs: 28.2](https://img.shields.io/badge/Emacs-28.2-blue.svg)](https://www.gnu.org/software/emacs/) +[![lang: PHP 8.2](https://img.shields.io/badge/lang-PHP%208.2-brightgreen.svg)](https://php.net/manual/migration82.php) [![lang: PHP 7](https://img.shields.io/badge/lang-PHP%207-green.svg)](https://php.net/downloads.php) [![Build Status](https://github.com/emacs-php/php-mode/workflows/CI/badge.svg)](https://github.com/emacs-php/php-mode/actions) [![GPL v3](https://img.shields.io/badge/license-GPL_v3-green.svg)](http://www.gnu.org/licenses/gpl-3.0.txt)
From 77083924b121c436ae3fa0c5183b54b92a605df2 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Wed, 8 Mar 2023 21:59:31 +0900 Subject: [PATCH 011/125] Add php-format-disable-async-format-buffer-has-modified --- lisp/php-format.el | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lisp/php-format.el b/lisp/php-format.el index 3aafc278..f3a78869 100644 --- a/lisp/php-format.el +++ b/lisp/php-format.el @@ -128,6 +128,12 @@ :type '(alist :key-type function :value-type symbol) :group 'php-format) + +(defcustom php-format-disable-async-format-buffer-has-modified t + "When non-NIL, disable asynchronous formatting if the buffer has modified (not saved)." + :tag "PHP Format Disable Async Format Buffer Has Modified" + :type 'boolean + :group 'php-format) ;; Internal functions (defsubst php-format--register-timer (sec command-args) @@ -182,8 +188,10 @@ "Asynchronously execute PHP format with COMMAND-ARGS in DIR." (setq php-format--idle-timer nil) (let ((default-directory dir)) - (apply #'call-process-shell-command (car command-args) nil nil nil - (append (cdr command-args) (list "&"))))) + (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 From 5d3e9462a252d6ef306894cb0ee7d886a84f267a Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sun, 19 Mar 2023 06:06:03 +0900 Subject: [PATCH 012/125] Fix doc comment --- lisp/php-format.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/php-format.el b/lisp/php-format.el index f3a78869..166975ff 100644 --- a/lisp/php-format.el +++ b/lisp/php-format.el @@ -130,7 +130,7 @@ :group 'php-format) (defcustom php-format-disable-async-format-buffer-has-modified t - "When non-NIL, disable asynchronous formatting if the buffer has modified (not saved)." + "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) From 67d818928af5b5748021f26ebc0ea1d02420e932 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Tue, 11 Oct 2022 01:15:28 +0900 Subject: [PATCH 013/125] Add php-ide-phpactor.el --- Cask | 2 + Makefile | 1 + lisp/php-ide-phpactor.el | 127 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 lisp/php-ide-phpactor.el diff --git a/Cask b/Cask index 1d85fe49..b0e67ed7 100644 --- a/Cask +++ b/Cask @@ -11,9 +11,11 @@ "lisp/php-format.el" "lisp/php-project.el" "lisp/php-local-manual.el" + "lisp/php-ide-phpactor.el" "lisp/php-mode-debug.el") (development + (depends-on "phpactor") (depends-on "pkg-info") (depends-on "projectile") (depends-on "smart-jump") diff --git a/Makefile b/Makefile index 12aadcda..dc60f900 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ ELS += lisp/php-defs.el ELS += lisp/php-face.el ELS += lisp/php-flymake.el ELS += lisp/php-format.el +ELS += lisp/php-ide-phpactor.el ELS += lisp/php-local-manual.el ELS += lisp/php-mode-debug.el ELS += lisp/php-mode.el diff --git a/lisp/php-ide-phpactor.el b/lisp/php-ide-phpactor.el new file mode 100644 index 00000000..3f73c80e --- /dev/null +++ b/lisp/php-ide-phpactor.el @@ -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 +;; Keywords: tools, files +;; URL: https://github.com/emacs-php/php-mode +;; Version: 1.24.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 . + +;;; Commentary: + +;; PHP-IDE implementation to integrate Phpactor (phpactor.el). +;; This feature depends on . + +;;; 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 From acde9abad2777b9893a062ebc178313b0fb4b2cb Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Tue, 11 Oct 2022 01:58:36 +0900 Subject: [PATCH 014/125] Add php-eglot.el --- Cask | 1 + Makefile | 1 + lisp/php-eglot.el | 116 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 118 insertions(+) create mode 100644 lisp/php-eglot.el diff --git a/Cask b/Cask index b0e67ed7..e090d524 100644 --- a/Cask +++ b/Cask @@ -7,6 +7,7 @@ "lisp/php.el" "lisp/php-complete.el" "lisp/php-defs.el" + "lisp/php-eglot.el" "lisp/php-face.el" "lisp/php-format.el" "lisp/php-project.el" diff --git a/Makefile b/Makefile index dc60f900..c2fc9ffe 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ ELS = lisp/php.el ELS += lisp/php-align.el ELS += lisp/php-complete.el ELS += lisp/php-defs.el +ELS += lisp/php-eglot.el ELS += lisp/php-face.el ELS += lisp/php-flymake.el ELS += lisp/php-format.el diff --git a/lisp/php-eglot.el b/lisp/php-eglot.el new file mode 100644 index 00000000..6a7875f3 --- /dev/null +++ b/lisp/php-eglot.el @@ -0,0 +1,116 @@ +;;; php-eglot.el --- Eglot enhancement for PHP development -*- lexical-binding: t; -*- + +;; Copyright (C) 2023 Friends of Emacs-PHP development + +;; Author: USAMI Kenta +;; Keywords: tools, files +;; URL: https://github.com/emacs-php/php-mode +;; Version: 1.24.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 . + +;;; Commentary: + +;; PHP Mode integrates Eglot . +;; +;; **Note**: +;; This feature is under development and experimental. +;; All of these functions, modes and terms are subject to change without notice. +;; +;; ## Configuration +;; +;; Put follows code into your .emacs (~/.emacs.d/init.el) file: +;; +;; (add-to-list 'eglot-server-programs ((php-mode phps-mode) . php-eglot-server-program)) +;; +;; ### For per project configuration +;; +;; Put follows code into .dir-locals.el in project directory: +;; +;; ((nil (php-project-root . git) +;; (php-eglot-executable . ("psalm-language-server")) +;; ;; or (php-eglot-executable . ("php" "vendor/bin/path/to/server")) +;; )) +;; +;; 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) +(require 'eglot nil t) +(require 'phpactor nil t) + +(eval-when-compile + (defvar eglot-server-programs) + (defvar eglot--managed-mode) + (declare-function eglot-ensure "ext:eglot" ()) + (declare-function phpactor--find-executable "ext:phpactor" ())) + +(defvar php-eglot-lsp-command-alist + '((intelephense "intelephense" "--stdio") + (phpactor . (lambda () (list (if (require 'phpactor nil t) + (phpactor--find-executable) + "phpactor")))))) + +(defgroup php-eglot nil + "Eglot PHP integration." + :tag "PHP-Eglot" + :prefix "php-eglot-" + :group 'eglot + :group 'php) + +;;;###autoload +(defcustom php-eglot-executable nil + "Command name or path to the command of Eglot LSP executable." + :tag "Php-Eglot Executable" + :group 'php-eglot + :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-eglot-lsp-command-alist))))) + +;;;###autoload +(defun php-eglot-server-program () + "Return a list of command to execute LSP Server." + (cond + ((stringp php-eglot-executable) (list php-eglot-executable)) + ((listp php-eglot-executable) php-eglot-executable) + ((when-let (command (assq php-eglot-executable php-eglot-lsp-command-alist)) + (cond + ((functionp command) (funcall command)) + ((listp command) command)))))) + +(defun php-eglot-ensure () + "Start PHP-specific Eglot session for current buffer if there isn't one." + (when-let (server-program (php-eglot-server-program)) + (setq-local eglot-server-programs (list (cons major-mode server-program)))) + (setq-local project-find-functions (list #'php-project-project-find-function)) + (add-function :after (local 'eglot--managed-mode) #'php-eglot--eglot--managed-mode-after) + (eglot-ensure)) + +(defun php-eglot--eglot--managed-mode-after (&optional _arg) + "Rollback variables when turning off `eglot--managed-mode'." + (unless eglot--managed-mode + (setq-local eglot-server-programs (default-value 'eglot-server-programs)))) + +(provide 'php-eglot) +;;; php-eglot.el ends here From bb5bec31ee927e184c1ddc162d0ddbb92d56d633 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Tue, 11 Oct 2022 02:04:47 +0900 Subject: [PATCH 015/125] Add php-ide.el --- Cask | 2 + Makefile | 1 + lisp/php-ide.el | 184 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 187 insertions(+) create mode 100644 lisp/php-ide.el diff --git a/Cask b/Cask index e090d524..0e8d0585 100644 --- a/Cask +++ b/Cask @@ -13,9 +13,11 @@ "lisp/php-project.el" "lisp/php-local-manual.el" "lisp/php-ide-phpactor.el" + "lisp/php-ide.el" "lisp/php-mode-debug.el") (development + ;;(depends-on "lsp-mode") (depends-on "phpactor") (depends-on "pkg-info") (depends-on "projectile") diff --git a/Makefile b/Makefile index c2fc9ffe..42db81da 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,7 @@ ELS += lisp/php-face.el ELS += lisp/php-flymake.el ELS += lisp/php-format.el ELS += lisp/php-ide-phpactor.el +ELS += lisp/php-ide.el ELS += lisp/php-local-manual.el ELS += lisp/php-mode-debug.el ELS += lisp/php-mode.el diff --git a/lisp/php-ide.el b/lisp/php-ide.el new file mode 100644 index 00000000..e19de0b2 --- /dev/null +++ b/lisp/php-ide.el @@ -0,0 +1,184 @@ +;;; php-ide.el --- IDE-like UI support for PHP development -*- lexical-binding: t; -*- + +;; Copyright (C) 2023 Friends of Emacs-PHP development + +;; Author: USAMI Kenta +;; Keywords: tools, files +;; URL: https://github.com/emacs-php/php-mode +;; Version: 1.24.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 . + +;;; 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-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 my-php-mode-setup () +;; (add-hook 'hack-local-variables-hook #'php-ide-mode t t)) +;; +;; (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 #'my-php-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 'php-project) + +(eval-when-compile + (require 'cl-lib) + (require 'php-ide-phpactor) + (defvar eglot-server-programs) + (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-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)))) + +(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) + +;;;###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") + (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, 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 From e45fa0766f277df50b1b5a8bda2d8ac49d42cabd Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 31 Oct 2022 02:35:42 +0900 Subject: [PATCH 016/125] Add lsp-bridge --- lisp/php-ide.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lisp/php-ide.el b/lisp/php-ide.el index e19de0b2..1342c156 100644 --- a/lisp/php-ide.el +++ b/lisp/php-ide.el @@ -43,6 +43,8 @@ ;; 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 @@ -88,6 +90,7 @@ (require 'cl-lib) (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" ())) @@ -102,6 +105,9 @@ (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))) @@ -161,7 +167,7 @@ (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, eglot or phpactor package")) + (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) From 6d4ca45093060ad320b9a9dfc197098953b89d63 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Fri, 4 Nov 2022 02:18:00 +0900 Subject: [PATCH 017/125] Add php-ide-mode-hooks --- lisp/php-ide.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lisp/php-ide.el b/lisp/php-ide.el index 1342c156..c0bf2e68 100644 --- a/lisp/php-ide.el +++ b/lisp/php-ide.el @@ -143,6 +143,8 @@ :type 'string :safe #'stringp) +(defvar php-ide-mode-hooks nil) + ;;;###autoload (define-minor-mode php-ide-mode "Minor mode for integrate IDE-like tools." @@ -155,6 +157,7 @@ ide-features (mapconcat (lambda (feature) (concat "'" (symbol-name feature))) (php-ide--avilable-features) ", "))) + (run-hooks 'php-ide-mode-hooks) (cl-loop for feature in ide-features for ide-plist = (cdr-safe (assq feature php-ide-feature-alist)) do (if (null ide-plist) From 91cd91a107bca6a0ad1b55d3ac05467f744b2e28 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Wed, 4 Jan 2023 23:00:54 +0900 Subject: [PATCH 018/125] Remove php-eglot.el --- Cask | 1 - Makefile | 1 - lisp/php-eglot.el | 116 ---------------------------------------------- 3 files changed, 118 deletions(-) delete mode 100644 lisp/php-eglot.el diff --git a/Cask b/Cask index 0e8d0585..a52d38fa 100644 --- a/Cask +++ b/Cask @@ -7,7 +7,6 @@ "lisp/php.el" "lisp/php-complete.el" "lisp/php-defs.el" - "lisp/php-eglot.el" "lisp/php-face.el" "lisp/php-format.el" "lisp/php-project.el" diff --git a/Makefile b/Makefile index 42db81da..77474be1 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,6 @@ ELS = lisp/php.el ELS += lisp/php-align.el ELS += lisp/php-complete.el ELS += lisp/php-defs.el -ELS += lisp/php-eglot.el ELS += lisp/php-face.el ELS += lisp/php-flymake.el ELS += lisp/php-format.el diff --git a/lisp/php-eglot.el b/lisp/php-eglot.el deleted file mode 100644 index 6a7875f3..00000000 --- a/lisp/php-eglot.el +++ /dev/null @@ -1,116 +0,0 @@ -;;; php-eglot.el --- Eglot enhancement for PHP development -*- lexical-binding: t; -*- - -;; Copyright (C) 2023 Friends of Emacs-PHP development - -;; Author: USAMI Kenta -;; Keywords: tools, files -;; URL: https://github.com/emacs-php/php-mode -;; Version: 1.24.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 . - -;;; Commentary: - -;; PHP Mode integrates Eglot . -;; -;; **Note**: -;; This feature is under development and experimental. -;; All of these functions, modes and terms are subject to change without notice. -;; -;; ## Configuration -;; -;; Put follows code into your .emacs (~/.emacs.d/init.el) file: -;; -;; (add-to-list 'eglot-server-programs ((php-mode phps-mode) . php-eglot-server-program)) -;; -;; ### For per project configuration -;; -;; Put follows code into .dir-locals.el in project directory: -;; -;; ((nil (php-project-root . git) -;; (php-eglot-executable . ("psalm-language-server")) -;; ;; or (php-eglot-executable . ("php" "vendor/bin/path/to/server")) -;; )) -;; -;; 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) -(require 'eglot nil t) -(require 'phpactor nil t) - -(eval-when-compile - (defvar eglot-server-programs) - (defvar eglot--managed-mode) - (declare-function eglot-ensure "ext:eglot" ()) - (declare-function phpactor--find-executable "ext:phpactor" ())) - -(defvar php-eglot-lsp-command-alist - '((intelephense "intelephense" "--stdio") - (phpactor . (lambda () (list (if (require 'phpactor nil t) - (phpactor--find-executable) - "phpactor")))))) - -(defgroup php-eglot nil - "Eglot PHP integration." - :tag "PHP-Eglot" - :prefix "php-eglot-" - :group 'eglot - :group 'php) - -;;;###autoload -(defcustom php-eglot-executable nil - "Command name or path to the command of Eglot LSP executable." - :tag "Php-Eglot Executable" - :group 'php-eglot - :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-eglot-lsp-command-alist))))) - -;;;###autoload -(defun php-eglot-server-program () - "Return a list of command to execute LSP Server." - (cond - ((stringp php-eglot-executable) (list php-eglot-executable)) - ((listp php-eglot-executable) php-eglot-executable) - ((when-let (command (assq php-eglot-executable php-eglot-lsp-command-alist)) - (cond - ((functionp command) (funcall command)) - ((listp command) command)))))) - -(defun php-eglot-ensure () - "Start PHP-specific Eglot session for current buffer if there isn't one." - (when-let (server-program (php-eglot-server-program)) - (setq-local eglot-server-programs (list (cons major-mode server-program)))) - (setq-local project-find-functions (list #'php-project-project-find-function)) - (add-function :after (local 'eglot--managed-mode) #'php-eglot--eglot--managed-mode-after) - (eglot-ensure)) - -(defun php-eglot--eglot--managed-mode-after (&optional _arg) - "Rollback variables when turning off `eglot--managed-mode'." - (unless eglot--managed-mode - (setq-local eglot-server-programs (default-value 'eglot-server-programs)))) - -(provide 'php-eglot) -;;; php-eglot.el ends here From 657a7b803d5870f2e0cdd83fdb745cbfdac808d2 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Wed, 4 Jan 2023 22:58:09 +0900 Subject: [PATCH 019/125] Update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index de0f8d11..21fa2d8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this * **Net feature**: `php-format` ([#731]) * Add `php-format-project` and `php-format-this-buffer-file` commands * Add `php-format-auto-mode` minor mode + * **Experimental feature: `php-ide`** ([#709]) + * Add `php-ide-phpactor` as simple IDE feature without LSP clients + * Add `php-ide-mode` minor mode for binding IDE-like features ### Fixed @@ -19,6 +22,7 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this * No longer highlights `'link` in PHPDoc ([#724]) * Please use `goto-address-prog-mode` minor mode +[#709]: https://github.com/emacs-php/php-mode/pull/709 [#724]: https://github.com/emacs-php/php-mode/pull/724 [#726]: https://github.com/emacs-php/php-mode/pull/726 [#731]: https://github.com/emacs-php/php-mode/pull/731 From a01bb220bfa1bf3991dbc79d50ea49342d7a6833 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Thu, 5 Jan 2023 02:52:40 +0900 Subject: [PATCH 020/125] Add php-ide-eglot-server-program command --- lisp/php-ide.el | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/lisp/php-ide.el b/lisp/php-ide.el index c0bf2e68..8d6cc758 100644 --- a/lisp/php-ide.el +++ b/lisp/php-ide.el @@ -84,10 +84,10 @@ ;; ;;; Code: +(require 'cl-lib) (require 'php-project) (eval-when-compile - (require 'cl-lib) (require 'php-ide-phpactor) (defvar eglot-server-programs) (declare-function lsp-bridge-mode "ext:lsp-bridge" ()) @@ -136,6 +136,31 @@ :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" From ece3dd51ce8ef349335042097a836ef4cd2ff03a Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sun, 19 Mar 2023 05:55:50 +0900 Subject: [PATCH 021/125] Add php-ide-mode-functions instead of php-ide-mode-hooks --- lisp/php-ide.el | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/lisp/php-ide.el b/lisp/php-ide.el index 8d6cc758..bd61e6ad 100644 --- a/lisp/php-ide.el +++ b/lisp/php-ide.el @@ -57,9 +57,18 @@ ;; ;; Put follows code into your .emacs (~/.emacs.d/init.el) file: ;; -;; (defun my-php-mode-setup () +;; (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 @@ -67,7 +76,8 @@ ;; ;; If you want to hide php-ide-mode from the mode line, set an empty string ;; '(php-ide-mode-lighter "")) ;; -;; (add-hook 'php-mode #'my-php-mode-setup)) +;; (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) ;; @@ -168,7 +178,19 @@ :type 'string :safe #'stringp) -(defvar php-ide-mode-hooks nil) +(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 @@ -182,11 +204,11 @@ ide-features (mapconcat (lambda (feature) (concat "'" (symbol-name feature))) (php-ide--avilable-features) ", "))) - (run-hooks 'php-ide-mode-hooks) (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)))))) From bed4d8ced39ecbfd6ac4961d88cb1ba9ddbaa939 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sun, 19 Mar 2023 06:17:42 +0900 Subject: [PATCH 022/125] Bump up version 1.24.3 --- CHANGELOG.md | 4 +++- Cask | 2 +- lisp/php-align.el | 2 +- lisp/php-complete.el | 2 +- lisp/php-defs.el | 2 +- lisp/php-face.el | 2 +- lisp/php-flymake.el | 2 +- lisp/php-mode-debug.el | 2 +- lisp/php-mode.el | 4 ++-- lisp/php-project.el | 2 +- lisp/php.el | 2 +- 11 files changed, 14 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21fa2d8c..3652ffd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,9 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles. -## Unreleased + + +## [1.24.3] - 2023-03-19 ### Added diff --git a/Cask b/Cask index a52d38fa..822f9101 100644 --- a/Cask +++ b/Cask @@ -1,4 +1,4 @@ -(package "php-mode" "1.24.2" "Major mode for editing PHP code") +(package "php-mode" "1.24.3" "Major mode for editing PHP code") (source melpa) (package-file "lisp/php-mode.el") diff --git a/lisp/php-align.el b/lisp/php-align.el index b1ea3bf4..bed85797 100644 --- a/lisp/php-align.el +++ b/lisp/php-align.el @@ -7,7 +7,7 @@ ;; Maintainer: USAMI Kenta ;; Keywords: php languages convenience align ;; Homepage: https://github.com/emacs-php/php-mode -;; Version: 1.24.2 +;; Version: 1.24.3 ;; License: GPL-3.0-or-later ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-complete.el b/lisp/php-complete.el index e289943a..1decb6f8 100644 --- a/lisp/php-complete.el +++ b/lisp/php-complete.el @@ -6,7 +6,7 @@ ;; Author: USAMI Kenta ;; Created: 18 Sep 2022 -;; Version: 1.24.2 +;; Version: 1.24.3 ;; Keywords: languages, php ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-defs.el b/lisp/php-defs.el index fc9e59c8..7b402db0 100644 --- a/lisp/php-defs.el +++ b/lisp/php-defs.el @@ -4,7 +4,7 @@ ;; Author: USAMI Kenta ;; Created: 5 Mar 2022 -;; Version: 1.24.2 +;; Version: 1.24.3 ;; Keywords: languages, php ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-face.el b/lisp/php-face.el index 1106035c..73f9f15c 100644 --- a/lisp/php-face.el +++ b/lisp/php-face.el @@ -4,7 +4,7 @@ ;; Author: USAMI Kenta ;; Created: 5 May 2019 -;; Version: 1.24.2 +;; Version: 1.24.3 ;; Keywords: faces, php ;; Homepage: https://github.com/emacs-php/php-mode ;; License: GPL-3.0-or-later diff --git a/lisp/php-flymake.el b/lisp/php-flymake.el index 822336e5..28649dc3 100644 --- a/lisp/php-flymake.el +++ b/lisp/php-flymake.el @@ -4,7 +4,7 @@ ;; Author: USAMI Kenta ;; Created: 5 Mar 2022 -;; Version: 1.24.2 +;; Version: 1.24.3 ;; Keywords: tools, languages, php ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-mode-debug.el b/lisp/php-mode-debug.el index 9c69e205..dcbea71f 100644 --- a/lisp/php-mode-debug.el +++ b/lisp/php-mode-debug.el @@ -5,7 +5,7 @@ ;; Author: USAMI Kenta ;; URL: https://github.com/emacs-php/php-mode ;; Keywords: maint -;; Version: 1.24.2 +;; Version: 1.24.3 ;; License: GPL-3.0-or-later ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-mode.el b/lisp/php-mode.el index 012f21ee..62690489 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -9,13 +9,13 @@ ;; Maintainer: USAMI Kenta ;; URL: https://github.com/emacs-php/php-mode ;; Keywords: languages php -;; Version: 1.24.2 +;; Version: 1.24.3 ;; Package-Requires: ((emacs "25.2")) ;; 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.24.3" "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 diff --git a/lisp/php-project.el b/lisp/php-project.el index f862a672..c338fa2f 100644 --- a/lisp/php-project.el +++ b/lisp/php-project.el @@ -5,7 +5,7 @@ ;; Author: USAMI Kenta ;; Keywords: tools, files ;; URL: https://github.com/emacs-php/php-mode -;; Version: 1.24.2 +;; Version: 1.24.3 ;; License: GPL-3.0-or-later ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php.el b/lisp/php.el index 3bff893b..ae6ad647 100644 --- a/lisp/php.el +++ b/lisp/php.el @@ -5,7 +5,7 @@ ;; Author: USAMI Kenta ;; Created: 5 Dec 2018 -;; Version: 1.24.2 +;; Version: 1.24.3 ;; Keywords: languages, php ;; Homepage: https://github.com/emacs-php/php-mode ;; License: GPL-3.0-or-later From 271439397990da38c045a99cadafc13ddfa7b9eb Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sun, 19 Mar 2023 06:30:18 +0900 Subject: [PATCH 023/125] Make PHP Mode requires Emacs 26.1+ --- .github/workflows/test.yml | 3 --- README.ja.md | 2 +- README.md | 2 +- lisp/php-mode.el | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e9467d27..b6eed395 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,10 +13,7 @@ jobs: strategy: matrix: emacs_version: - - "25.2" - - "25.3" - "26.1" - - "26.2" - "26.3" - "27.1" - "27.2" diff --git a/README.ja.md b/README.ja.md index b97f06b8..65e31d7f 100644 --- a/README.ja.md +++ b/README.ja.md @@ -18,7 +18,7 @@ A powerful and flexible Emacs major mode for editing PHP scripts インストール ------------ -**PHP ModeはEmacs 25.2以降で動作します**。古いバージョンのEmacsでも動作するかもしれませんが、保証外です。 古いバージョンのEmacsのPHPモードを使用することによる問題のバグ報告は積極的に対応しません。現在のサポートポリシーは[Supported Version]のページをご覧ください。 +**PHP ModeはEmacs 26.1以降で動作します**。古いバージョンのEmacsでも動作するかもしれませんが、保証外です。 古いバージョンのEmacsのPHPモードを使用することによる問題のバグ報告は積極的に対応しません。現在のサポートポリシーは[Supported Version]のページをご覧ください。 ### **(推奨)** NonGNU ELPAからのインストール diff --git a/README.md b/README.md index 8b94717a..9527810c 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Please submit any bug reports or feature requests by creating issues on [the Git Installation ------------ -**PHP Mode works on Emacs 25.2 or later.** PHP Mode may work with older versions of Emacs but this is not guaranteed. Bug reports for problems related to using PHP Mode with older versions of Emacs will most like *not* be addressed. +**PHP Mode works on Emacs 26.1 or later.** PHP Mode may work with older versions of Emacs but this is not guaranteed. Bug reports for problems related to using PHP Mode with older versions of Emacs will most like *not* be addressed. The current support policy can be found on the [Supported Version] page. diff --git a/lisp/php-mode.el b/lisp/php-mode.el index 62690489..dc854675 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -10,7 +10,7 @@ ;; URL: https://github.com/emacs-php/php-mode ;; Keywords: languages php ;; Version: 1.24.3 -;; Package-Requires: ((emacs "25.2")) +;; Package-Requires: ((emacs "26.1")) ;; License: GPL-3.0-or-later (eval-and-compile From f8913f9a5f96fcc9cfc9bb9302ea1b29dc9f3e93 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 10 Apr 2023 21:04:42 +0900 Subject: [PATCH 024/125] Add GNU ELPA (gnu) to Cask source --- Cask | 1 + 1 file changed, 1 insertion(+) diff --git a/Cask b/Cask index 822f9101..21281db2 100644 --- a/Cask +++ b/Cask @@ -1,5 +1,6 @@ (package "php-mode" "1.24.3" "Major mode for editing PHP code") (source melpa) +(source gnu) (package-file "lisp/php-mode.el") From dfec53804264a874e93ba8e2297a639e29a38992 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 10 Apr 2023 20:36:06 +0900 Subject: [PATCH 025/125] Remove unnecessary :group 'php-mode from defcustom --- lisp/php-mode.el | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/lisp/php-mode.el b/lisp/php-mode.el index dc854675..954ca384 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -138,7 +138,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 +145,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 +156,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 +166,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 +181,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 +188,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 +201,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 +211,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 +250,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 +263,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) @@ -296,7 +279,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 +287,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) From 2f9fa61516a87bd174a2060c6f631e797c1cdb5b Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 10 Apr 2023 20:47:24 +0900 Subject: [PATCH 026/125] Replace function name with #'function-form instead of 'symbol --- lisp/php-mode.el | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lisp/php-mode.el b/lisp/php-mode.el index 954ca384..b5f6d750 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -270,7 +270,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 @@ -337,7 +337,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 @@ -345,7 +345,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 @@ -353,15 +353,15 @@ 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 [(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 [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) ;; 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. @@ -842,12 +842,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'."))) @@ -1230,8 +1230,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) @@ -1241,8 +1241,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 From e45117f0e22fae5af687c3552dcc3e50e22adc41 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 10 Apr 2023 20:51:36 +0900 Subject: [PATCH 027/125] Properly quote symbols in documentation strings --- lisp/php-mode.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/php-mode.el b/lisp/php-mode.el index b5f6d750..aff188f5 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -943,8 +943,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)) From 9a5ace8c9549cb468d91f74e41fa812d7bc0501c Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 10 Apr 2023 21:12:28 +0900 Subject: [PATCH 028/125] Hide CC-mode's `TAB' binding --- lisp/php-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/php-mode.el b/lisp/php-mode.el index aff188f5..df090088 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -365,7 +365,7 @@ as a function. Call with AS-NUMBER keyword to compare by `version<'. ;; 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'.") From 06763946a0e291ddc4a6148c98ee7010d5a05aea Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 10 Apr 2023 21:21:22 +0900 Subject: [PATCH 029/125] Simplify code for style-specific hooks --- lisp/php-mode.el | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/lisp/php-mode.el b/lisp/php-mode.el index df090088..1dca9380 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -1080,13 +1080,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? " @@ -1110,15 +1104,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." From 9e952d47a91454c00b616c47f9d88f0cc1b94a4a Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 10 Apr 2023 21:30:58 +0900 Subject: [PATCH 030/125] Remove unnecessary boundp guards from remove-hook call --- lisp/php-mode.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lisp/php-mode.el b/lisp/php-mode.el index 1dca9380..cabb11cb 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -1132,8 +1132,7 @@ After setting the stylevars run hook `php-mode-STYLENAME-hook'." "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 From 65b8db569ed32dde7ddc12971ed8f12c3f3e75b8 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 10 Apr 2023 21:59:51 +0900 Subject: [PATCH 031/125] Fixed incorrect use of 'local' (nonexistent) advice --- lisp/php-mode.el | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/lisp/php-mode.el b/lisp/php-mode.el index cabb11cb..2f4e22fc 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -660,13 +660,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) "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) @@ -1208,7 +1209,7 @@ After setting the stylevars run hook `php-mode-STYLENAME-hook'." (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)))) @@ -1242,15 +1243,12 @@ After setting the stylevars run hook `php-mode-STYLENAME-hook'." 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 @@ -1558,22 +1556,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 From 4b03e9b956fa78a87b5707308eb0d92854111513 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 10 Apr 2023 22:11:42 +0900 Subject: [PATCH 032/125] Use syntax-propertize-precompile-rules for php-syntax-propertize-function --- lisp/php-mode.el | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/lisp/php-mode.el b/lisp/php-mode.el index 2f4e22fc..b3ea2d08 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -995,20 +995,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))))))) - - (defmacro php-build-propertize-function () - `(byte-compile (syntax-propertize-rules ,@php-syntax-propertize-rules))) - - (defalias 'php-syntax-propertize-function (php-build-propertize-function))) + (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)))))))) + +(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." From f584dfa96583a1cafbcbc303a3eef6758593a8c7 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Tue, 11 Apr 2023 03:19:28 +0900 Subject: [PATCH 033/125] Fix missing received args --- lisp/php-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/php-mode.el b/lisp/php-mode.el index b3ea2d08..c3859614 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -660,7 +660,7 @@ but only if the setting is enabled." '+) (t nil))))))) -(defun php-c-looking-at-or-maybe-in-bracelist (orig-fun &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 From f6d7a4a0b271cb52abd4c5d8ee76e410976c4140 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Wed, 12 Apr 2023 00:53:22 +0900 Subject: [PATCH 034/125] Fix quotations in doc strings --- lisp/php-ide.el | 2 +- lisp/php.el | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lisp/php-ide.el b/lisp/php-ide.el index bd61e6ad..83d085a0 100644 --- a/lisp/php-ide.el +++ b/lisp/php-ide.el @@ -182,7 +182,7 @@ "Hook functions called when before activating or deactivating PHP-IDE. Notice that two arguments (FEATURE ACTIVATE) are given. -FEATURE: A symbol, like 'lsp-mode. +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 diff --git a/lisp/php.el b/lisp/php.el index ae6ad647..4e991287 100644 --- a/lisp/php.el +++ b/lisp/php.el @@ -261,12 +261,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 +293,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 From 062eb5c713aca6ae7452f8b36be982b834c83556 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Wed, 12 Apr 2023 00:53:41 +0900 Subject: [PATCH 035/125] Fix GitHub Actions CI --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b6eed395..b333e2cb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,4 +40,4 @@ jobs: run: 'make .cask test' - name: Run tests (allow failure) if: matrix.allow_failure == true - run: 'make test || true' + run: 'make .cask test || true' From 3e9c75ac7e3bf2ff0f8ca8ab8c6e6c9cdc2fbb48 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Wed, 12 Apr 2023 01:01:34 +0900 Subject: [PATCH 036/125] Fix wrong defcustom --- lisp/php-format.el | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lisp/php-format.el b/lisp/php-format.el index 166975ff..61ddceae 100644 --- a/lisp/php-format.el +++ b/lisp/php-format.el @@ -97,12 +97,12 @@ (defcustom php-format-command 'auto "A formatter symbol, or a list of command and arguments." :tag "PHP Format Command" - :type '(choice (const nil :tag "Disabled reformat codes") - (const 'auto :tag "Auto") - (const 'ecs :tag "Easy Coding Standard") - (const 'php-cs-fixer :tag "PHP-CS-Fixer") - (const 'phpcbf :tag "PHP Code Beautifier and Fixer") - (repeat string :tag "Command and arguments")) + :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) From e00469f654a0a3e3b5e5262ccaf49c83fdce3b04 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Wed, 10 May 2023 12:10:44 +0200 Subject: [PATCH 037/125] Disable php-mode-lineup-cascaded-calls for PEAR style Resolves: https://github.com/emacs-php/php-mode/issues/745 --- lisp/php-mode.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/php-mode.el b/lisp/php-mode.el index c3859614..f0cd36ce 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -714,7 +714,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." From f1af89c6d51feb81cdda808e6fb634240d6eec16 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sat, 17 Jun 2023 04:15:20 +0900 Subject: [PATCH 038/125] Fix call to php-mode-debug-reinstall from php-mode --- lisp/php-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/php-mode.el b/lisp/php-mode.el index c3859614..30d7acec 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -1156,7 +1156,7 @@ After setting the stylevars run hook `php-mode-STYLENAME-hook'." ;; (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) From d03b7ce29c0b5eff25a6eb594161447244a5fc31 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 24 Jul 2023 02:22:47 +0900 Subject: [PATCH 039/125] Add CI test for release-snapshot --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b333e2cb..72f1fd89 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,6 +19,7 @@ jobs: - "27.2" - "28.1" - "28.2" + - release-snapshot - snapshot include: - emacs_version: snapshot From 23d8249e7298d0b34c7ffbeedb14d59b8b456b66 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 24 Jul 2023 02:23:14 +0900 Subject: [PATCH 040/125] Fix type-hints.php test for Emacs 29.1-rc1 --- tests/php-mode-test.el | 3 +- tests/type-hints.php.29.faces | 590 ++++++++++++++++++++++++++++++++++ 2 files changed, 592 insertions(+), 1 deletion(-) create mode 100644 tests/type-hints.php.29.faces diff --git a/tests/php-mode-test.el b/tests/php-mode-test.el index 0dae822e..b827fcfc 100644 --- a/tests/php-mode-test.el +++ b/tests/php-mode-test.el @@ -596,7 +596,8 @@ style from Drupal." (ert-deftest php-mode-test-type-hints () "Test highlighting of type hints and return types." - (with-php-mode-test ("type-hints.php" :faces t))) + (with-php-mode-test ("type-hints.php" :faces (cond ((version<= "29" emacs-version) ".29.faces") + (t))))) (ert-deftest php-mode-test-static-method-calls () "Test highlighting of static method calls which are named the same diff --git a/tests/type-hints.php.29.faces b/tests/type-hints.php.29.faces new file mode 100644 index 00000000..14cf581e --- /dev/null +++ b/tests/type-hints.php.29.faces @@ -0,0 +1,590 @@ +;; -*- mode: emacs-lisp -*- +((" Date: Mon, 24 Jul 2023 02:23:41 +0900 Subject: [PATCH 041/125] Update available Emacs badge to 29.1 --- README.ja.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.ja.md b/README.ja.md index 65e31d7f..b56a66a7 100644 --- a/README.ja.md +++ b/README.ja.md @@ -1,7 +1,7 @@

Emacs PHP Mode

-[![Emacs: 28.2](https://img.shields.io/badge/Emacs-28.2-blue.svg)](https://www.gnu.org/software/emacs/) +[![Emacs: 29.1](https://img.shields.io/badge/Emacs-29.1-blue.svg)](https://www.gnu.org/software/emacs/) [![lang: PHP 8.2](https://img.shields.io/badge/lang-PHP%208.2-brightgreen.svg)](https://php.net/manual/migration82.php) [![lang: PHP 7](https://img.shields.io/badge/lang-PHP%207-green.svg)](https://php.net/downloads.php) [![Build Status](https://github.com/emacs-php/php-mode/workflows/CI/badge.svg)](https://github.com/emacs-php/php-mode/actions) diff --git a/README.md b/README.md index 9527810c..829199d4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

Emacs PHP Mode

-[![Emacs: 28.2](https://img.shields.io/badge/Emacs-28.2-blue.svg)](https://www.gnu.org/software/emacs/) +[![Emacs: 29.1](https://img.shields.io/badge/Emacs-29.1-blue.svg)](https://www.gnu.org/software/emacs/) [![lang: PHP 8.2](https://img.shields.io/badge/lang-PHP%208.2-brightgreen.svg)](https://php.net/manual/migration82.php) [![lang: PHP 7](https://img.shields.io/badge/lang-PHP%207-green.svg)](https://php.net/downloads.php) [![Build Status](https://github.com/emacs-php/php-mode/workflows/CI/badge.svg)](https://github.com/emacs-php/php-mode/actions) From 7774c8d7437997ed8c03b9a323fd66956cce372a Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 24 Jul 2023 02:32:46 +0900 Subject: [PATCH 042/125] Update CHANGELOG --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3652ffd0..02e51eaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,13 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles. - +## Unreleased + +### Added + + * **Support Emacs 29.1** ([#750]) + +[#750]: https://github.com/emacs-php/php-mode/pull/750 ## [1.24.3] - 2023-03-19 From 22059e065fc5acc427f01f3b49f310823dccad9f Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 24 Jul 2023 04:00:49 +0900 Subject: [PATCH 043/125] Add link to [disscussions-emacs29] [disscussions-emacs29]: https://github.com/emacs-php/php-mode/discussions/751 --- README.ja.md | 9 +++++++++ README.md | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/README.ja.md b/README.ja.md index b56a66a7..74bd68b3 100644 --- a/README.ja.md +++ b/README.ja.md @@ -11,10 +11,19 @@ A powerful and flexible Emacs major mode for editing PHP scripts +English   |   [日本語](README.ja.md) +
[PHP ModeのGitHubプロジェクト][php-mode]にissueを作成してバグ報告や機能リクエストを送ってください。 +> **Note** +> [最新版][releases]のPHP ModeはEmacs 29をサポートしています. +> アップグレードに伴うトラブルは[Discussions][disscussions-emacs29]に気軽に書き込んでください。 + +[releases]: https://github.com/emacs-php/php-mode/releases +[disscussions-emacs29]: https://github.com/emacs-php/php-mode/discussions/751 + インストール ------------ diff --git a/README.md b/README.md index 829199d4..6f618693 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,19 @@ A powerful and flexible Emacs major mode for editing PHP scripts +[English](README.md)   |   日本語 +
Please submit any bug reports or feature requests by creating issues on [the GitHub page for PHP Mode][php-mode]. +> **Note** +> The [latest version][releases] of PHP Mode supports Emacs 29. +> Please feel free to [write to disucuss][disscussions-emacs29] if you have problems upgrading to Emacs 29. + +[releases]: https://github.com/emacs-php/php-mode/releases +[disscussions-emacs29]: https://github.com/emacs-php/php-mode/discussions/751 + Installation ------------ From 10509949d3c587771e2f91de2aec143e444adeb4 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 24 Jul 2023 04:02:00 +0900 Subject: [PATCH 044/125] Update CHANGELOG --- CHANGELOG.md | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02e51eaa..5b6a0709 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,36 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles. -## Unreleased + + +## [1.25.0] - 2023-07-24 ### Added - * **Support Emacs 29.1** ([#750]) + * **Support Emacs 29.1** ([#743], [#750]) + +### Fixed + + * Fixed many byte compilation errors on Emacs 29 and 30 by multiple patches contributed by [Stefan Monnier] ([#737], [#739] and [#740], thanks Stefan!) + * Fixed PEAR method chaining wrong indentation ([#745] and [#746], thanks [@cweiske]!) + * Fixed `php-mode-debug-reinstall` command ([#747], [#748]) + +### Removed + * Drop Emacs 25 support ([#729], [736]) + +[Stefan Monnier]: https://www.iro.umontreal.ca/~monnier/ +[#729]: https://github.com/emacs-php/php-mode/pull/729 +[#736]: https://github.com/emacs-php/php-mode/pull/736 +[#737]: https://github.com/emacs-php/php-mode/pull/737 +[#739]: https://github.com/emacs-php/php-mode/pull/739 +[#740]: https://github.com/emacs-php/php-mode/pull/740 +[#741]: https://github.com/emacs-php/php-mode/pull/741 +[#743]: https://github.com/emacs-php/php-mode/pull/743 +[#745]: https://github.com/emacs-php/php-mode/pull/745 +[#746]: https://github.com/emacs-php/php-mode/pull/746 +[#747]: https://github.com/emacs-php/php-mode/pull/747 +[#748]: https://github.com/emacs-php/php-mode/pull/748 [#750]: https://github.com/emacs-php/php-mode/pull/750 ## [1.24.3] - 2023-03-19 From 28d0a0bc81a8481fd75e5a6477dda394fe04fef3 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 24 Jul 2023 04:04:26 +0900 Subject: [PATCH 045/125] Bump up version 1.25.0 --- Cask | 2 +- lisp/php-align.el | 2 +- lisp/php-complete.el | 2 +- lisp/php-defs.el | 2 +- lisp/php-face.el | 2 +- lisp/php-flymake.el | 2 +- lisp/php-ide-phpactor.el | 2 +- lisp/php-ide.el | 2 +- lisp/php-mode-debug.el | 2 +- lisp/php-mode.el | 4 ++-- lisp/php-project.el | 2 +- lisp/php.el | 2 +- 12 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cask b/Cask index 21281db2..7b327b34 100644 --- a/Cask +++ b/Cask @@ -1,4 +1,4 @@ -(package "php-mode" "1.24.3" "Major mode for editing PHP code") +(package "php-mode" "1.25.0" "Major mode for editing PHP code") (source melpa) (source gnu) diff --git a/lisp/php-align.el b/lisp/php-align.el index bed85797..2615495f 100644 --- a/lisp/php-align.el +++ b/lisp/php-align.el @@ -7,7 +7,7 @@ ;; Maintainer: USAMI Kenta ;; Keywords: php languages convenience align ;; Homepage: https://github.com/emacs-php/php-mode -;; Version: 1.24.3 +;; Version: 1.25.0 ;; License: GPL-3.0-or-later ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-complete.el b/lisp/php-complete.el index 1decb6f8..605f4626 100644 --- a/lisp/php-complete.el +++ b/lisp/php-complete.el @@ -6,7 +6,7 @@ ;; Author: USAMI Kenta ;; Created: 18 Sep 2022 -;; Version: 1.24.3 +;; Version: 1.25.0 ;; Keywords: languages, php ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-defs.el b/lisp/php-defs.el index 7b402db0..810e26f1 100644 --- a/lisp/php-defs.el +++ b/lisp/php-defs.el @@ -4,7 +4,7 @@ ;; Author: USAMI Kenta ;; Created: 5 Mar 2022 -;; Version: 1.24.3 +;; Version: 1.25.0 ;; Keywords: languages, php ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-face.el b/lisp/php-face.el index 73f9f15c..1d80c702 100644 --- a/lisp/php-face.el +++ b/lisp/php-face.el @@ -4,7 +4,7 @@ ;; Author: USAMI Kenta ;; Created: 5 May 2019 -;; Version: 1.24.3 +;; Version: 1.25.0 ;; Keywords: faces, php ;; Homepage: https://github.com/emacs-php/php-mode ;; License: GPL-3.0-or-later diff --git a/lisp/php-flymake.el b/lisp/php-flymake.el index 28649dc3..54eef1e7 100644 --- a/lisp/php-flymake.el +++ b/lisp/php-flymake.el @@ -4,7 +4,7 @@ ;; Author: USAMI Kenta ;; Created: 5 Mar 2022 -;; Version: 1.24.3 +;; Version: 1.25.0 ;; Keywords: tools, languages, php ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-ide-phpactor.el b/lisp/php-ide-phpactor.el index 3f73c80e..ff9b8d78 100644 --- a/lisp/php-ide-phpactor.el +++ b/lisp/php-ide-phpactor.el @@ -5,7 +5,7 @@ ;; Author: USAMI Kenta ;; Keywords: tools, files ;; URL: https://github.com/emacs-php/php-mode -;; Version: 1.24.0 +;; Version: 1.25.0 ;; License: GPL-3.0-or-later ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-ide.el b/lisp/php-ide.el index 83d085a0..26c8fd7e 100644 --- a/lisp/php-ide.el +++ b/lisp/php-ide.el @@ -5,7 +5,7 @@ ;; Author: USAMI Kenta ;; Keywords: tools, files ;; URL: https://github.com/emacs-php/php-mode -;; Version: 1.24.0 +;; Version: 1.25.0 ;; License: GPL-3.0-or-later ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-mode-debug.el b/lisp/php-mode-debug.el index dcbea71f..45262531 100644 --- a/lisp/php-mode-debug.el +++ b/lisp/php-mode-debug.el @@ -5,7 +5,7 @@ ;; Author: USAMI Kenta ;; URL: https://github.com/emacs-php/php-mode ;; Keywords: maint -;; Version: 1.24.3 +;; Version: 1.25.0 ;; License: GPL-3.0-or-later ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-mode.el b/lisp/php-mode.el index 9911d4e4..dda4c892 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -9,13 +9,13 @@ ;; Maintainer: USAMI Kenta ;; URL: https://github.com/emacs-php/php-mode ;; Keywords: languages php -;; Version: 1.24.3 +;; 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.3" "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 diff --git a/lisp/php-project.el b/lisp/php-project.el index c338fa2f..53af3500 100644 --- a/lisp/php-project.el +++ b/lisp/php-project.el @@ -5,7 +5,7 @@ ;; Author: USAMI Kenta ;; Keywords: tools, files ;; URL: https://github.com/emacs-php/php-mode -;; Version: 1.24.3 +;; Version: 1.25.0 ;; License: GPL-3.0-or-later ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php.el b/lisp/php.el index 4e991287..74725973 100644 --- a/lisp/php.el +++ b/lisp/php.el @@ -5,7 +5,7 @@ ;; Author: USAMI Kenta ;; Created: 5 Dec 2018 -;; Version: 1.24.3 +;; Version: 1.25.0 ;; Keywords: languages, php ;; Homepage: https://github.com/emacs-php/php-mode ;; License: GPL-3.0-or-later From 651ceaa71c89ff5e91d049835ec072748a85cb66 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 24 Jul 2023 04:16:42 +0900 Subject: [PATCH 046/125] Fix README --- README.ja.md | 3 +-- README.md | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/README.ja.md b/README.ja.md index 74bd68b3..40fa9854 100644 --- a/README.ja.md +++ b/README.ja.md @@ -18,8 +18,7 @@ English   |   [日本語](README.ja.md) [PHP ModeのGitHubプロジェクト][php-mode]にissueを作成してバグ報告や機能リクエストを送ってください。 > **Note** -> [最新版][releases]のPHP ModeはEmacs 29をサポートしています. -> アップグレードに伴うトラブルは[Discussions][disscussions-emacs29]に気軽に書き込んでください。 +> [最新版][releases]のPHP ModeはEmacs 29をサポートしています。
アップグレードに伴うトラブルは[Discussions][disscussions-emacs29]に気軽に書き込んでください。 [releases]: https://github.com/emacs-php/php-mode/releases [disscussions-emacs29]: https://github.com/emacs-php/php-mode/discussions/751 diff --git a/README.md b/README.md index 6f618693..e4b5b2a2 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,7 @@ A powerful and flexible Emacs major mode for editing PHP scripts Please submit any bug reports or feature requests by creating issues on [the GitHub page for PHP Mode][php-mode]. > **Note** -> The [latest version][releases] of PHP Mode supports Emacs 29. -> Please feel free to [write to disucuss][disscussions-emacs29] if you have problems upgrading to Emacs 29. +> The [latest version][releases] of PHP Mode supports Emacs 29.
Please feel free to [write to disucuss][disscussions-emacs29] if you have problems upgrading to Emacs 29. [releases]: https://github.com/emacs-php/php-mode/releases [disscussions-emacs29]: https://github.com/emacs-php/php-mode/discussions/751 From ffd1a72fb487d08a58f73a4358bf927c312fce33 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 24 Jul 2023 04:19:55 +0900 Subject: [PATCH 047/125] Exchange translation link with each other --- README.ja.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.ja.md b/README.ja.md index 40fa9854..1f8767e2 100644 --- a/README.ja.md +++ b/README.ja.md @@ -11,7 +11,7 @@ A powerful and flexible Emacs major mode for editing PHP scripts -English   |   [日本語](README.ja.md) +[English](README.md)   |   日本語
diff --git a/README.md b/README.md index e4b5b2a2..1605a719 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ A powerful and flexible Emacs major mode for editing PHP scripts -[English](README.md)   |   日本語 +English   |   [日本語](README.ja.md)
From 44c3cd68daea8a707b5ee98b74aba875b03da5c6 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 31 Jul 2023 01:40:26 +0900 Subject: [PATCH 048/125] Add Emacs 29.1 to CI --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 72f1fd89..7166cbbe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,6 +19,7 @@ jobs: - "27.2" - "28.1" - "28.2" + - "29.1" - release-snapshot - snapshot include: From f47612375a035dbdaff2c4dc99a28540be60a4dc Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 31 Jul 2023 02:20:13 +0900 Subject: [PATCH 049/125] Remove Phan specific features from php-project.el --- CHANGELOG.md | 8 +++++++- lisp/php-project.el | 21 --------------------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b6a0709..74a72e2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,13 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles. - +## Unreleased + +### Removed + + * Removed Phan-specific features from `php-project` ([#754]) + +[#754]: https://github.com/emacs-php/php-mode/pull/754 ## [1.25.0] - 2023-07-24 diff --git a/lisp/php-project.el b/lisp/php-project.el index 53af3500..55a45ec2 100644 --- a/lisp/php-project.el +++ b/lisp/php-project.el @@ -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 From 59459d4ddf70113e7d7b2a1d3aa6153bbab3f288 Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski Date: Sat, 12 Aug 2023 17:59:30 +0200 Subject: [PATCH 050/125] update github actions --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7166cbbe..8c2438c1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,7 +26,7 @@ jobs: - emacs_version: snapshot allow_failure: true steps: - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v4 with: python-version: '3.11' architecture: 'x64' @@ -36,7 +36,7 @@ jobs: - uses: conao3/setup-cask@master with: version: 'snapshot' - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Run tests if: matrix.allow_failure != true run: 'make .cask test' From b9ada729f31c79e3daa75522d7da6af531fa59f6 Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski Date: Sat, 12 Aug 2023 18:03:44 +0200 Subject: [PATCH 051/125] php-magical-constant: align implementation with php-ts-mode --- lisp/php.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/php.el b/lisp/php.el index 74725973..71c6c09a 100644 --- a/lisp/php.el +++ b/lisp/php.el @@ -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. From 532b73eb21c0ca1b896a34952d2837a73e9cb7ca Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski Date: Mon, 14 Aug 2023 17:16:41 +0200 Subject: [PATCH 052/125] add support for consult imenu --- AUTHORS.md | 1 + lisp/php-mode.el | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/AUTHORS.md b/AUTHORS.md index ab8da75c..9b5ab920 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -83,6 +83,7 @@ Names Sorted Alphabetically: - Olaf The Viking - Peter Oliver - Philippe Ivaldi +- Piotr Kwiecinski - Rex McMaster - Roland - Rosenfeld diff --git a/lisp/php-mode.el b/lisp/php-mode.el index dda4c892..dd57690b 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -73,6 +73,7 @@ (require 'custom) (require 'speedbar) (require 'imenu) +(require 'consult-imenu nil t) (require 'package) (require 'nadvice) (require 'mode-local) @@ -1267,6 +1268,16 @@ After setting the stylevars run hook `php-mode-STYLENAME-hook'." #'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 () From 044ced8eb089cf1115f867fc14985ad0ab4c8169 Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski Date: Tue, 15 Aug 2023 10:44:53 +0200 Subject: [PATCH 053/125] fix byte compilation warnings --- lisp/php-face.el | 9 ++++++--- lisp/php-format.el | 8 ++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lisp/php-face.el b/lisp/php-face.el index 1d80c702..a9ce85f9 100644 --- a/lisp/php-face.el +++ b/lisp/php-face.el @@ -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") @@ -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") diff --git a/lisp/php-format.el b/lisp/php-format.el index 61ddceae..cfa71a57 100644 --- a/lisp/php-format.el +++ b/lisp/php-format.el @@ -98,10 +98,10 @@ "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) + (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) From 8a6a13f3f9d5f9a5b70a5057dd5faf79eda8bd12 Mon Sep 17 00:00:00 2001 From: Nicholas D Steeves Date: Thu, 17 Aug 2023 16:17:38 -0400 Subject: [PATCH 054/125] Future proof one Emacs statement --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1605a719..43717853 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ The current support policy can be found on the [Supported Version] page. [![NonGNU ELPA][nongnu-elpa-badge]][nongnu-elpa] [![NonGNU-devel ELPA][nongnu-devel-elpa-badge]][nongnu-devel-elpa] -Emacs 28 (latest stable release) includes [NonGNU ELPA](https://elpa.nongnu.org/) as the default package repository. +Emacs releases since version 28 have included [NonGNU ELPA](https://elpa.nongnu.org/) as the default package repository. ### Install from MELPA From 1d55887ef3ea7dc2b41484e6dbe03d4dd150a50a Mon Sep 17 00:00:00 2001 From: Nicholas D Steeves Date: Thu, 17 Aug 2023 16:18:09 -0400 Subject: [PATCH 055/125] Drop obsolete Debian&Ubuntu-related info that is no longer relevant. --- README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.md b/README.md index 43717853..38180d97 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,6 @@ PHP Mode is available from [package systems provided by several OSs][php-mode-pa Please consider installing the package provided in `sid` (aka: "unstable", a rolling release) in order to benefit from the latest PHP Mode features and performance improvements. The latest version can be found here: [`elpa-php-mode`][elpa-php-mode]. Investigate "apt-pinning" to make tracking this update stream automatic. -Also, the `php-elisp` package provided by [Debian 9 (stretch)][php-elisp-stretch] and [Ubuntu 18.10][php-elisp-ubuntu1810] and earlier is [extremely old][issue-430], so **PLEASE DO NOT INSTALL IT**. - ### Manual installation If you don't want to depend on a package manager, you can install Lisp files directly in the traditional way. See [Manual installation][wiki-manual-installation] for our recommended setup method. @@ -332,7 +330,6 @@ This project was maintained by [Eric James Michael Ritz][@ejmr] until 2017. Curr [cc mode]: https://www.gnu.org/software/emacs/manual/html_mono/ccmode.html [elpa-php-mode]: https://packages.debian.org/sid/elpa-php-mode [gpl-v3]: https://www.gnu.org/licenses/quick-guide-gplv3.html -[issue-430]: https://github.com/emacs-php/php-mode/issues/430 [nongnu-devel-elpa-badge]: https://elpa.nongnu.org/nongnu-devel/php-mode.svg [nongnu-devel-elpa]: https://elpa.nongnu.org/nongnu-devel/php-mode.html [nongnu-elpa-badge]: https://elpa.nongnu.org/nongnu/php-mode.svg @@ -342,8 +339,6 @@ This project was maintained by [Eric James Michael Ritz][@ejmr] until 2017. Curr [melpa-stable-badge]: http://stable.melpa.org/packages/php-mode-badge.svg [melpa-stable-link]: http://stable.melpa.org/#/php-mode [package]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Packages.html -[php-elisp-stretch]: https://packages.debian.org/stretch/php-elisp -[php-elisp-ubuntu1810]: https://packages.ubuntu.com/cosmic/php-elisp [php-mode-packages]: https://repology.org/project/emacs:php-mode/versions [php-mode]: https://github.com/emacs-php/php-mode [php-suite]: https://github.com/emacs-php/php-suite From 67a3a885c483ade4858ef01c9b7b31971d84e3e3 Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski Date: Mon, 4 Sep 2023 16:54:40 +0200 Subject: [PATCH 056/125] update github action checkout to v4 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8c2438c1..4a2ec425 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,7 +36,7 @@ jobs: - uses: conao3/setup-cask@master with: version: 'snapshot' - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Run tests if: matrix.allow_failure != true run: 'make .cask test' From c7f6b5b9c265ee05ed741d31c47c6886db9ce4e4 Mon Sep 17 00:00:00 2001 From: JenChieh Date: Sun, 10 Sep 2023 23:12:35 -0700 Subject: [PATCH 057/125] test: Add depend bot --- .github/dependabot.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..253bcb76 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: daily From f6496ae81b2df5312d0767323e79b95eb3da6d6b Mon Sep 17 00:00:00 2001 From: JenChieh Date: Mon, 11 Sep 2023 15:58:00 -0700 Subject: [PATCH 058/125] ci: Build with Eask --- .github/workflows/test.yml | 20 ++++++++++++------- .gitignore | 2 ++ Eask | 36 +++++++++++++++++++++++++++++++++ Makefile | 41 +++++++++----------------------------- tests/php-mode-test.el | 1 + 5 files changed, 61 insertions(+), 39 deletions(-) create mode 100644 Eask diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4a2ec425..ab534b45 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,14 +5,21 @@ on: paths-ignore: - '**/*.md' - 'etc/*' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: build: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.experimental }} timeout-minutes: 3 strategy: matrix: - emacs_version: + os: [ubuntu-latest, macos-latest, windows-latest] + emacs-version: - "26.1" - "26.3" - "27.1" @@ -20,7 +27,6 @@ jobs: - "28.1" - "28.2" - "29.1" - - release-snapshot - snapshot include: - emacs_version: snapshot @@ -30,16 +36,16 @@ jobs: with: python-version: '3.11' architecture: 'x64' - - uses: purcell/setup-emacs@master + - uses: jcs090218/setup-emacs@master with: version: ${{ matrix.emacs_version }} - - uses: conao3/setup-cask@master + - uses: emacs-eask/setup-eask@master with: version: 'snapshot' - uses: actions/checkout@v4 - name: Run tests if: matrix.allow_failure != true - run: 'make .cask test' + run: 'make .eask test' - name: Run tests (allow failure) if: matrix.allow_failure == true - run: 'make .cask test || true' + run: 'make .eask test || true' diff --git a/.gitignore b/.gitignore index f1e2797e..3e9846c7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,9 @@ *~ .dir-locals-2.el /.cask/* +/.eask/* /.keg/* +/dist /.php-cs-fixer.cache php-mode-autoloads.el php_manual_en.json diff --git a/Eask b/Eask new file mode 100644 index 00000000..5c0a8558 --- /dev/null +++ b/Eask @@ -0,0 +1,36 @@ +(package "php-mode" + "1.25.0" + "Major mode for editing PHP code") + +(website-url "https://github.com/emacs-php/php-mode") +(keywords "languages" "php") + +(package-file "lisp/php-mode.el") +(files + "lisp/php.el" + "lisp/php-complete.el" + "lisp/php-defs.el" + "lisp/php-face.el" + "lisp/php-format.el" + "lisp/php-project.el" + "lisp/php-local-manual.el" + "lisp/php-ide-phpactor.el" + "lisp/php-ide.el" + "lisp/php-mode-debug.el") + +(script "test" "echo \"Error: no test specified\" && exit 1") + +(source 'melpa) +(source 'gnu) + +(depends-on "emacs" "26.1") + +(development + (depends-on "phpactor") + (depends-on "pkg-info") + (depends-on "projectile") + (depends-on "smart-jump") + (depends-on "shut-up") + ) + +(setq network-security-level 'low) ; see https://github.com/jcs090218/setup-emacs-windows/issues/156#issuecomment-932956432 diff --git a/Makefile b/Makefile index 77474be1..52665554 100644 --- a/Makefile +++ b/Makefile @@ -1,23 +1,9 @@ EMACS ?= emacs CASK ?= cask -ELS = lisp/php.el -ELS += lisp/php-align.el -ELS += lisp/php-complete.el -ELS += lisp/php-defs.el -ELS += lisp/php-face.el -ELS += lisp/php-flymake.el -ELS += lisp/php-format.el -ELS += lisp/php-ide-phpactor.el -ELS += lisp/php-ide.el -ELS += lisp/php-local-manual.el -ELS += lisp/php-mode-debug.el -ELS += lisp/php-mode.el -ELS += lisp/php-project.el -AUTOLOADS = php-mode-autoloads.el -ELCS = $(ELS:.el=.elc) +EASK ?= eask -%.elc: %.el - $(EMACS) --batch -L lisp/ -f batch-byte-compile $< +compile: + $(EASK) compile all: autoloads $(ELCS) authors @@ -34,19 +20,14 @@ AUTHORS.md: etc/git/AUTHORS.md.in .mailmap && printf "FINISHED\n" ; ) \ || printf "FAILED (non-fatal)\n" -autoloads: $(AUTOLOADS) +autoloads: + $(EASK) generate autoloads -$(AUTOLOADS): $(ELS) - $(EMACS) --batch -L lisp/ --eval \ - "(let ((user-emacs-directory default-directory)) \ - (require 'package) \ - (package-generate-autoloads \"php-mode\" (expand-file-name \"lisp\")))" - -.cask: Cask - $(CASK) install +.eask: Eask + $(EASK) install clean: - rm -f $(ELCS) $(AUTOLOADS) + $(EASK) clean all # Perform any operations that will be useful for developers # who contribute to PHP Mode. @@ -66,10 +47,6 @@ dev: # for an example of using a script like this with the 'git bisect run' # command. test: clean all - touch tests/project/1/.git - $(EMACS) --batch -l lisp/php-mode-autoloads.el --eval \ - "(let ((default-directory (expand-file-name \".cask\" default-directory))) \ - (normal-top-level-add-subdirs-to-load-path))" \ - -l tests/php-mode-test.el -f ert-run-tests-batch-and-exit + $(EASK) test ert ./tests/php-mode-test.el .PHONY: all authors autoloads clean test diff --git a/tests/php-mode-test.el b/tests/php-mode-test.el index b827fcfc..1aa9173f 100644 --- a/tests/php-mode-test.el +++ b/tests/php-mode-test.el @@ -619,6 +619,7 @@ as a keyword." (ert-deftest php-project-root () "Test for detection `php-project-root' by directory." (dolist (root (mapcar #'car php-project-available-root-files)) + (skip-unless (eq system-type windows-nt)) ; TODO: Make test compatible to Windows! (with-php-mode-test ("project/1/src/functions.php") (let ((php-project-root root)) (should (string= (expand-file-name "project/1/" php-mode-test-dir) From 291ed01ccefb52deec0695f8573dcb7a5dba356f Mon Sep 17 00:00:00 2001 From: JenChieh Date: Mon, 11 Sep 2023 16:00:24 -0700 Subject: [PATCH 059/125] fix typo --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ab534b45..623bf3ba 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,7 +38,7 @@ jobs: architecture: 'x64' - uses: jcs090218/setup-emacs@master with: - version: ${{ matrix.emacs_version }} + version: ${{ matrix.emacs-version }} - uses: emacs-eask/setup-eask@master with: version: 'snapshot' From 8a9d72c42802291d859bb083799bbb54abd87a40 Mon Sep 17 00:00:00 2001 From: JenChieh Date: Mon, 11 Sep 2023 16:03:13 -0700 Subject: [PATCH 060/125] fix workflow --- .github/workflows/test.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 623bf3ba..8c3c4ef9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,9 +28,17 @@ jobs: - "28.2" - "29.1" - snapshot + experimental: [false] include: - - emacs_version: snapshot - allow_failure: true + - os: ubuntu-latest + emacs-version: snapshot + experimental: true + - os: macos-latest + emacs-version: snapshot + experimental: true + - os: windows-latest + emacs-version: snapshot + experimental: true steps: - uses: actions/setup-python@v4 with: @@ -44,8 +52,6 @@ jobs: version: 'snapshot' - uses: actions/checkout@v4 - name: Run tests - if: matrix.allow_failure != true run: 'make .eask test' - name: Run tests (allow failure) - if: matrix.allow_failure == true run: 'make .eask test || true' From fff5b972ebdf4ab08568139a10dcc368eb715528 Mon Sep 17 00:00:00 2001 From: JenChieh Date: Mon, 11 Sep 2023 16:04:42 -0700 Subject: [PATCH 061/125] only test latest minor version --- .github/workflows/test.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8c3c4ef9..129fee5c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,11 +20,8 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] emacs-version: - - "26.1" - "26.3" - - "27.1" - "27.2" - - "28.1" - "28.2" - "29.1" - snapshot From 284f15f68745ef649dac608cec42047382b88a83 Mon Sep 17 00:00:00 2001 From: JenChieh Date: Mon, 11 Sep 2023 16:07:35 -0700 Subject: [PATCH 062/125] Add fail-fast --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 129fee5c..4bbe8e68 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,6 +17,7 @@ jobs: continue-on-error: ${{ matrix.experimental }} timeout-minutes: 3 strategy: + fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] emacs-version: From 6bb82814b57d6eff79413893edbc26fddfa61fbf Mon Sep 17 00:00:00 2001 From: JenChieh Date: Mon, 11 Sep 2023 16:10:09 -0700 Subject: [PATCH 063/125] get rid of unused snapshot --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4bbe8e68..c660d58f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,7 +25,6 @@ jobs: - "27.2" - "28.2" - "29.1" - - snapshot experimental: [false] include: - os: ubuntu-latest From 75d48f3c14f503ec5a2958f443e6ec56c7460a7b Mon Sep 17 00:00:00 2001 From: JenChieh Date: Mon, 11 Sep 2023 16:21:21 -0700 Subject: [PATCH 064/125] mark test failed on macos --- tests/php-mode-test.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/php-mode-test.el b/tests/php-mode-test.el index 1aa9173f..3590ba49 100644 --- a/tests/php-mode-test.el +++ b/tests/php-mode-test.el @@ -181,6 +181,7 @@ file name and check that the faces of the fonts in the buffer match." The next character after \">We\" is a single quote. It should not have a string face." :expected-result :failed + (skip-unless (not (eq system-type darwin))) ; TODO: Failed on macOS 28.2 or above! (with-php-mode-test ("issue-9.php") (search-forward ">We") (forward-char) ;; Jump to after the opening apostrophe @@ -619,7 +620,7 @@ as a keyword." (ert-deftest php-project-root () "Test for detection `php-project-root' by directory." (dolist (root (mapcar #'car php-project-available-root-files)) - (skip-unless (eq system-type windows-nt)) ; TODO: Make test compatible to Windows! + (skip-unless (not (eq system-type windows-nt))) ; TODO: Make test compatible to Windows! (with-php-mode-test ("project/1/src/functions.php") (let ((php-project-root root)) (should (string= (expand-file-name "project/1/" php-mode-test-dir) From 015f9ae2e17f1db524cff961897ae450dbb5938a Mon Sep 17 00:00:00 2001 From: JenChieh Date: Mon, 11 Sep 2023 16:36:47 -0700 Subject: [PATCH 065/125] avoid timeout --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c660d58f..bfe04578 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,6 @@ jobs: build: runs-on: ${{ matrix.os }} continue-on-error: ${{ matrix.experimental }} - timeout-minutes: 3 strategy: fail-fast: false matrix: From 21b0e6bcb3b4465ca99290151380a2d093804716 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Wed, 13 Sep 2023 14:38:22 +0900 Subject: [PATCH 066/125] Update AUTHORS --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 9b5ab920..2f5ab259 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -62,6 +62,7 @@ Names Sorted Alphabetically: - Jakub Jankiewicz - James Laver - Jeff Beeman +- JenChieh - Joe Wreschnig - John Keller - Jon Dufresne From 8500ecd2c4079404d0672254e974e1df240452ac Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Tue, 19 Sep 2023 15:44:33 -0700 Subject: [PATCH 067/125] docs(AUTHORS.md): Fix name for @jcs090218 --- AUTHORS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index 2f5ab259..bdd02614 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -62,7 +62,7 @@ Names Sorted Alphabetically: - Jakub Jankiewicz - James Laver - Jeff Beeman -- JenChieh +- Jen-Chieh Shen - Joe Wreschnig - John Keller - Jon Dufresne From 7e93315a8e28a26f5f8398ecd519beff00ca9a82 Mon Sep 17 00:00:00 2001 From: takeokunn Date: Fri, 29 Sep 2023 08:53:38 +0900 Subject: [PATCH 068/125] Add (require 'flymake-proc) --- lisp/php-flymake.el | 1 + lisp/php-mode.el | 1 + 2 files changed, 2 insertions(+) diff --git a/lisp/php-flymake.el b/lisp/php-flymake.el index 54eef1e7..a3650dad 100644 --- a/lisp/php-flymake.el +++ b/lisp/php-flymake.el @@ -26,6 +26,7 @@ ;;; Code: (require 'flymake) +(require 'flymake-proc) (require 'cl-lib) (eval-when-compile (require 'pcase) diff --git a/lisp/php-mode.el b/lisp/php-mode.el index dd57690b..efcdd2a3 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -83,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" From 2bad994c1727388ca5b1313f63c9604ebe959daf Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sat, 18 Nov 2023 13:29:33 +0900 Subject: [PATCH 069/125] Add php-topsy-beginning-of-defun-with-class for Topsy --- CHANGELOG.md | 5 +++++ lisp/php.el | 31 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74a72e2f..0c29853e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,16 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this ## Unreleased +### Added + + * Add `php-topsy-beginning-of-defun-with-class` to display classname with function signature. ([#766]) + ### Removed * Removed Phan-specific features from `php-project` ([#754]) [#754]: https://github.com/emacs-php/php-mode/pull/754 +[#766]: https://github.com/emacs-php/php-mode/pull/766 ## [1.25.0] - 2023-07-24 diff --git a/lisp/php.el b/lisp/php.el index 71c6c09a..67193f03 100644 --- a/lisp/php.el +++ b/lisp/php.el @@ -203,6 +203,12 @@ a completion list." :type 'integer :link '(url-link :tag "Built-in web server" "https://www.php.net/manual/features.commandline.webserver.php")) + +(defcustom php-topsy-separator " > " + "Separator string for `php-topsy-beginning-of-defun-with-class'." + :group 'php + :tag "PHP Topsy Separator" + :type 'string) ;;; PHP Keywords (defconst php-magical-constants @@ -655,6 +661,31 @@ Look at the `php-executable' variable instead of the constant \"php\" command." (if (string= class "") "" (concat "\\" class "::")) (if (string= namedfunc "") "" (concat namedfunc "()")))))) +(defun php-topsy-beginning-of-defun-with-class () + "Return function signature and class name string for header line in topsy. + +You can add the function to topsy with the code below: +\(add-to-list 'topsy-mode-functions '(php-mode . php-topsy-beginning-of-defun-with-class))" + (save-excursion + (goto-char (window-start)) + (mapconcat + #'identity + (append + (save-match-data + (save-excursion + (when (re-search-backward php--re-classlike-pattern nil t) + (font-lock-ensure (point) (line-end-position)) + (list (string-trim (buffer-substring (point) (line-end-position))))))) + (progn + (beginning-of-defun) + (font-lock-ensure (point) (line-end-position)) + (list (string-trim + (replace-regexp-in-string + (eval-when-compile (rx bos " Date: Sat, 18 Nov 2023 14:10:30 +0900 Subject: [PATCH 070/125] Update doc comment --- lisp/php.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/php.el b/lisp/php.el index 67193f03..7188c0c6 100644 --- a/lisp/php.el +++ b/lisp/php.el @@ -665,7 +665,7 @@ Look at the `php-executable' variable instead of the constant \"php\" command." "Return function signature and class name string for header line in topsy. You can add the function to topsy with the code below: -\(add-to-list 'topsy-mode-functions '(php-mode . php-topsy-beginning-of-defun-with-class))" + \(add-to-list 'topsy-mode-functions '\(php-mode . php-topsy-beginning-of-defun-with-class\)\)" (save-excursion (goto-char (window-start)) (mapconcat From 886400c8ee967a26805a215fb0f5d015962bd080 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sat, 18 Nov 2023 14:15:11 +0900 Subject: [PATCH 071/125] (require 'flymake-proc) when compile time --- CHANGELOG.md | 6 ++++++ lisp/php-flymake.el | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c29853e..b96f30ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,12 +8,18 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this * Add `php-topsy-beginning-of-defun-with-class` to display classname with function signature. ([#766]) +### Fixed + + * Fixed build failure in Emacs on master branch ([#764], [#767]) + ### Removed * Removed Phan-specific features from `php-project` ([#754]) [#754]: https://github.com/emacs-php/php-mode/pull/754 +[#764]: https://github.com/emacs-php/php-mode/issues/764 [#766]: https://github.com/emacs-php/php-mode/pull/766 +[#767]: https://github.com/emacs-php/php-mode/pull/767 ## [1.25.0] - 2023-07-24 diff --git a/lisp/php-flymake.el b/lisp/php-flymake.el index a3650dad..a55a22a8 100644 --- a/lisp/php-flymake.el +++ b/lisp/php-flymake.el @@ -26,8 +26,9 @@ ;;; Code: (require 'flymake) -(require 'flymake-proc) (require 'cl-lib) +(eval-and-compile + (require 'flymake-proc)) (eval-when-compile (require 'pcase) (require 'rx)) From a33777503c217da0a1e27b6bad05548744e772e3 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sun, 19 Nov 2023 00:12:18 +0900 Subject: [PATCH 072/125] Update CONTRIBUTING.md --- CONTRIBUTING.md | 49 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f7c36c85..58c3d13b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,19 +11,25 @@ This project accepts contributions in various languages. Not only development b ## English +### Setup (en) + +[Eask] is required to build the package. You need to install it using node.js and npm, or [download a prebuilt executable][eask-releases]. See [Eask Introduction][eask-introduction] and [Install Eask][eask-install] for more details. + +You can run the tests using the following command: + +```sh +make test +``` + ### Guideline (en) -All contributions to PHP Mode are welcome. But please try to do the following when sending improvements or bug fixes: +All contributions to PHP Mode are welcome. But please try to do the following when submitting enhancements or bug fixes: - 1. Add your name to the list of ‘Contributors’ in this `README.md` file if it is not there already. If you have a GitHub page and/or personal site then please feel free to link your name to it so people can see your other work. - 2. If your contribution addresses an issue on the GitHub project page then include a single line like `GitHub-Issue: #16` with the appropriate issue number. - 3. Make sure to update the constant `php-mode-modified` *only if you patch affects `php-mode.el`,* which means this step is unnecessary for patches related to unit tests. - 4. However, please do not modify `php-mode-version-number`. The maintainers will decide what constitutes a bump in the version number. - 5. Open the `php-mode-test.el` file and [run all of the tests] to ensure they still pass as expected. Sometimes we expect for a test to fail, and those unit tests have the appropriate configuration so their failure will not raise any warnings. You can use `make test` script to run all tests from a terminal, which is also useful in conjunction with [`git bisect run`]. - 6. Send us a pull request here on GitHub. - 7. Please make your commit messages as detailed as possible. It is better to be too verbose than to write too little. Look at the commits of the maintainers to see many examples of the level of detail that we feel is ideal. Please never assume that your patch is so simple that future developers will be able to understand the *reason* for the change without comment. And that is important: your commit message should always strive to answer *"Why"* the patch exists, *"What*" does it accomplish? The maintainers will sometimes write detailed commit messages for pull-requests by other developers, but please do not rely on us to do this consistently. + 1. Open `php-mode-test.el` and run all the tests to make sure they pass as expected. You can also check this by running `make test` from the terminal. + 2. Please commit with a concise and clear message that effectively achieves a simple purpose. + 3. Submit a pull request here on GitHub. -If you are fixing a bug related to a GitHub issue, then first of all, thank you for the help improving PHP Mode. Second, there is a `tests/` directory which contains PHP scripts for issues (although not all of them). Please consider adding a test script to that directory that documents the expected behavior and provides code that allows others to see if said behavior works properly. Then create a unit test within `php-mode-test.el` using [ERT]. Please try to follow the format of the existing tests. +If you are fixing a bug related to a GitHub issue, then first of all, thank you for helping to improve PHP Mode. Second, there is a `tests/` directory that contains PHP scripts for issues (though not all). Please consider adding a test script to that directory that documents the expected behavior and provides code that allows others to see if that behavior works properly. Then create a unit test within `php-mode-test.el' using [ERT]. Try to follow the format of the existing tests. ### Regression test for Face (en) @@ -55,17 +61,23 @@ Please contribute. ## Japanese +### Setup (ja) + +パッケージをビルドするにはEaskが必要です。node.jsとnpmからインストールするか、ビルド済み実行ファイルをダウンロードする必要があります。Easkの詳細は[Eask Introduction][eask-introduction]と[Install Eask][eask-install]をお読みください。 + +以下のコマンドでテストを実行できます。 + +```sh +make test +``` + ### Guideline (ja) **Emacs PHP Mode**はどなたからの貢献も歓迎です。改善やバグ修正を行う前に以下の手順を行ってください。 - 1. あなたの名前が`README.md`の“Contributors”のリストになければ追加してください。あなたの名前とGitHubアカウントや個人サイトをリンクして構いません。 - 2. もし既にissueとして提起された問題に対処するならば、コミットメッセージに`GitHub-Issue: #16`のような行を含めてください。 - 3. `php-mode.el`に影響する変更をした場合、`php-mode-modified`定数を更新してください。テストやドキュメントのみの修正の場合は不要です。 - 4. しかし、 `php-mode-version-number` は変更しないでください。メンテナがバージョンを決定します。 - 5. `php-mode-test.el`を開いて[すべてのテストを実行][run all of the tests]し、期待通りにテストを通過することを確認します。端末から`make test`で確認することもでき、[`git bisect run`]と併用すると便利です。 - 6. GitHubからプルリクエストを送信します - 7. 可能な限り詳細なコミットメッセージを作成してください。不足するよりも冗長すぎる方が良いです。メンテナーのコミットを参照して、私たちが理想的だと期待するコミットメッセージの詳細度として参考にしてください。シンプルすぎるパッチだからと決めつけずにコミットメッセージを書けば、コード中にコメントを書かなくても将来の開発者がコミットの「理由」「経緯」を理解できるようになります。コミットメッセージには「なぜ」コミットを作成したか、「何を」解決するものなのかを記述することが重要です。メンテナーはほかの開発者のプルリクエストに詳細なコミットメッセージを書き込むことがありますが、常に一貫して行われるとは期待しないでください。 + 1. `php-mode-test.el`を開いて[すべてのテストを実行][run all of the tests]し、期待通りにテストを通過することを確認します。端末から`make test`で確認することもできます。 + 2. 簡潔でシンプルな目的を達成するための、明示的なメッセージでコミットしてください。 + 3. GitHubからプルリクエストを送信してください。 **GitHubのissueに関連するバグを修正する場合**: PHPモードの改善に協力いただきありがとうございます! `tests/`ディレクトリには(すべてではありませんが)issueに関連のあるPHPスクリプトが配置されています。そこに予期される挙動と他のひとが動作を適切に確認できるテストコードを追加することを検討してください。そして`php-mode-test.el`に既存のテストと同じように[ERT]を使ったテストコードを追加してください。 @@ -76,7 +88,10 @@ Please contribute. このテストに必要な`.face`ファイルの生成方法は[How to generate face file]を参考にしてください。 [run all of the tests]: http://www.gnu.org/software/emacs/manual/html_node/ert/Running-Tests-Interactively.html#Running-Tests-Interactively -[`git bisect run`]: http://git-scm.com/book/en/Git-Tools-Debugging-with-Git +[Eask]: https://emacs-eask.github.io/ +[eask-introduction]: https://emacs-eask.github.io/Getting-Started/Introduction/ +[eask-install]: https://emacs-eask.github.io/Getting-Started/Install-Eask/ +[eask-releases]: https://github.com/emacs-eask/cli/releases [ERT]: http://www.gnu.org/software/emacs/manual/html_node/ert/index.html [Font Lock]: https://www.gnu.org/software/emacs/manual/html_node/elisp/Font-Lock-Mode.html [How to generate face file]: https://github.com/emacs-php/php-mode/issues/509#issuecomment-491528968 From d3e0467bfb475f82141e06551d6e2bba793ed3b1 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sun, 19 Nov 2023 02:18:04 +0900 Subject: [PATCH 073/125] Update README.md --- README.ja.md | 300 +++++---------------------------------------------- README.md | 288 ++++++------------------------------------------- 2 files changed, 61 insertions(+), 527 deletions(-) diff --git a/README.ja.md b/README.ja.md index 1f8767e2..54b6ba7d 100644 --- a/README.ja.md +++ b/README.ja.md @@ -15,73 +15,55 @@ A powerful and flexible Emacs major mode for editing PHP scripts -[PHP ModeのGitHubプロジェクト][php-mode]にissueを作成してバグ報告や機能リクエストを送ってください。 +[GitHubプロジェクト][php-mode]にissueを作成してバグ報告や機能リクエストを送ってください。 -> **Note** +> [!NOTE] > [最新版][releases]のPHP ModeはEmacs 29をサポートしています。
アップグレードに伴うトラブルは[Discussions][disscussions-emacs29]に気軽に書き込んでください。 [releases]: https://github.com/emacs-php/php-mode/releases [disscussions-emacs29]: https://github.com/emacs-php/php-mode/discussions/751 -インストール ------------- +## インストール -**PHP ModeはEmacs 26.1以降で動作します**。古いバージョンのEmacsでも動作するかもしれませんが、保証外です。 古いバージョンのEmacsのPHPモードを使用することによる問題のバグ報告は積極的に対応しません。現在のサポートポリシーは[Supported Version]のページをご覧ください。 +**PHP ModeはEmacs 26.1以降で動作します**。対応バージョンの詳細は[Supported Version]をお読みください。Emacs 28以降では単に以下のコマンドを実行するだけでインストールできます。 -### **(推奨)** NonGNU ELPAからのインストール - -[![NonGNU ELPA][nongnu-elpa-badge]][nongnu-elpa] [![NonGNU-devel ELPA][nongnu-devel-elpa-badge]][nongnu-devel-elpa] - -Emacs 28 (最新安定版) では[NonGNU ELPA](https://elpa.nongnu.org/)がデフォルトのパッケージリポジトリとして追加されています。 - - -### MELPAからのインストール - -[![melpa badge][melpa-badge]][melpa-link] [![melpa stable badge][melpa-stable-badge]][melpa-stable-link] - -GNU Emacs 24以降では、[package][]機能(または[Cask][])を使って[MELPA][]/[MELPA Stable][]からPHP Modeをインストールできます。 - -### OSのパッケージマネージャからのインストール - -PHP Modeは[いくつかのOSが提供するパッケージシステム][php-mode-packages]からインストール可能です。DebianおよびUbuntuのようなDebian派生のOSではEmacsにPHPを追加する最も簡単な方法で、`sudo apt install elpa-php-mode` で導入できます。これらの "Stable" リリースは最新のPHP Modeよりも古いものの、十分にテストされた固定バージョンが提供されます。オートロードとバイトコンパイルは自動で行われます。 - -最新のPHP Modeの機能とパフォーマンス改善を活用するために**sid** ("unstable"としても知られるローリングリリース)で提供されるバージョンのインストールを検討してください。最新バージョンは[`elpa-php-mode`][elpa-php-mode]にあります。"apt-pinning"を使ってアップデートを自動化することもできます。 - -また、[Debian 9 (stretch)][php-elisp-stretch]や[Ubuntu 18.10][php-elisp-ubuntu1810]以前で提供されていた `php-elisp` パッケージは[あまりにも古い][issue-430]ので、 **くれぐれもインストールしないでください**。 - -### 手動でインストール - -もしパッケージマネージャに依存したくなければ、伝統的な方法によってLispファイルを直接インストールすることもできます。詳細なセットアップ方法は[手動でのインストール][wiki-manual-installation-ja]ページをご覧ください。 +``` +M-x package-install php-mode +``` -バグを報告する --------------- +[`package-archives`にMELPAを追加][melpa-getting-started]することで、Web上の多くのパッケージでEmacsを強化できます。 -報告の際には `M-x php-mode-debug` コマンドを実行して、その出力をバグレポートに含めてください。問題を再現するための手がかりになります。 +パッケージマネージャへの依存なしでインストールしたい場合は、Lispファイルを直接配置する伝統的な方法も可能です。詳しくは[Manual installation][wiki-manual-installation]をお読みください。 -Settings --------- +## 設定 ### 個人設定 -.emacsファイル(`~/.emacs.d/init.el`)にPHPモードでの設定を記述できます。 +.emacsファイル(`~/.emacs.d/init.el`)にPHPモードの設定を記述できます。 ```lisp (defun my-php-mode-init () + (subword-mode 1) (setq-local show-trailing-whitespace t) (setq-local ac-disable-faces '(font-lock-comment-face font-lock-string-face)) - (setq-local page-delimiter "\\_<\\(class\\|function\\|namespace\\)\\_>.+$") + (add-hook 'hack-local-variables-hook 'php-ide-turn-on nil t)) - ;; If you feel phumped and phpcs annoying, invalidate them. - (when (boundp 'flycheck-disabled-checkers) +(with-eval-after-load 'php-mode + (add-hook 'php-mode-hook #'my-php-mode-init) + (custom-set-variables + '(php-mode-coding-style 'psr2) + '(php-mode-template-compatibility nil) + '(php-imenu-generic-expression 'php-imenu-generic-expression-simple)) + + ;; If you find phpcs to be bothersome, you can disable it. + (when (require 'flycheck nil) (add-to-list 'flycheck-disabled-checkers 'php-phpmd) (add-to-list 'flycheck-disabled-checkers 'php-phpcs))) - -(add-hook 'php-mode-hook #'my-php-mode-init) ``` ### プロジェクトローカル設定 -プロジェクトのトップディレクトリに`.dir-locals.el`を記述すると、プロジェクト単位の設定を追加することができます。このファイルはユーザー自身のEmacsにインストールされたパッケージに依存するため、バージョン管理の対象に含めないことを推奨します。 +プロジェクトのトップディレクトリに`.dir-locals.el`または`.dir-locals-2.el`を記述すると、プロジェクト単位の設定を追加することができます。このファイルはユーザー自身のEmacsにインストールされたパッケージに依存するため、バージョン管理の対象に含めないことを推奨します。 ```lisp ((nil @@ -89,226 +71,15 @@ Settings (php-project-coding-style . psr2))) ``` -実験的および作業中の機能 -------------------------------------- - -### CC Mode, CEDET, EDE, and Semantic - -In 2013 Daniel Haxney began rewriting parts of PHP Mode in terms of Emacs' built-in CC Mode. This laid the foundation for incorporating some of the inherit IDE-ish features of Emacs, such as CEDET, EDE, and Semantic. Support for these tools continues to improve thanks to the work of Andrea Turso, Steven Rémot, Joris Steyn, and others. If you wish to test, contribute to, or simply experiment with such features then [this thread is a good place to start](https://github.com/emacs-php/php-mode/issues/256). - -### PHP7サポート - -PHP7がリリースされました。PHPモードはPHP7からの以下の文法をサポートします。 - - 1. 返り値の型宣言 - 2. `yield from` キーワード - 3. `declare(strict_types=1)` 宣言 - -機能 --------- - -### 新しいキーワード - -現在のPHPモードはトレイト関連の`insteadof`などのPHP5.4で導入された新しいキーワードを構文強調表示します。また、従来のキーワード`clone`や`default`などもサポートします。 - -### 定数 - -強調表示には公式のPHPマニュアルに記載があるすべてのマジック定数と定義済み定数が含まれます。ただし、特定の拡張機能の定数は現在のところ含みません。 - -### トレイト、インターフェイスと名前空間 - -トレイト、インターフェイス、名前空間がImenuリストに表示されるようになりました。フォント表示は名前空間でも正しく動作するようになり、`namespace Foo\Bar\Baz`のようなコードはもはや警告されません。`use as `のような名前空間のエイリアスも同様です。現在のところエイリアス名はImenuのリストには含まれませんが、将来のバージョンでは対応予定です。 - -### アンダースコアの取り扱い - -PHPモードは`$foo_bar_baz`のような変数名の単語のそれぞれの部分を移動できるように、アンダースコア(`_`)を「シンボル構成要素 (symbol constituents)」(Emacs用語)として取り扱います。 - -### メソッドチェーン呼び出し - -複数行にわたるメソッド呼び出しを`->`の位置に揃えること(アライメント)ができます。 - -```php -$object->foo() - ->bar() - ->baz(); -``` - -この動作はデフォルトでは無効ですが、カスタマイズ変数 `php-mode-lineup-cascaded-calls` をセットすることで有効化できます。 - -**注意**: アライメントは、PHPモードのコーディングスタイルのひとつを使用するか、それを継承した場合のみ機能します。 - -### ネストされた配列の整形 - -ネストされた関数呼び出しと `array()` 構文は現在デフォルトで(少くとも私の意見では)よく見えるようになりました。例として、このようなスタイルです: - -```php -$results = Post::model()->find( - array( - 'select' => 'title', - 'condition' => 'postID=:postID', - 'params' => array(':postID' => 10), - ) -); -``` - -### 無名関数 - -以下のような無名関数 - -```php -$greet = function($name) { ... }; -``` - -これは現在、Imenuで`$greet`として表示します。 - -### Flymakeサポート - -カスタマイズ変数`php-executable`をセットすることで、コーディング中に警告とエラーをリアルタイムで見るためにFlymakeモードを有効にすることができます。 - -### ローカルのドキュメントを検索する - -コマンド`C-c C-f`でカーソル位置のシンボルをPHP公式サイトのドキュメントから検索できます。また、[ローカルにドキュメントをダウンロード](http://us2.php.net/download-docs.php)してあれば、それを優先します。`php-manual-path`をセットするだけです。もしローカルで発見できなければPHPのWebサイトにフォールバックします。 - -### 選択範囲内のコードを実行する - -`php-send-region`コマンド(デフォルトでは`C-c C-r`)はリージョンで選択された範囲のPHPコードを実行します。`C-x h`と組合せてコード全体を実行することもできます。出力は `*PHP*` バッファに現れます。 - -### PHPDoc タグ/アノテーション - -PHPDocは[JavaDoc](https://en.wikipedia.org/wiki/Javadoc)に似たドキュメンテーションの形式です。 - -`@param`, `@return`, `@var`... などの表記は**タグ**と呼ばれ、[list of tags defined by phpDocumentor2](https://phpdoc.org/docs/latest/references/phpdoc/tags/index.html)で定義されます。 (これらのタグはPhpStormや[Phan](https://github.com/etsy/phan)といった型チェッカーと互換性があります。) - -**アノテーション**と呼ばれる記法は部分的にサポートしています。アノテーションの文法はタグとは少し異なり、`@Annotation(attr1="vvv", attr2="zzz")` のような形式です。 - -[Symfony](https://symfony.com/)プロジェクトや[Go! AOP](https://github.com/goaop/framework)などいくつかのプロジェクト・フレームワークは[Doctrine Annotations](https://www.doctrine-project.org/projects/doctrine-annotations/en/latest/index.html)の文法を元にしています。 - -```php -/** - * Summary of Product class - * - * @copyright 2112 John Doe - * @license https://spdx.org/licenses/Apache-2.0.html Apache License 2.0 - * @ORM\Entity - * @ORM\Table(name="product") - */ -class Product -{ - /** - * @ORM\Id - * @ORM\Column(type="integer") - * @ORM\GeneratedValue(strategy="AUTO") - */ - protected $id; - - /** - * @ORM\Column(type="string", length=100) - */ - protected $name; - - /** - * @ORM\Column(type="decimal", scale=2) - */ - protected $price; - - /** - * @ORM\Column(type="text") - */ - protected $description; -} -``` - -アノテーションは `@` から始まる行で、わかりやすく強調表示されます。ただしPHPモードは[PSR-5: PHPDoc (草案)](https://github.com/phpDocumentor/fig-standards/blob/master/proposed/phpdoc.md)の完全なサポートは実装していません。我々は将来的にこれらの強調表示を厳密にサポートしたいと考えていますが、現在の実装は限定的です。詳しくは[#478](https://github.com/emacs-php/php-mode/issues/478)をご覧ください。 - -### コーディングスタイル - -PHPモードはデフォルトでは`php-enable-default-coding-style`関数で設定される合理的なインデントと整形スタイルを提供します。また、ほかの有用なコーディングスタイルも提供しているので、以下の関数を通じて設定することができます。 - -1. `php-enable-pear-coding-style` -2. `php-enable-drupal-coding-style` -3. `php-enable-wordpress-coding-style` -4. `php-enable-symfony2-coding-style` -5. `php-enable-psr2-coding-style` - -`M-x customize-group php`で‘PHP Mode Coding Style’を探してカスタマイズメニューを探して、デフォルトのコーディングスタイルの設定を有効化することができます。以下のように、コーディングスタイルごとにフックを有効化することもできます。 - -```lisp -(add-hook 'php-mode-hook 'php-enable-default-coding-style) -``` - -#### Symfony2 Style - -このスタイルではメソッドチェーンのインデントの継続とぶらさがったセミコロンを整形できます。 - - -```php - $user1 - ->setCreateDate(new \DateTime('2007-05-07 01:34:45')) - ->setLastDate(new \DateTime('2012-08-18 19:03:02')) - ->setUsername('jay') - ; -``` - -このスタイルはSymfony2のコードベースで広く利用されていますが、慣習についての文書で明示的に言及されているものではありません。 - -### HTMLテンプレートのサポートを無効化する - -多くの開発者はPHPモードで純粋なPHPスクリプト(HTMLテンプレートを含まないもの)を編集します。HTMLとの互換レイヤーはPHPモードの歴史的な機能ですが、完全には機能していません。速度の低下や強調表示を破壊するおそれがあるなどの副作用があります。変数`php-template-compatibility`を`nil`にセットすると、HTMLとの互換性を無効化することができます。HTMLやその他のマークアップ言語のテンプレートエンジンを含むPHPスクリプトを開発する際は[Web Mode][]は優れた選択肢です。 - -### Subword Mode - -GNU Emacsには[Subword Mode][]という機能があり、このマイナーモードは[キャメルケース][camelCase]の部分を別の単語のように移動することができます。たとえば、PHPモードはデフォルトでは変数`$fooBarBaz`を一つの単語として扱います。しかしSubword Modeを有効にすればEmacsはこの変数名を3つの単語として扱い、単語関係のコマンド(`M-f`, `M-b`, `M-d`など)はカーソル位置のキャメルケースの各部分に影響します。 - -もしPHPファイルで常にSubword Modeを有効化したいならば、以下のように設定できます。 - -```lisp -(add-hook 'php-mode-hook (lambda () (subword-mode 1))) -``` - -キーバインド `C-c C-w` はSubword Modeのオンとオフを切り替えます。 - -### 現在のclass/namespaceを挿入する - -```el -(with-eval-after-load 'php-mode - (define-key php-mode-map (kbd "C-c C--") 'php-current-class) - (define-key php-mode-map (kbd "C-c C-=") 'php-current-namespace)) -``` - -PHPプログラミングのためのパッケージ ----------------------------------- - -- 入力補完 - - [ac-php](https://github.com/xcwen/ac-php): [company-mode](https://github.com/company-mode/company-mode) and [auto-complete](https://github.com/auto-complete/auto-complete) for PHP -- 構文チェック - - [flycheck](https://github.com/flycheck/flycheck/): On the fly syntax checker - - [flymake-php](https://github.com/purcell/flymake-php): flymake for PHP files -- スニペット - - [php-auto-yasnippets](https://github.com/ejmr/php-auto-yasnippets): Dynamically Generated YASnippets for PHP Code -- ドキュメント - - [ggtags](https://github.com/leoliu/ggtags): eldoc by using GNU global tags - - [php-eldoc](https://github.com/sabof/php-eldoc): eldoc backend for PHP -- テスト - - [phpunit](https://github.com/nlamirault/phpunit.el): phpunit test command tool -- コーディングスタイル - - [phpcbf](https://github.com/nishimaki10/emacs-phpcbf): PHP_CodeSniffer for Emacs -- Semantic - - [ede-php-autoload](https://github.com/stevenremot/ede-php-autoload): Semantic for PHP -- フレームワーク - - [cake](https://github.com/k1LoW/emacs-cake): minor-mode for CakePHP - - [cake2](https://github.com/k1LoW/emacs-cake2): minor-mode for CakePHP2 +## 不具合を報告する +バグ報告の際には `M-x php-mode-debug` の出力を含めてください。この情報は問題の再現に役立ちます。 貢献するには ----------------- [CONTRIBUTING.md](CONTRIBUTING.md#japanese)をご覧ください。 -Wiki --------- - -GitHubのプロジェクトページには[wiki][]があり、自由に編集して構いません。このWikiには今後追加する計画のある機能やバグが掲載されています。また、PHPモードをより使いやすくするためのTipsを追加できます。 - ## 著作権 PHP Modeは[GNU General Public License Version 3][gpl-v3] (GPLv3) でライセンスされています。 @@ -342,31 +113,14 @@ PHP Modeは[GNU General Public License Version 3][gpl-v3] (GPLv3) でライセ [@haxney]: https://github.com/haxney [@turadg]: https://github.com/turadg [Authors]: https://github.com/emacs-php/php-mode/wiki/Authors -[Cask]: https://github.com/cask/cask [Contributors]: https://github.com/emacs-php/php-mode/graphs/contributors -[MELPA Stable]: https://stable.melpa.org/ -[MELPA]: https://melpa.org/ -[Subword Mode]: https://www.gnu.org/software/emacs/manual/html_node/ccmode/Subword-Movement.html [Supported Version]: https://github.com/emacs-php/php-mode/wiki/Supported-Version -[Web Mode]: http://web-mode.org/ -[camelCase]: https://ja.wikipedia.org/wiki/%E3%82%AD%E3%83%A3%E3%83%A1%E3%83%AB%E3%82%B1%E3%83%BC%E3%82%B9 -[cc mode]: https://www.gnu.org/software/emacs/manual/html_mono/ccmode.html -[elpa-php-mode]: https://packages.debian.org/sid/elpa-php-mode [gpl-v3]: https://www.gnu.org/licenses/quick-guide-gplv3.html -[issue-430]: https://github.com/emacs-php/php-mode/issues/430 -[nongnu-devel-elpa-badge]: https://elpa.nongnu.org/nongnu-devel/php-mode.svg -[nongnu-devel-elpa]: https://elpa.nongnu.org/nongnu-devel/php-mode.html [nongnu-elpa-badge]: https://elpa.nongnu.org/nongnu/php-mode.svg [nongnu-elpa]: https://elpa.nongnu.org/nongnu/php-mode.html [melpa-badge]: http://melpa.org/packages/php-mode-badge.svg +[melpa-getting-started]: https://melpa.org/#/getting-started [melpa-link]: http://melpa.org/#/php-mode -[melpa-stable-badge]: http://stable.melpa.org/packages/php-mode-badge.svg -[melpa-stable-link]: http://stable.melpa.org/#/php-mode -[package]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Packages.html -[php-elisp-stretch]: https://packages.debian.org/stretch/php-elisp -[php-elisp-ubuntu1810]: https://packages.ubuntu.com/cosmic/php-elisp -[php-mode-packages]: https://repology.org/project/emacs:php-mode/versions [php-mode]: https://github.com/emacs-php/php-mode -[php-suite]: https://github.com/emacs-php/php-suite [wiki]: https://github.com/emacs-php/php-mode/wiki -[wiki-manual-installation-ja]: https://github.com/emacs-php/php-mode/wiki/Manual-installation-ja +[wiki-manual-installation]: https://github.com/emacs-php/php-mode/wiki/Manual-installation-ja diff --git a/README.md b/README.md index 38180d97..38ef01b0 100644 --- a/README.md +++ b/README.md @@ -17,274 +17,68 @@ English   |   [日本語](README.ja.md) Please submit any bug reports or feature requests by creating issues on [the GitHub page for PHP Mode][php-mode]. -> **Note** +> [!NOTE] > The [latest version][releases] of PHP Mode supports Emacs 29.
Please feel free to [write to disucuss][disscussions-emacs29] if you have problems upgrading to Emacs 29. [releases]: https://github.com/emacs-php/php-mode/releases [disscussions-emacs29]: https://github.com/emacs-php/php-mode/discussions/751 -Installation ------------- +## Installation -**PHP Mode works on Emacs 26.1 or later.** PHP Mode may work with older versions of Emacs but this is not guaranteed. Bug reports for problems related to using PHP Mode with older versions of Emacs will most like *not* be addressed. +**PHP Mode works with Emacs 26.1 or later**. For details on supported versions, see [Supported Version]. Emacs 28 or later can be installed simply by running the following command. -The current support policy can be found on the [Supported Version] page. - -### **(RECOMMENDED)** Install from NonGNU ELPA - -[![NonGNU ELPA][nongnu-elpa-badge]][nongnu-elpa] [![NonGNU-devel ELPA][nongnu-devel-elpa-badge]][nongnu-devel-elpa] - -Emacs releases since version 28 have included [NonGNU ELPA](https://elpa.nongnu.org/) as the default package repository. - -### Install from MELPA - -[![melpa badge][melpa-badge]][melpa-link] [![melpa stable badge][melpa-stable-badge]][melpa-stable-link] - -With GNU Emacs 24 or later then you can use its [package][] feature (or [Cask][]) to install PHP Mode from [MELPA][] or [MELPA Stable][]. - -### Install using OS package system - -PHP Mode is available from [package systems provided by several OSs][php-mode-packages]. On Debian, and operating systems derived from it, such as Ubuntu, the easiest way to add PHP support to Emacs is `sudo apt install elpa-php-mode`. "Stable" releases of these operating systems include a well-tested frozen version of this package that is always older than the latest upstream version of PHP Mode. Autoloads and byte-compilation are automatic. - -Please consider installing the package provided in `sid` (aka: "unstable", a rolling release) in order to benefit from the latest PHP Mode features and performance improvements. The latest version can be found here: [`elpa-php-mode`][elpa-php-mode]. Investigate "apt-pinning" to make tracking this update stream automatic. - -### Manual installation - -If you don't want to depend on a package manager, you can install Lisp files directly in the traditional way. See [Manual installation][wiki-manual-installation] for our recommended setup method. - -### Configuration - -PHP Mode's default style might not be what you expect. Before filing a bug, please try the following: `C-h v php-mode-coding-style`, to get the list of available styles. Then use `M-x php-set-style` for each of these, to check to see if one of them is to your liking. Use `TODO: Please comment on what config method you'd like to recommend to users` - -Reporting Bugs --------------- - -When reporting a bug please run the function `M-x php-mode-debug` and include its output in your bug report. This helps up reproduce any problem you may have. - - -Experimental and In-Progress Features -------------------------------------- - -### CC Mode, CEDET, EDE, and Semantic - -In 2013 Daniel Haxney began rewriting parts of PHP Mode in terms of Emacs' built-in CC Mode. This laid the foundation for incorporating some of the inherit IDE-ish features of Emacs, such as CEDET, EDE, and Semantic. Support for these tools continues to improve thanks to the work of Andrea Turso, Steven Rémot, Joris Steyn, and others. If you wish to test, contribute to, or simply experiment with such features then [this thread is a good place to start](https://github.com/emacs-php/php-mode/issues/256). - -### PHP 7 Support - -PHP 7 has been released. PHP Mode supports the following features and changes from PHP 7: - -1. Type-hints for return values in functions and methods receive syntax highlighting in the same way as type-hints for function and method parameters. - -2. PHP Mode treats `yield from` as keyword in the same way it already does for a sole `yield`. - -3. It recognizes `strict_types` as a special declaration in the same way as `ticks`. - - -Features --------- - -### New Keywords - -Now PHP Mode supports syntax highlighting for new keywords which PHP 5.4 introduced, e.g. those related to traits, such as `insteadof`. Also supported are the older keywords `clone` and `default`. - -### Constants - -Syntax highlighting includes every magic constant and predefined constant listed on the official PHP site. However, some constants from specific extensions are not currently included. - -### Traits, Interfaces, and Namespaces - -Traits, interfaces, and namespaces now appear under Imenu listings. Fontification behaves properly for namespaces as well, so that code like `namespace Foo\Bar\Baz` no longer looks like a warning. This is also true for namespace aliases, e.g. `use as `; currently the aliased name is not listed in Imenu, but future versions will address this. - -### Treatment of Underscores - -PHP Mode treats underscores as ‘symbol constituents’ (in Emacs terminology) so that you can use keys like `M-f` and `M-b` to move through the individual parts of a variable name like `$foo_bar_baz`. - -### Chained Method Calls - -PHP Mode can align method calls over multiple lines anchored around the `->` operator, e.g.: - -```php -$object->foo() - ->bar() - ->baz(); -``` - -This behaviour is off by default, but you can customize the variable `php-mode-lineup-cascaded-calls` to enable this. - -**Note:** Alignment will only work if you use one of the php-mode coding styles or inherit one of the styles. - -### Nested Array Formatting - -Nested function calls and `array()` structures now look better by default (or at least in my opinion). Here is an example of the style: - -```php -$results = Post::model()->find( - array( - 'select' => 'title', - 'condition' => 'postID=:postID', - 'params' => array(':postID' => 10), - ) -); ``` - -### Anonymous Functions - -Anonymous functions such as - -```php -$greet = function($name) { ... }; -``` - -will now appear on Imenu; in this case the name will be `$greet`. - -### Flymake Support - -By customizing the variable `php-executable` you can enable Flymake mode in order to see warnings and errors in real-time as you write code. - -### Search Local Documentation - -The key command `C-c C-f` will search the PHP website for documentation on the word under the cursor. However, if you have a [local copy of the PHP documentation](http://us2.php.net/download-docs.php) then PHP Mode will try searching that documentation first. All you need to do is customize the variable `php-manual-path` and give it the path to your copy of the documentation. If PHP Mode cannot find something locally then it will still fallback on searching the PHP website. - -### Executing Regions of PHP - -The command `php-send-region`, which is bound to `C-c C-r` by default, will execute the selected region of PHP code. In conjunction with the Emacs command `C-x h` you can use this to execute an entire file. Any output will appear in a buffer called `*PHP*`. - -### PHPDoc Tag / Annotation Highlighting - -PHPDoc is a documentation format similar to [JavaDoc](https://en.wikipedia.org/wiki/Javadoc). - -There are `@param`, `@return`, `@var`... etc in the notation called **tag**, look at [list of tags defined by phpDocumentor2](https://phpdoc.org/docs/latest/references/phpdoc/tags/index.html). (These tags are compatible with static type checkers like PhpStorm and [Phan](https://github.com/etsy/phan).) - -In addition, it also partially supports notation called **annotation**. Annotation has a slightly different grammar from tag, and the example is `@Annotation(attr1="vvv", attr2="zzz")`. - -[Symfony](https://symfony.com/) project and [Go! AOP](https://github.com/goaop/framework) and some projects/frameworks use annotation grammer based on [Doctrine Annotations](https://www.doctrine-project.org/projects/doctrine-annotations/en/latest/index.html). - -```php -/** - * Summary of Product class - * - * @copyright 2112 John Doe - * @license https://spdx.org/licenses/Apache-2.0.html Apache License 2.0 - * @ORM\Entity - * @ORM\Table(name="product") - */ -class Product -{ - /** - * @ORM\Id - * @ORM\Column(type="integer") - * @ORM\GeneratedValue(strategy="AUTO") - */ - protected $id; - - /** - * @ORM\Column(type="string", length=100) - */ - protected $name; - - /** - * @ORM\Column(type="decimal", scale=2) - */ - protected $price; - - /** - * @ORM\Column(type="text") - */ - protected $description; -} +M-x package-install php-mode ``` -The annotations are the lines that begin with the `@` character, and PHP Mode will give these special highlighting to help them stand out. +By [adding MELPA to `package-archives`][melpa-getting-started], you can extend Emacs with many packages from the web. -PHP Mode has not fully supported [PSR-5: PHPDoc (Draft)](https://github.com/phpDocumentor/fig-standards/blob/master/proposed/phpdoc.md) yet. We want to support them, but the current implementation still limited. See issue [#478](https://github.com/emacs-php/php-mode/issues/478) for details. - -### Coding Styles +If you don't want to depend on a package manager, you can install Lisp files directly in the traditional way. See [Manual installation][wiki-manual-installation] for our recommended setup method. -By default PHP Mode tries to provide a reasonable style for indentation and formatting, which you can use via the function `php-enable-default-coding-style`. However, it provides other options suited for particular projects which you may find useful. Other coding styles are available through these functions: +## Configuration -1. `php-enable-pear-coding-style` -2. `php-enable-drupal-coding-style` -3. `php-enable-wordpress-coding-style` -4. `php-enable-symfony2-coding-style` -5. `php-enable-psr2-coding-style` +### Personal Settings -They will help format your code for PEAR/PSR-2 projects, or work on Drupal, WordPress, and Symfony2 software, respectively. You may enable any of them by default by running `M-x customize-group php` and looking for the ‘PHP Mode Coding Style’ option. You may also enable any of these via a hook, e.g. +You can add configurations for PHP mode in the .emacs file (`~/.emacs.d/init.el`): ```lisp -(add-hook 'php-mode-hook 'php-enable-default-coding-style) -``` - -#### Symfony2 Style - -With this style method call chains can be formatted with indented continuation and a hanging semi-colon: +(defun my-php-mode-init () + (subword-mode 1) + (setq-local show-trailing-whitespace t) + (setq-local ac-disable-faces '(font-lock-comment-face font-lock-string-face)) + (add-hook 'hack-local-variables-hook 'php-ide-turn-on nil t)) -```php - $user1 - ->setCreateDate(new \DateTime('2007-05-07 01:34:45')) - ->setLastDate(new \DateTime('2012-08-18 19:03:02')) - ->setUsername('jay') - ; +(with-eval-after-load 'php-mode + (add-hook 'php-mode-hook #'my-php-mode-init) + (custom-set-variables + '(php-mode-coding-style 'psr2) + '(php-mode-template-compatibility nil) + '(php-imenu-generic-expression 'php-imenu-generic-expression-simple)) + + ;; If you find phpcs to be bothersome, you can disable it. + (when (require 'flycheck nil) + (add-to-list 'flycheck-disabled-checkers 'php-phpmd) + (add-to-list 'flycheck-disabled-checkers 'php-phpcs))) ``` -This style is used widely throughout Symfony2 source code even if it is not explicitly mentioned in their conventions documents. - -### Avoid HTML Template Compatibility - -Many developers use PHP Mode to edit pure PHP scripts (e.g. files with only PHP and no HTML). A basic compatibility layer with HTML has historically been part of PHP Mode but it does not work perfectly and can cause some bad side effects such as slowness and incorrect font locking. Configuring the `php-template-compatibility` property with a `nil` will cancel any attempt of HTML compatibility. [Web Mode](http://web-mode.org/) is a great alternative to PHP Mode if you need to work with PHP scripts that do contain HTML and other markup. - -### Subword Mode - -GNU Emacs comes with [Subword Mode][], a minor mode that allows you to navigate the parts of a [camelCase][] as if they were separate words. For example, PHP Mode treats the variable `$fooBarBaz` as a whole name by default. But if you enable Subword Mode then Emacs will treat the variable name as three separate words, and therefore word-related commands (e.g. `M-f`, `M-b`, `M-d`) will only affect the camelCase part of the name under the cursor. +### Project Setting -If you want to always use Subword Mode for PHP files then you can add this to your Emacs configuration: +You can add project-specific settings by creating a `.dir-locals.el` or `.dir-locals-2.el` file in the project's root directory. It is recommended not to put these files under version control, as they depend on the packages installed in each user's Emacs. ```lisp -(add-hook 'php-mode-hook (lambda () (subword-mode 1))) +((nil + (php-project-root . git) + (php-project-coding-style . psr2))) ``` -The key-binding `C-c C-w` will also toggle Subword Mode on and off. +## Reporting Bugs -### Insert current class/namespace - -```el -(with-eval-after-load 'php-mode - (define-key php-mode-map (kbd "C-c C--") 'php-current-class) - (define-key php-mode-map (kbd "C-c C-=") 'php-current-namespace)) -``` +When reporting a bug please run the function `M-x php-mode-debug` and include its output in your bug report. This helps up reproduce any problem you may have. -Other Packages for PHP programming ----------------------------------- - -- Completions - - [ac-php](https://github.com/xcwen/ac-php): [company-mode](https://github.com/company-mode/company-mode) and [auto-complete](https://github.com/auto-complete/auto-complete) for PHP -- Syntax checking - - [flycheck](https://github.com/flycheck/flycheck/): On the fly syntax checker - - [flymake-php](https://github.com/purcell/flymake-php): flymake for PHP files -- Snippet - - [php-auto-yasnippets](https://github.com/ejmr/php-auto-yasnippets): Dynamically Generated YASnippets for PHP Code -- Documentation - - [ggtags](https://github.com/leoliu/ggtags): eldoc by using GNU global tags - - [php-eldoc](https://github.com/sabof/php-eldoc): eldoc backend for PHP -- Testing - - [phpunit](https://github.com/nlamirault/phpunit.el): phpunit test command tool -- Style - - [phpcbf](https://github.com/nishimaki10/emacs-phpcbf): PHP_CodeSniffer for Emacs -- Semantic - - [ede-php-autoload](https://github.com/stevenremot/ede-php-autoload): Semantic for PHP -- Framework - - [cake](https://github.com/k1LoW/emacs-cake): minor-mode for CakePHP - - [cake2](https://github.com/k1LoW/emacs-cake2): minor-mode for CakePHP2 - - -How to Contribute ------------------ +## How to Contribute Please see [CONTRIBUTING.md](CONTRIBUTING.md#english). -The Wiki --------- - -The GitHub project page has a [wiki][] that you should feel free to edit. The wiki lists the features and bugs that are on plan to include in upcoming versions of PHP Mode. It is also a place to add any tips to make the mode more useful. ## Copyright @@ -319,28 +113,14 @@ This project was maintained by [Eric James Michael Ritz][@ejmr] until 2017. Curr [@haxney]: https://github.com/haxney [@turadg]: https://github.com/turadg [Authors]: https://github.com/emacs-php/php-mode/wiki/Authors -[Cask]: https://github.com/cask/cask [Contributors]: https://github.com/emacs-php/php-mode/graphs/contributors -[MELPA Stable]: https://stable.melpa.org/ -[MELPA]: https://melpa.org/ -[Subword Mode]: https://www.gnu.org/software/emacs/manual/html_node/ccmode/Subword-Movement.html [Supported Version]: https://github.com/emacs-php/php-mode/wiki/Supported-Version -[Web Mode]: http://web-mode.org/ -[camelCase]: https://ja.wikipedia.org/wiki/%E3%82%AD%E3%83%A3%E3%83%A1%E3%83%AB%E3%82%B1%E3%83%BC%E3%82%B9 -[cc mode]: https://www.gnu.org/software/emacs/manual/html_mono/ccmode.html -[elpa-php-mode]: https://packages.debian.org/sid/elpa-php-mode [gpl-v3]: https://www.gnu.org/licenses/quick-guide-gplv3.html -[nongnu-devel-elpa-badge]: https://elpa.nongnu.org/nongnu-devel/php-mode.svg -[nongnu-devel-elpa]: https://elpa.nongnu.org/nongnu-devel/php-mode.html [nongnu-elpa-badge]: https://elpa.nongnu.org/nongnu/php-mode.svg [nongnu-elpa]: https://elpa.nongnu.org/nongnu/php-mode.html [melpa-badge]: http://melpa.org/packages/php-mode-badge.svg +[melpa-getting-started]: https://melpa.org/#/getting-started [melpa-link]: http://melpa.org/#/php-mode -[melpa-stable-badge]: http://stable.melpa.org/packages/php-mode-badge.svg -[melpa-stable-link]: http://stable.melpa.org/#/php-mode -[package]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Packages.html -[php-mode-packages]: https://repology.org/project/emacs:php-mode/versions [php-mode]: https://github.com/emacs-php/php-mode -[php-suite]: https://github.com/emacs-php/php-suite [wiki]: https://github.com/emacs-php/php-mode/wiki [wiki-manual-installation]: https://github.com/emacs-php/php-mode/wiki/Manual-installation From c0ff815afafc4de661addfee884c357c6fb42f1d Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 20 Nov 2023 04:00:17 +0900 Subject: [PATCH 074/125] Update mailmap --- .mailmap | 1 + 1 file changed, 1 insertion(+) diff --git a/.mailmap b/.mailmap index a2d4abff..1c9c3d6f 100644 --- a/.mailmap +++ b/.mailmap @@ -1,5 +1,6 @@ Elis Axelsson Elis David Arroyo Menéndez David Arroyo7 +Jen-Chieh Shen JenChieh Joe Wreschnig Joe Jon Dufresne Jon Dufrense Syohei YOSHIDA Shohei YOSHIDA From 31f44192e0c5c0195ad2742e70ddec41488e2ffa Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Fri, 24 Nov 2023 05:08:33 +0900 Subject: [PATCH 075/125] Remove Keg and Cask metadata files for building --- CHANGELOG.md | 2 ++ Cask | 25 ------------------------- Keg | 10 ---------- 3 files changed, 2 insertions(+), 35 deletions(-) delete mode 100644 Cask delete mode 100644 Keg diff --git a/CHANGELOG.md b/CHANGELOG.md index b96f30ec..4d811d41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,11 +15,13 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this ### Removed * Removed Phan-specific features from `php-project` ([#754]) + * Removed [Cask](https://cask.readthedocs.io/) and [Keg](https://github.com/conao3/keg.el) metadata files for building ([#770]) [#754]: https://github.com/emacs-php/php-mode/pull/754 [#764]: https://github.com/emacs-php/php-mode/issues/764 [#766]: https://github.com/emacs-php/php-mode/pull/766 [#767]: https://github.com/emacs-php/php-mode/pull/767 +[#770]: https://github.com/emacs-php/php-mode/pull/770 ## [1.25.0] - 2023-07-24 diff --git a/Cask b/Cask deleted file mode 100644 index 7b327b34..00000000 --- a/Cask +++ /dev/null @@ -1,25 +0,0 @@ -(package "php-mode" "1.25.0" "Major mode for editing PHP code") -(source melpa) -(source gnu) - -(package-file "lisp/php-mode.el") - -(files - "lisp/php.el" - "lisp/php-complete.el" - "lisp/php-defs.el" - "lisp/php-face.el" - "lisp/php-format.el" - "lisp/php-project.el" - "lisp/php-local-manual.el" - "lisp/php-ide-phpactor.el" - "lisp/php-ide.el" - "lisp/php-mode-debug.el") - -(development - ;;(depends-on "lsp-mode") - (depends-on "phpactor") - (depends-on "pkg-info") - (depends-on "projectile") - (depends-on "smart-jump") - (depends-on "shut-up")) diff --git a/Keg b/Keg deleted file mode 100644 index f08e89ed..00000000 --- a/Keg +++ /dev/null @@ -1,10 +0,0 @@ -(source gnu melpa) - -(package - (php-mode - (recipe . (php-mode :fetcher github :repo "emacs-php/php-mode.el" - :files (:defaults "lisp/*.el"))))) - -(dev-dependency pkg-info) -(dev-dependency projectile) -(dev-dependency shut-up) From 3fbe2eada05c370f3e75ed07b55be0c34031a027 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Fri, 24 Nov 2023 04:52:18 +0900 Subject: [PATCH 076/125] Update CHANGELOG --- CHANGELOG.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d811d41..3ffd2693 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,15 +2,24 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles. -## Unreleased + + +## [1.25.1] - 2023-11-24 ### Added * Add `php-topsy-beginning-of-defun-with-class` to display classname with function signature. ([#766]) + * Add missing `__DIR__` to `php-magical-constants` ([#756], thanks [@piotrkwiecinski]) + +### Changed + + * Make developer build task in Makefile now depends on Eask. ([#762], thanks [@jcs090218]) + * This change does not affect package installation users + * Read [CONTRIBUTING.md] if you prefer to build it yourself from zip or tar ball ### Fixed - * Fixed build failure in Emacs on master branch ([#764], [#767]) + * Fixed build failure in Emacs on master branch ([#764], [#765], [#767], thanks [@takeokunn]) ### Removed @@ -18,10 +27,17 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this * Removed [Cask](https://cask.readthedocs.io/) and [Keg](https://github.com/conao3/keg.el) metadata files for building ([#770]) [#754]: https://github.com/emacs-php/php-mode/pull/754 +[#756]: https://github.com/emacs-php/php-mode/pull/756 +[#762]: https://github.com/emacs-php/php-mode/pull/762 [#764]: https://github.com/emacs-php/php-mode/issues/764 +[#765]: https://github.com/emacs-php/php-mode/pull/765 [#766]: https://github.com/emacs-php/php-mode/pull/766 [#767]: https://github.com/emacs-php/php-mode/pull/767 [#770]: https://github.com/emacs-php/php-mode/pull/770 +[@jcs090218]: https://github.com/jcs090218 +[@piotrkwiecinski]: https://github.com/piotrkwiecinski +[@takeokunn]: https://github.com/takeokunn +[CONTRIBUTING.md]: https://github.com/emacs-php/php-mode/blob/master/CONTRIBUTING.md ## [1.25.0] - 2023-07-24 From 88a2a742d9e76fcad3ed088fd53b9ba2be4b05f5 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Fri, 24 Nov 2023 05:07:41 +0900 Subject: [PATCH 077/125] Fix link to gpl-v3 --- README.ja.md | 4 ++-- README.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.ja.md b/README.ja.md index 54b6ba7d..f6c61ba1 100644 --- a/README.ja.md +++ b/README.ja.md @@ -5,7 +5,7 @@ [![lang: PHP 8.2](https://img.shields.io/badge/lang-PHP%208.2-brightgreen.svg)](https://php.net/manual/migration82.php) [![lang: PHP 7](https://img.shields.io/badge/lang-PHP%207-green.svg)](https://php.net/downloads.php) [![Build Status](https://github.com/emacs-php/php-mode/workflows/CI/badge.svg)](https://github.com/emacs-php/php-mode/actions) -[![GPL v3](https://img.shields.io/badge/license-GPL_v3-green.svg)](http://www.gnu.org/licenses/gpl-3.0.txt)
+[![GPL v3](https://img.shields.io/badge/license-GPL_v3-green.svg)][gpl-v3]
[![NonGNU ELPA][nongnu-elpa-badge]][nongnu-elpa] [![melpa badge][melpa-badge]][melpa-link] @@ -115,7 +115,7 @@ PHP Modeは[GNU General Public License Version 3][gpl-v3] (GPLv3) でライセ [Authors]: https://github.com/emacs-php/php-mode/wiki/Authors [Contributors]: https://github.com/emacs-php/php-mode/graphs/contributors [Supported Version]: https://github.com/emacs-php/php-mode/wiki/Supported-Version -[gpl-v3]: https://www.gnu.org/licenses/quick-guide-gplv3.html +[gpl-v3]: https://www.gnu.org/licenses/gpl-3.0 [nongnu-elpa-badge]: https://elpa.nongnu.org/nongnu/php-mode.svg [nongnu-elpa]: https://elpa.nongnu.org/nongnu/php-mode.html [melpa-badge]: http://melpa.org/packages/php-mode-badge.svg diff --git a/README.md b/README.md index 38ef01b0..f02e9428 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![lang: PHP 8.2](https://img.shields.io/badge/lang-PHP%208.2-brightgreen.svg)](https://php.net/manual/migration82.php) [![lang: PHP 7](https://img.shields.io/badge/lang-PHP%207-green.svg)](https://php.net/downloads.php) [![Build Status](https://github.com/emacs-php/php-mode/workflows/CI/badge.svg)](https://github.com/emacs-php/php-mode/actions) -[![GPL v3](https://img.shields.io/badge/license-GPL_v3-green.svg)](http://www.gnu.org/licenses/gpl-3.0.txt)
+[![GPL v3](https://img.shields.io/badge/license-GPL_v3-green.svg)][gpl-v3]
[![NonGNU ELPA][nongnu-elpa-badge]][nongnu-elpa] [![melpa badge][melpa-badge]][melpa-link] @@ -115,7 +115,7 @@ This project was maintained by [Eric James Michael Ritz][@ejmr] until 2017. Curr [Authors]: https://github.com/emacs-php/php-mode/wiki/Authors [Contributors]: https://github.com/emacs-php/php-mode/graphs/contributors [Supported Version]: https://github.com/emacs-php/php-mode/wiki/Supported-Version -[gpl-v3]: https://www.gnu.org/licenses/quick-guide-gplv3.html +[gpl-v3]: https://www.gnu.org/licenses/gpl-3.0 [nongnu-elpa-badge]: https://elpa.nongnu.org/nongnu/php-mode.svg [nongnu-elpa]: https://elpa.nongnu.org/nongnu/php-mode.html [melpa-badge]: http://melpa.org/packages/php-mode-badge.svg From 6ad1715ef0aed463ab05076dc7c91657978e4ec1 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Fri, 24 Nov 2023 04:55:02 +0900 Subject: [PATCH 078/125] Bump up version 1.25.1 --- Eask | 2 +- lisp/php-align.el | 2 +- lisp/php-complete.el | 2 +- lisp/php-defs.el | 2 +- lisp/php-face.el | 2 +- lisp/php-flymake.el | 2 +- lisp/php-ide-phpactor.el | 2 +- lisp/php-ide.el | 2 +- lisp/php-mode-debug.el | 2 +- lisp/php-mode.el | 4 ++-- lisp/php-project.el | 2 +- lisp/php.el | 2 +- 12 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Eask b/Eask index 5c0a8558..23cc3463 100644 --- a/Eask +++ b/Eask @@ -1,5 +1,5 @@ (package "php-mode" - "1.25.0" + "1.25.1" "Major mode for editing PHP code") (website-url "https://github.com/emacs-php/php-mode") diff --git a/lisp/php-align.el b/lisp/php-align.el index 2615495f..de4fe3cf 100644 --- a/lisp/php-align.el +++ b/lisp/php-align.el @@ -7,7 +7,7 @@ ;; Maintainer: USAMI Kenta ;; Keywords: php languages convenience align ;; Homepage: https://github.com/emacs-php/php-mode -;; Version: 1.25.0 +;; Version: 1.25.1 ;; License: GPL-3.0-or-later ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-complete.el b/lisp/php-complete.el index 605f4626..28ac52fe 100644 --- a/lisp/php-complete.el +++ b/lisp/php-complete.el @@ -6,7 +6,7 @@ ;; Author: USAMI Kenta ;; Created: 18 Sep 2022 -;; Version: 1.25.0 +;; Version: 1.25.1 ;; Keywords: languages, php ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-defs.el b/lisp/php-defs.el index 810e26f1..37bd682d 100644 --- a/lisp/php-defs.el +++ b/lisp/php-defs.el @@ -4,7 +4,7 @@ ;; Author: USAMI Kenta ;; Created: 5 Mar 2022 -;; Version: 1.25.0 +;; Version: 1.25.1 ;; Keywords: languages, php ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-face.el b/lisp/php-face.el index a9ce85f9..70db33e0 100644 --- a/lisp/php-face.el +++ b/lisp/php-face.el @@ -4,7 +4,7 @@ ;; Author: USAMI Kenta ;; Created: 5 May 2019 -;; Version: 1.25.0 +;; Version: 1.25.1 ;; Keywords: faces, php ;; Homepage: https://github.com/emacs-php/php-mode ;; License: GPL-3.0-or-later diff --git a/lisp/php-flymake.el b/lisp/php-flymake.el index a55a22a8..37e4aea4 100644 --- a/lisp/php-flymake.el +++ b/lisp/php-flymake.el @@ -4,7 +4,7 @@ ;; Author: USAMI Kenta ;; Created: 5 Mar 2022 -;; Version: 1.25.0 +;; Version: 1.25.1 ;; Keywords: tools, languages, php ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-ide-phpactor.el b/lisp/php-ide-phpactor.el index ff9b8d78..831f49be 100644 --- a/lisp/php-ide-phpactor.el +++ b/lisp/php-ide-phpactor.el @@ -5,7 +5,7 @@ ;; Author: USAMI Kenta ;; Keywords: tools, files ;; URL: https://github.com/emacs-php/php-mode -;; Version: 1.25.0 +;; Version: 1.25.1 ;; License: GPL-3.0-or-later ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-ide.el b/lisp/php-ide.el index 26c8fd7e..9f63cdee 100644 --- a/lisp/php-ide.el +++ b/lisp/php-ide.el @@ -5,7 +5,7 @@ ;; Author: USAMI Kenta ;; Keywords: tools, files ;; URL: https://github.com/emacs-php/php-mode -;; Version: 1.25.0 +;; Version: 1.25.1 ;; License: GPL-3.0-or-later ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-mode-debug.el b/lisp/php-mode-debug.el index 45262531..a3e2d1da 100644 --- a/lisp/php-mode-debug.el +++ b/lisp/php-mode-debug.el @@ -5,7 +5,7 @@ ;; Author: USAMI Kenta ;; URL: https://github.com/emacs-php/php-mode ;; Keywords: maint -;; Version: 1.25.0 +;; Version: 1.25.1 ;; License: GPL-3.0-or-later ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-mode.el b/lisp/php-mode.el index efcdd2a3..022b2a62 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -9,13 +9,13 @@ ;; Maintainer: USAMI Kenta ;; URL: https://github.com/emacs-php/php-mode ;; Keywords: languages php -;; Version: 1.25.0 +;; Version: 1.25.1 ;; Package-Requires: ((emacs "26.1")) ;; License: GPL-3.0-or-later (eval-and-compile (make-obsolete-variable - (defconst php-mode-version-number "1.25.0" "PHP Mode version number.") + (defconst php-mode-version-number "1.25.1" "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 diff --git a/lisp/php-project.el b/lisp/php-project.el index 55a45ec2..6d20e455 100644 --- a/lisp/php-project.el +++ b/lisp/php-project.el @@ -5,7 +5,7 @@ ;; Author: USAMI Kenta ;; Keywords: tools, files ;; URL: https://github.com/emacs-php/php-mode -;; Version: 1.25.0 +;; Version: 1.25.1 ;; License: GPL-3.0-or-later ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php.el b/lisp/php.el index 7188c0c6..3c5f3490 100644 --- a/lisp/php.el +++ b/lisp/php.el @@ -5,7 +5,7 @@ ;; Author: USAMI Kenta ;; Created: 5 Dec 2018 -;; Version: 1.25.0 +;; Version: 1.25.1 ;; Keywords: languages, php ;; Homepage: https://github.com/emacs-php/php-mode ;; License: GPL-3.0-or-later From f7beda8e0a3a508af71e43bcc2ccf796c49ab31e Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sun, 26 Nov 2023 08:37:33 +0900 Subject: [PATCH 079/125] Update full copy of GPL Version 3 https://www.gnu.org/licenses/gpl-3.0.txt --- LICENSE | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/LICENSE b/LICENSE index 94a9ed02..f288702d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found. 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 . + along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. @@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see -. +. The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read -. +. From 0b598a96760bfc09c29984fe1ca7d7ac660caa98 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Wed, 29 Nov 2023 02:37:19 +0900 Subject: [PATCH 080/125] Add php-base-mode for common parent mode for php editing modes --- CHANGELOG.md | 9 ++++++++- lisp/php.el | 9 +++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ffd2693..62f59096 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,14 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles. - +## Unreleased + +### Added + + * Add `php-base-mode` which is the base of php related modes ([#772]) + * `php-base-mode` is designed as a common parent mode for `php-mode` and [`php-ts-mode`](https://github.com/emacs-php/php-ts-mode). + +[#772]: https://github.com/emacs-php/php-mode/pull/772 ## [1.25.1] - 2023-11-24 diff --git a/lisp/php.el b/lisp/php.el index 3c5f3490..8fa7a6d5 100644 --- a/lisp/php.el +++ b/lisp/php.el @@ -627,6 +627,15 @@ Look at the `php-executable' variable instead of the constant \"php\" command." (setq mode nil))) (or mode php-default-major-mode))) +;;;###autoload +(define-derived-mode php-base-mode prog-mode "PHP" + "Generic major mode for editing PHP. + +This mode is intended to be inherited by concrete major modes. +Currently there are `php-mode' and `php-ts-mode'." + :group 'php + nil) + ;;;###autoload (defun php-mode-maybe () "Select PHP mode or other major mode." From 52f82976069d002d8be10bd17b1cf476f83811d3 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Wed, 29 Nov 2023 02:38:15 +0900 Subject: [PATCH 081/125] Make php-mode inherit from php-base-mode instead of c-mode --- CHANGELOG.md | 4 ++++ lisp/php-mode.el | 19 ++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62f59096..649c8132 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this * Add `php-base-mode` which is the base of php related modes ([#772]) * `php-base-mode` is designed as a common parent mode for `php-mode` and [`php-ts-mode`](https://github.com/emacs-php/php-ts-mode). +### Changed + + * Make `php-mode` inherit from `php-base-mode` instead of `c-mode` ([#772]) + [#772]: https://github.com/emacs-php/php-mode/pull/772 ## [1.25.1] - 2023-11-24 diff --git a/lisp/php-mode.el b/lisp/php-mode.el index 022b2a62..e19faea8 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -327,6 +327,7 @@ as a function. Call with AS-NUMBER keyword to compare by `version<'. (defvar php-mode-map (let ((map (make-sparse-keymap "PHP Mode"))) + (set-keymap-parent map c-mode-base-map) ;; Remove menu item for c-mode (define-key map [menu-bar C] nil) @@ -1150,14 +1151,14 @@ After setting the stylevars run hook `php-mode-STYLENAME-hook'." table)) ;;;###autoload -(define-derived-mode php-mode c-mode "PHP" +(define-derived-mode php-mode php-base-mode "PHP" "Major mode for editing PHP code. \\{php-mode-map}" :syntax-table php-mode-syntax-table - ;; :after-hook (c-update-modeline) - ;; (setq abbrev-mode t) - + :after-hook (progn (c-make-noise-macro-regexps) + (c-make-macro-with-semi-re) + (c-update-modeline)) (unless (string= php-mode-cc-version c-version) (php-mode-debug-reinstall nil)) @@ -1168,8 +1169,16 @@ After setting the stylevars run hook `php-mode-STYLENAME-hook'." :warning)) (c-initialize-cc-mode t) + (setq abbrev-mode t) + + ;; Must be called once as c-mode to enable font-lock for Heredoc. + ;; TODO: This call may be removed in the future. + (c-common-init 'c-mode) + (c-init-language-vars php-mode) (c-common-init 'php-mode) + (cc-imenu-init cc-imenu-c-generic-expression) + (setq-local c-auto-align-backslashes nil) (setq-local comment-start "// ") @@ -1252,7 +1261,7 @@ After setting the stylevars run hook `php-mode-STYLENAME-hook'." (advice-add 'acm-backend-tabnine-candidate-expand :filter-args #'php-acm-backend-tabnine-candidate-expand-filter-args) - (when (>= emacs-major-version 25) + (when (eval-when-compile (>= emacs-major-version 25)) (with-silent-modifications (save-excursion (let* ((start (point-min)) From 7d740e7e5197266b78306d0c4e0da4aac2d2ad75 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Wed, 29 Nov 2023 03:09:57 +0900 Subject: [PATCH 082/125] Fix code style --- lisp/php.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/php.el b/lisp/php.el index 8fa7a6d5..32142cb0 100644 --- a/lisp/php.el +++ b/lisp/php.el @@ -674,7 +674,9 @@ Currently there are `php-mode' and `php-ts-mode'." "Return function signature and class name string for header line in topsy. You can add the function to topsy with the code below: - \(add-to-list 'topsy-mode-functions '\(php-mode . php-topsy-beginning-of-defun-with-class\)\)" + + (add-to-list \\='topsy-mode-functions + \\='(php-mode . php-topsy-beginning-of-defun-with-class))" (save-excursion (goto-char (window-start)) (mapconcat From e22166bbc9ae89dc97e4f0337a68e5babb02821e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Dec 2023 17:44:31 +0000 Subject: [PATCH 083/125] Bump actions/setup-python from 4 to 5 Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bfe04578..64071bf4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,7 +36,7 @@ jobs: emacs-version: snapshot experimental: true steps: - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: '3.11' architecture: 'x64' From de19a9063c6b4b5f940ed71ea1dcb62f4f21aeed Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sun, 17 Dec 2023 18:09:03 +0900 Subject: [PATCH 084/125] Remove php-mode-disable-c-mode-hook custom variable --- CHANGELOG.md | 6 ++++++ lisp/php-mode.el | 20 -------------------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 649c8132..87a6d404 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,13 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this * Make `php-mode` inherit from `php-base-mode` instead of `c-mode` ([#772]) +### Removed + + * Remove `php-mode-disable-c-mode-hook` custom variable and `php-mode-neutralize-cc-mode-effect` function ([#775]) + * `php-mode` no longer inherits `c-mode`, so this variable won't work. + [#772]: https://github.com/emacs-php/php-mode/pull/772 +[#775]: https://github.com/emacs-php/php-mode/pull/775 ## [1.25.1] - 2023-11-24 diff --git a/lisp/php-mode.el b/lisp/php-mode.el index e19faea8..94983369 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -292,13 +292,6 @@ In that case set to `NIL'." :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')." - :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." :tag "PHP Mode Enable Project Local Variable" @@ -1132,13 +1125,6 @@ After setting the stylevars run hook `php-mode-STYLENAME-hook'." (php-project-apply-local-variables) (remove-hook 'hack-local-variables-hook #'php-mode-set-local-variable-delay)) -(defun php-mode-neutralize-cc-mode-effect () - "Reset PHP-irrelevant variables set by Cc Mode initialization." - (setq-local c-mode-hook nil) - (setq-local java-mode-hook nil) - (remove-hook 'flymake-diagnostic-functions 'flymake-cc t) - t) - (defvar php-mode-syntax-table (let ((table (make-syntax-table))) (c-populate-syntax-table table) @@ -1162,12 +1148,6 @@ After setting the stylevars run hook `php-mode-STYLENAME-hook'." (unless (string= php-mode-cc-version c-version) (php-mode-debug-reinstall nil)) - (if php-mode-disable-c-mode-hook - (php-mode-neutralize-cc-mode-effect) - (display-warning 'php-mode - "`php-mode-disable-c-mode-hook' will be removed. Do not depends on this variable." - :warning)) - (c-initialize-cc-mode t) (setq abbrev-mode t) From 2a52f9789e9ad413bd4788bf4fda2ae7312375af Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sun, 17 Dec 2023 19:03:09 +0900 Subject: [PATCH 085/125] Ignore "dependabot" from AUTHORS.md --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 52665554..9b722e9b 100644 --- a/Makefile +++ b/Makefile @@ -14,8 +14,10 @@ AUTHORS.md: etc/git/AUTHORS.md.in .mailmap @printf "Generating AUTHORS.md file..." @test -d .git \ && (cat $< > $@ \ - && git log --pretty=format:'- %aN' | \ - cat etc/git/former-contributors - | LANG=C sort -u >> $@ \ + && git log --pretty=format:'- %aN' \ + | cat etc/git/former-contributors - \ + | grep -v dependabot \ + | LANG=C sort -u >> $@ \ && cat etc/git/AUTHORS2.md.in >> $@ \ && printf "FINISHED\n" ; ) \ || printf "FAILED (non-fatal)\n" From c6efeaada6911ee95ce81ec509c07400268f1d20 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sun, 17 Dec 2023 20:17:45 +0900 Subject: [PATCH 086/125] Modify overindentation for PEAR style --- CHANGELOG.md | 9 +++++++++ lisp/php-mode.el | 2 +- tests/{ => indent}/issue-227.php | 2 +- tests/indent/issue-774.php | 11 +++++++++++ tests/php-mode-test.el | 10 +++++----- 5 files changed, 27 insertions(+), 7 deletions(-) rename tests/{ => indent}/issue-227.php (77%) create mode 100644 tests/indent/issue-774.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 87a6d404..11708e02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,14 +12,23 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this ### Changed * Make `php-mode` inherit from `php-base-mode` instead of `c-mode` ([#772]) + * Modify indentation of [PEAR Coding Standards] ([#774], [#777]) + * No longer overindent it by default, since we don't see any mention in the coding style that it should hang `.`. (refs [#227] and [#229]) + * **If you have any feedback on PEAR style, please let us know in [the discussion #776][#776].** ### Removed * Remove `php-mode-disable-c-mode-hook` custom variable and `php-mode-neutralize-cc-mode-effect` function ([#775]) * `php-mode` no longer inherits `c-mode`, so this variable won't work. +[#227]: https://github.com/emacs-php/php-mode/pull/227 +[#229]: https://github.com/emacs-php/php-mode/pull/229 [#772]: https://github.com/emacs-php/php-mode/pull/772 +[#774]: https://github.com/emacs-php/php-mode/issues/774 [#775]: https://github.com/emacs-php/php-mode/pull/775 +[#776]: https://github.com/emacs-php/php-mode/discussions/776 +[#777]: https://github.com/emacs-php/php-mode/pull/777 +[PEAR Coding Standards]: https://pear.php.net/manual/en/standards.php ## [1.25.1] - 2023-11-24 diff --git a/lisp/php-mode.el b/lisp/php-mode.el index 94983369..5a6b887d 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -709,7 +709,7 @@ a backward search limit." "pear" '("php" (c-basic-offset . 4) - (c-offsets-alist . ((case-label . 0))) + (c-offsets-alist . ((case-label . 0) (statement-cont . +))) (tab-width . 4) (php-mode-lineup-cascaded-calls . nil))) diff --git a/tests/issue-227.php b/tests/indent/issue-227.php similarity index 77% rename from tests/issue-227.php rename to tests/indent/issue-227.php index daf9200f..6f3c83f8 100644 --- a/tests/issue-227.php +++ b/tests/indent/issue-227.php @@ -8,5 +8,5 @@ function my_func() { return "a really long string with = inside " . -"some more text"; // ###php-mode-test### ((indent 49)) +"some more text"; // ###php-mode-test### ((indent 8)) } diff --git a/tests/indent/issue-774.php b/tests/indent/issue-774.php new file mode 100644 index 00000000..118cfc06 --- /dev/null +++ b/tests/indent/issue-774.php @@ -0,0 +1,11 @@ +someFunction("some", "parameter") // ###php-mode-test### ((indent 0)) + ->someOtherFunc(23, 42) // ###php-mode-test### ((indent 4)) + ->andAThirdFunction(); // ###php-mode-test### ((indent 4)) + +$result = DateTime::createFromFormat('Y-m-d', '2112-09-03') // ###php-mode-test### ((indent 0)) + ->someFunction(); // ###php-mode-test### ((indent 4)) + +$pages = $dbOld->createQueryBuilder() // ###php-mode-test### ((indent 0)) + ->select('*'); // ###php-mode-test### ((indent 4)) diff --git a/tests/php-mode-test.el b/tests/php-mode-test.el index 3590ba49..dde44c7f 100644 --- a/tests/php-mode-test.el +++ b/tests/php-mode-test.el @@ -522,11 +522,6 @@ style from Drupal." (search-forward "return") (should (eq (current-indentation) (* 2 c-basic-offset))))) -(ert-deftest php-mode-test-issue-227 () - "multi-line strings indents " - (custom-set-variables '(php-lineup-cascaded-calls t)) - (with-php-mode-test ("issue-227.php" :indent t :style pear :magic t))) - (ert-deftest php-mode-test-issue-237 () "Indent chaining method for PSR2." (with-php-mode-test ("issue-237.php" :indent t :style psr2 :magic t))) @@ -696,6 +691,11 @@ Meant for `php-mode-test-issue-503'." (with-php-mode-test ("lang/errorcontrol.php" :faces t)) (with-php-mode-test ("lang/magical-constants/echo.php" :faces t))) +(ert-deftest php-mode-test-pear () + "Tests for PEAR style." + (with-php-mode-test ("indent/issue-227.php" :indent t :magic t :style pear)) + (with-php-mode-test ("indent/issue-774.php" :indent t :magic t :style pear))) + ;; For developers: How to make .faces list file. ;; ;; 1. Press `M-x eval-buffer' in this file bufffer. From 6d197a9209104914c5a9c8ae35d977beed959ae6 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Thu, 18 Jan 2024 23:53:09 +0900 Subject: [PATCH 087/125] Simplify :safe function for php-ide-mode-functions --- lisp/php-ide.el | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lisp/php-ide.el b/lisp/php-ide.el index 9f63cdee..f73d5bc3 100644 --- a/lisp/php-ide.el +++ b/lisp/php-ide.el @@ -178,6 +178,7 @@ :type 'string :safe #'stringp) +;;;###autoload (defcustom php-ide-mode-functions nil "Hook functions called when before activating or deactivating PHP-IDE. Notice that two arguments (FEATURE ACTIVATE) are given. @@ -188,9 +189,7 @@ ACTIVATE: T is given when activeting, NIL when deactivating PHP-IDE." :group 'php-ide :type '(repeat function) :safe (lambda (functions) - (and (listp functions) - (cl-loop for function in functions - always (functionp function))))) + (and (listp functions) (cl-every #'functionp functions)))) ;;;###autoload (define-minor-mode php-ide-mode From f0a14387427244251883889ba616c7f042323f6d Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Thu, 18 Jan 2024 23:58:18 +0900 Subject: [PATCH 088/125] Add @phpstan-require-extends and @phpstan-require-implements tag --- lisp/php-mode.el | 1 + 1 file changed, 1 insertion(+) diff --git a/lisp/php-mode.el b/lisp/php-mode.el index 5a6b887d..d66cf0af 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -1320,6 +1320,7 @@ for \\[find-tag] (which see)." "return" "throws" "var" "self-out" "this-out" "param-out" "type" "extends" "require-extends" "implemtents" "require-implements" "template" "template-covariant" "template-extends" "template-implements" + "require-extends" "require-implements" "assert" "assert-if-true" "assert-if-false" "if-this-is") "A list of tags specifying type names.") From c06bd688ca1a6ff0383a7b5d97c5891354a1f3de Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Sat, 20 Jan 2024 01:34:57 -0800 Subject: [PATCH 089/125] chore: Test 29.2 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 64071bf4..c2db6011 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,7 +23,7 @@ jobs: - "26.3" - "27.2" - "28.2" - - "29.1" + - "29.2" experimental: [false] include: - os: ubuntu-latest From 4fbf4ebdae100538eb8493147c2385c55e32fcb0 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 29 Jan 2024 00:41:14 +0900 Subject: [PATCH 090/125] Update Emacs 29.2 badge --- README.ja.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.ja.md b/README.ja.md index f6c61ba1..27e6a871 100644 --- a/README.ja.md +++ b/README.ja.md @@ -1,7 +1,7 @@

Emacs PHP Mode

-[![Emacs: 29.1](https://img.shields.io/badge/Emacs-29.1-blue.svg)](https://www.gnu.org/software/emacs/) +[![Emacs: 29.2](https://img.shields.io/badge/Emacs-29.2-blue.svg)](https://www.gnu.org/software/emacs/) [![lang: PHP 8.2](https://img.shields.io/badge/lang-PHP%208.2-brightgreen.svg)](https://php.net/manual/migration82.php) [![lang: PHP 7](https://img.shields.io/badge/lang-PHP%207-green.svg)](https://php.net/downloads.php) [![Build Status](https://github.com/emacs-php/php-mode/workflows/CI/badge.svg)](https://github.com/emacs-php/php-mode/actions) diff --git a/README.md b/README.md index f02e9428..91a00e0b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

Emacs PHP Mode

-[![Emacs: 29.1](https://img.shields.io/badge/Emacs-29.1-blue.svg)](https://www.gnu.org/software/emacs/) +[![Emacs: 29.2](https://img.shields.io/badge/Emacs-29.2-blue.svg)](https://www.gnu.org/software/emacs/) [![lang: PHP 8.2](https://img.shields.io/badge/lang-PHP%208.2-brightgreen.svg)](https://php.net/manual/migration82.php) [![lang: PHP 7](https://img.shields.io/badge/lang-PHP%207-green.svg)](https://php.net/downloads.php) [![Build Status](https://github.com/emacs-php/php-mode/workflows/CI/badge.svg)](https://github.com/emacs-php/php-mode/actions) From a0bcafbe30494b2c5a70c2fe05f2bb0859e83645 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 29 Jan 2024 00:45:13 +0900 Subject: [PATCH 091/125] Update PHP 8.3 badge --- README.ja.md | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.ja.md b/README.ja.md index 27e6a871..5c0dd082 100644 --- a/README.ja.md +++ b/README.ja.md @@ -2,7 +2,7 @@

Emacs PHP Mode

[![Emacs: 29.2](https://img.shields.io/badge/Emacs-29.2-blue.svg)](https://www.gnu.org/software/emacs/) -[![lang: PHP 8.2](https://img.shields.io/badge/lang-PHP%208.2-brightgreen.svg)](https://php.net/manual/migration82.php) +[![lang: PHP 8.3](https://img.shields.io/badge/lang-PHP%208.3-brightgreen.svg)](https://php.net/manual/migration83.php) [![lang: PHP 7](https://img.shields.io/badge/lang-PHP%207-green.svg)](https://php.net/downloads.php) [![Build Status](https://github.com/emacs-php/php-mode/workflows/CI/badge.svg)](https://github.com/emacs-php/php-mode/actions) [![GPL v3](https://img.shields.io/badge/license-GPL_v3-green.svg)][gpl-v3]
diff --git a/README.md b/README.md index 91a00e0b..b2726c5d 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@

Emacs PHP Mode

[![Emacs: 29.2](https://img.shields.io/badge/Emacs-29.2-blue.svg)](https://www.gnu.org/software/emacs/) -[![lang: PHP 8.2](https://img.shields.io/badge/lang-PHP%208.2-brightgreen.svg)](https://php.net/manual/migration82.php) -[![lang: PHP 7](https://img.shields.io/badge/lang-PHP%207-green.svg)](https://php.net/downloads.php) +[![lang: PHP 8.3](https://img.shields.io/badge/lang-PHP%208.3-brightgreen.svg)](https://www.php.net/manual/migration83.php) +[![lang: PHP 7](https://img.shields.io/badge/lang-PHP%207-green.svg)](https://www.php.net/downloads.php) [![Build Status](https://github.com/emacs-php/php-mode/workflows/CI/badge.svg)](https://github.com/emacs-php/php-mode/actions) [![GPL v3](https://img.shields.io/badge/license-GPL_v3-green.svg)][gpl-v3]
[![NonGNU ELPA][nongnu-elpa-badge]][nongnu-elpa] From 0f521ac4cb644ad0e2c4b9a3efb409a9bb287b02 Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Wed, 27 Mar 2024 00:13:56 -0700 Subject: [PATCH 092/125] ci: Bump Emacs 29.x to 3 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c2db6011..0825bdea 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,7 +23,7 @@ jobs: - "26.3" - "27.2" - "28.2" - - "29.2" + - "29.3" experimental: [false] include: - os: ubuntu-latest From 4bc08f68f2362e0fc36ff3c767c225b37afe58ec Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Tue, 7 May 2024 23:36:13 -0700 Subject: [PATCH 093/125] ci: Exclude macos tests below 27.x See https://github.com/purcell/setup-emacs/issues/48. --- .github/workflows/test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0825bdea..6e755ae2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,6 +35,11 @@ jobs: - os: windows-latest emacs-version: snapshot experimental: true + exclude: + - os: macos-latest + emacs-version: "26.3" + - os: macos-latest + emacs-version: "27.2" steps: - uses: actions/setup-python@v5 with: From 0e4d7db6c8b09046d50a7dea33676c490940afc1 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Tue, 28 May 2024 03:32:01 +0900 Subject: [PATCH 094/125] Remove $ from facename for interop with treesit --- CHANGELOG.md | 5 +++++ lisp/php-face.el | 7 +++++-- lisp/php-mode.el | 2 +- tests/7.4/typed-property.php.faces | 8 ++++---- tests/issue-136.php.faces | 4 ++-- tests/issue-201.php.faces | 4 ++-- tests/lang/doc-comment/comments.php.24.faces | 4 ++-- tests/lang/doc-comment/comments.php.27.faces | 4 ++-- tests/lang/doc-comment/comments.php.faces | 4 ++-- tests/php-mode-test.el | 4 ++-- 10 files changed, 27 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11708e02..3ec3ec28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,9 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this * Modify indentation of [PEAR Coding Standards] ([#774], [#777]) * No longer overindent it by default, since we don't see any mention in the coding style that it should hang `.`. (refs [#227] and [#229]) * **If you have any feedback on PEAR style, please let us know in [the discussion #776][#776].** + * Remove `$` from face names for interoperability with treesit ([#780], [emacs-php/php-ts-mode#68]) + * `php-$this` → `php-this` + * `php-$this-sigil` → `php-this-sigil` ### Removed @@ -28,6 +31,8 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this [#775]: https://github.com/emacs-php/php-mode/pull/775 [#776]: https://github.com/emacs-php/php-mode/discussions/776 [#777]: https://github.com/emacs-php/php-mode/pull/777 +[#780]: https://github.com/emacs-php/php-mode/issues/780 +[emacs-php/php-ts-mode#68]: https://github.com/emacs-php/php-ts-mode/pull/68 [PEAR Coding Standards]: https://pear.php.net/manual/en/standards.php ## [1.25.1] - 2023-11-24 diff --git a/lisp/php-face.el b/lisp/php-face.el index 70db33e0..d5ac817b 100644 --- a/lisp/php-face.el +++ b/lisp/php-face.el @@ -156,16 +156,19 @@ The operator is also knows as \"Paamayim Nekudotayim\"." :group 'php-faces :tag "PHP Magical Constant") -(defface php-$this '((t (:inherit php-constant))) +(defface php-this '((t (:inherit php-constant))) "PHP Mode face used to highlight $this variables." :group 'php-faces :tag "PHP $this") -(defface php-$this-sigil '((t (:inherit php-constant))) +(defface php-this-sigil '((t (:inherit php-constant))) "PHP Mode face used to highlight sigils($) of $this variable." :group 'php-faces :tag "PHP $this Sigil") +(define-obsolete-face-alias 'php-$this 'php-this "1.26.0") +(define-obsolete-face-alias 'php-$this-sigil 'php-this-sigil "1.26.0") + (defface php-errorcontrol-op '((t (:inherit font-lock-type-face))) "PHP Mode face used to highlight errorcontrol operators (@).." :group 'php-faces diff --git a/lisp/php-mode.el b/lisp/php-mode.el index d66cf0af..3ec28d66 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -1378,7 +1378,7 @@ for \\[find-tag] (which see)." ("\\(!\\)[^=]" 1 'php-logical-op) ;; Highlight special variables - ("\\(\\$\\)\\(this\\)\\>" (1 'php-$this-sigil) (2 'php-$this)) + ("\\(\\$\\)\\(this\\)\\>" (1 'php-this-sigil) (2 'php-this)) ("\\(\\$+\\)\\(\\sw+\\)" (1 'php-variable-sigil) (2 'php-variable-name)) ("\\(->\\)\\([a-zA-Z0-9_]+\\)" (1 'php-object-op) (2 'php-property-name)) diff --git a/tests/7.4/typed-property.php.faces b/tests/7.4/typed-property.php.faces index fac03f33..93779d5c 100644 --- a/tests/7.4/typed-property.php.faces +++ b/tests/7.4/typed-property.php.faces @@ -32,8 +32,8 @@ (" ") ("null" . php-constant) (")\n {\n ") - ("$" . php-$this-sigil) - ("this" . php-$this) + ("$" . php-this-sigil) + ("this" . php-this) ("->" . php-object-op) ("string" . php-property-name) (" ") @@ -50,8 +50,8 @@ ("()\n {\n ") ("var_dump" . php-function-call) ("(") - ("$" . php-$this-sigil) - ("this" . php-$this) + ("$" . php-this-sigil) + ("this" . php-this) ("->" . php-object-op) ("string" . php-property-name) (");\n }\n}\n\n(") diff --git a/tests/issue-136.php.faces b/tests/issue-136.php.faces index 538cdd97..0e5d6b71 100644 --- a/tests/issue-136.php.faces +++ b/tests/issue-136.php.faces @@ -103,8 +103,8 @@ ("$" . php-variable-sigil) ("name" . php-variable-name) (")\n {\n ") - ("$" . php-$this-sigil) - ("this" . php-$this) + ("$" . php-this-sigil) + ("this" . php-this) ("->" . php-object-op) ("name" . php-property-name) (" = ") diff --git a/tests/issue-201.php.faces b/tests/issue-201.php.faces index 7cd5f111..5801ea2a 100644 --- a/tests/issue-201.php.faces +++ b/tests/issue-201.php.faces @@ -8,8 +8,8 @@ ("\n\n") ("// " . font-lock-comment-delimiter-face) ("Start:\n" . font-lock-comment-face) - ("$" . php-$this-sigil) - ("this" . php-$this) + ("$" . php-this-sigil) + ("this" . php-this) (";\n") ("$" . php-variable-sigil) ("that" . php-variable-name) diff --git a/tests/lang/doc-comment/comments.php.24.faces b/tests/lang/doc-comment/comments.php.24.faces index 593bb49e..ca033603 100644 --- a/tests/lang/doc-comment/comments.php.24.faces +++ b/tests/lang/doc-comment/comments.php.24.faces @@ -105,8 +105,8 @@ ("$" . php-variable-sigil) ("name" . php-variable-name) (")\n {\n ") - ("$" . php-$this-sigil) - ("this" . php-$this) + ("$" . php-this-sigil) + ("this" . php-this) ("->" . php-object-op) ("name" . php-property-name) (" ") diff --git a/tests/lang/doc-comment/comments.php.27.faces b/tests/lang/doc-comment/comments.php.27.faces index 8b3b78e5..9b2fe992 100644 --- a/tests/lang/doc-comment/comments.php.27.faces +++ b/tests/lang/doc-comment/comments.php.27.faces @@ -106,8 +106,8 @@ ("$" . php-variable-sigil) ("name" . php-variable-name) (")\n {\n ") - ("$" . php-$this-sigil) - ("this" . php-$this) + ("$" . php-this-sigil) + ("this" . php-this) ("->" . php-object-op) ("name" . php-property-name) (" ") diff --git a/tests/lang/doc-comment/comments.php.faces b/tests/lang/doc-comment/comments.php.faces index 593bb49e..ca033603 100644 --- a/tests/lang/doc-comment/comments.php.faces +++ b/tests/lang/doc-comment/comments.php.faces @@ -105,8 +105,8 @@ ("$" . php-variable-sigil) ("name" . php-variable-name) (")\n {\n ") - ("$" . php-$this-sigil) - ("this" . php-$this) + ("$" . php-this-sigil) + ("this" . php-this) ("->" . php-object-op) ("name" . php-property-name) (" ") diff --git a/tests/php-mode-test.el b/tests/php-mode-test.el index dde44c7f..9890e0c8 100644 --- a/tests/php-mode-test.el +++ b/tests/php-mode-test.el @@ -533,8 +533,8 @@ style from Drupal." (should (eq 'php-variable-name (get-text-property (1- (point)) 'face))) (search-forward "$this") - (should (eq 'php-$this-sigil (get-text-property (match-beginning 0) 'face))) - (should (eq 'php-$this (get-text-property (1+ (match-beginning 0)) 'face))) + (should (eq 'php-this-sigil (get-text-property (match-beginning 0) 'face))) + (should (eq 'php-this (get-text-property (1+ (match-beginning 0)) 'face))) (search-forward "$x") (should (eq 'php-variable-sigil (get-text-property (match-beginning 0) 'face))) From ee88d597bed1be3dab481513411ba91e46d24da3 Mon Sep 17 00:00:00 2001 From: Alex Figl-Brick Date: Thu, 20 Jun 2024 15:23:33 +0900 Subject: [PATCH 095/125] Add php-function-call-standard inherit font-lock-function-call-face --- AUTHORS.md | 1 + CHANGELOG.md | 3 +++ lisp/php-face.el | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/AUTHORS.md b/AUTHORS.md index bdd02614..2c25aaee 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -24,6 +24,7 @@ Names Sorted Alphabetically: - Aaron S. Hawley - Alan Pearce +- Alex Figl-Brick - Andreas Röhler - Andrei Chițu - Antoine Brand diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ec3ec28..84abbfb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this * Remove `$` from face names for interoperability with treesit ([#780], [emacs-php/php-ts-mode#68]) * `php-$this` → `php-this` * `php-$this-sigil` → `php-this-sigil` + * Add `php-function-call-standard` face inherit `font-lock-function-call-face` on Emacs 29.1 and above ([#782], thanks [@bricka]!) ### Removed @@ -32,6 +33,8 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this [#776]: https://github.com/emacs-php/php-mode/discussions/776 [#777]: https://github.com/emacs-php/php-mode/pull/777 [#780]: https://github.com/emacs-php/php-mode/issues/780 +[#782]: https://github.com/emacs-php/php-mode/issues/782 +[@bricka]: https://github.com/bricka [emacs-php/php-ts-mode#68]: https://github.com/emacs-php/php-ts-mode/pull/68 [PEAR Coding Standards]: https://pear.php.net/manual/en/standards.php diff --git a/lisp/php-face.el b/lisp/php-face.el index d5ac817b..bb07e531 100644 --- a/lisp/php-face.el +++ b/lisp/php-face.el @@ -55,6 +55,12 @@ :group 'php-faces :tag "PHP Function Name") +(defface php-function-call-standard `((t ,(when (eval-when-compile (get 'font-lock-function-call-face 'face-defface-spec)) + '(:inherit font-lock-function-call-face)))) + "PHP Mode face used to highlight function names in calles." + :group 'php-faces + :tag "PHP Function Call Standard") + (defface php-function-call '((t ())) "PHP Mode face used to highlight function names in calles." :group 'php-faces From 0ed7faa0b504d9fea62e66d52de9d8c85d29a43d Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Thu, 20 Jun 2024 16:29:19 +0900 Subject: [PATCH 096/125] Add -traditional and -standard faces to call faces --- CHANGELOG.md | 5 +++++ lisp/php-face.el | 28 ++++++++++++++++++++++------ lisp/php-mode.el | 6 +++--- lisp/php.el | 18 ++++++++++++++++++ 4 files changed, 48 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84abbfb5..8a62ff7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,11 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this * `php-$this` → `php-this` * `php-$this-sigil` → `php-this-sigil` * Add `php-function-call-standard` face inherit `font-lock-function-call-face` on Emacs 29.1 and above ([#782], thanks [@bricka]!) + * Add `-tranditional` suffix to the `php-*-call` faces. + * `php-function-call` → `php-function-call-traditional` + * `php-method-call` → `php-method-call-traditional` + * `php-static-method-call` → `php-static-method-call-traditional` + * Add variables for the `php-function-call`, `php-method-call`, and `php-static-method-call` faces, defaulting to the `-traditional` face. ### Removed diff --git a/lisp/php-face.el b/lisp/php-face.el index bb07e531..4f16a816 100644 --- a/lisp/php-face.el +++ b/lisp/php-face.el @@ -61,20 +61,36 @@ :group 'php-faces :tag "PHP Function Call Standard") -(defface php-function-call '((t ())) +(defface php-function-call-traditional '((t ())) "PHP Mode face used to highlight function names in calles." :group 'php-faces - :tag "PHP Function Call") + :tag "PHP Function Call Traditional") -(defface php-method-call '((t (:inherit php-function-call))) +(define-obsolete-face-alias 'php-function-call 'php-function-call-traditional "1.26.0") + +(defface php-method-call-standard '((t (:inherit php-function-call-standard))) "PHP Mode face used to highlight method names in calles." :group 'php-faces - :tag "PHP Method Call") + :tag "PHP Method Call Standard") + +(defface php-method-call-traditional '((t (:inherit php-function-call-traditional))) + "PHP Mode face used to highlight method names in calles." + :group 'php-faces + :tag "PHP Method Call Traditional") + +(define-obsolete-face-alias 'php-method-call 'php-method-call-traditional "1.26.0") -(defface php-static-method-call '((t (:inherit php-method-call))) +(defface php-static-method-call-standard '((t (:inherit php-method-call-standard))) "PHP Mode face used to highlight static method names in calles." :group 'php-faces - :tag "PHP Static Method Call") + :tag "PHP Static Method Call Standard") + +(defface php-static-method-call-traditional '((t (:inherit php-method-call-traditional))) + "PHP Mode face used to highlight static method names in calles." + :group 'php-faces + :tag "PHP Static Method Call Traditional") + +(define-obsolete-face-alias 'php-static-method-call 'php-static-method-call-traditional "1.26.0") (defface php-variable-name '((t (:inherit font-lock-variable-name-face))) "PHP Mode face used to highlight variable names." diff --git a/lisp/php-mode.el b/lisp/php-mode.el index 3ec28d66..cfb1f17f 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -1371,7 +1371,7 @@ for \\[find-tag] (which see)." ;; Highlight variables, e.g. 'var' in '$var' and '$obj->var', but ;; not in $obj->var() - ("\\(->\\)\\(\\sw+\\)\\s-*(" (1 'php-object-op) (2 'php-method-call)) + ("\\(->\\)\\(\\sw+\\)\\s-*(" (1 'php-object-op) (2 php-method-call)) ("\\<\\(const\\)\\s-+\\(\\_<.+?\\_>\\)" (1 'php-keyword) (2 'php-constant-assign)) ;; Logical operator (!) @@ -1413,7 +1413,7 @@ for \\[find-tag] (which see)." ;; Highlight static method calls as such. This is necessary for method ;; names which are identical to keywords to be highlighted correctly. - ("\\sw+::\\(\\sw+\\)(" 1 'php-static-method-call) + ("\\sw+::\\(\\sw+\\)(" 1 php-static-method-call) ;; Multiple catch (FooException | BarException $e) (,(rx symbol-start "catch" symbol-end (* (syntax whitespace)) "(" (* (syntax whitespace)) @@ -1457,7 +1457,7 @@ for \\[find-tag] (which see)." (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) + ("\\(\\_<\\(?:\\sw\\|\\s_\\)+?\\_>\\)\\s-*(" 1 php-function-call) ;; Highlight all upper-cased symbols as constant ("\\<\\([A-Z_][A-Z0-9_]+\\)\\>" 1 'php-constant) diff --git a/lisp/php.el b/lisp/php.el index 32142cb0..e78c7c97 100644 --- a/lisp/php.el +++ b/lisp/php.el @@ -209,6 +209,24 @@ a completion list." :group 'php :tag "PHP Topsy Separator" :type 'string) + +(defcustom php-function-call 'php-function-call-traditional + "Face name to use for method call." + :group 'php + :tag "PHP Function Call" + :type 'face) + +(defcustom php-method-call 'php-method-call-traditional + "Face name to use for method call." + :group 'php + :tag "PHP Method Call" + :type 'face) + +(defcustom php-static-method-call 'php-static-method-call-traditional + "Face name to use for method call." + :group 'php + :tag "PHP Static Method Call" + :type 'face) ;;; PHP Keywords (defconst php-magical-constants From ccd28de9b881fea3d76e51785fa2e0da9e05347c Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Thu, 20 Jun 2024 16:29:43 +0900 Subject: [PATCH 097/125] Fix tests --- tests/7.4/typed-property.php.faces | 4 ++-- tests/8.0/attribute/class.php.faces | 12 +++++----- tests/8.0/attribute/function.php.faces | 8 +++---- tests/constants.php.faces | 2 +- tests/identifiers.php.faces | 6 ++--- tests/issue-197.php.faces | 4 ++-- tests/issue-201.php.faces | 6 ++--- tests/issue-439.php.faces | 4 ++-- tests/lang/class/anonymous-class.php.faces | 2 +- tests/lang/doc-comment/comments.php.24.faces | 2 +- tests/lang/doc-comment/comments.php.27.faces | 2 +- tests/lang/doc-comment/comments.php.faces | 2 +- tests/lang/function/calls.php.faces | 24 ++++++++++---------- tests/lang/function/closure.php.faces | 6 ++--- tests/static-method-calls.php.faces | 18 +++++++-------- tests/variables.php.faces | 2 +- 16 files changed, 52 insertions(+), 52 deletions(-) diff --git a/tests/7.4/typed-property.php.faces b/tests/7.4/typed-property.php.faces index 93779d5c..660b7b0a 100644 --- a/tests/7.4/typed-property.php.faces +++ b/tests/7.4/typed-property.php.faces @@ -48,7 +48,7 @@ (" ") ("print" . php-function-name) ("()\n {\n ") - ("var_dump" . php-function-call) + ("var_dump" . php-function-call-traditional) ("(") ("$" . php-this-sigil) ("this" . php-this) @@ -60,5 +60,5 @@ ("Typed" . font-lock-type-face) (")") ("->" . php-object-op) - ("print" . php-method-call) + ("print" . php-method-call-traditional) ("();\n")) diff --git a/tests/8.0/attribute/class.php.faces b/tests/8.0/attribute/class.php.faces index a4381657..1d249b6a 100644 --- a/tests/8.0/attribute/class.php.faces +++ b/tests/8.0/attribute/class.php.faces @@ -24,10 +24,10 @@ #[WithoutArgument] #[") - ("SingleArgument" . php-function-call) + ("SingleArgument" . php-function-call-traditional) ("(0)] #[") - ("FewArguments" . php-function-call) + ("FewArguments" . php-function-call-traditional) ("(") ("'Hello'" . php-string) (", ") @@ -40,9 +40,9 @@ ("() {} #[WithoutArgument] #[") - ("SingleArgument" . php-function-call) + ("SingleArgument" . php-function-call-traditional) ("(0)] #[") - ("FewArguments" . php-function-call) + ("FewArguments" . php-function-call-traditional) ("(") ("'Hello'" . php-string) (", ") @@ -55,11 +55,11 @@ ("() {} #[") - ("Attr2" . php-function-call) + ("Attr2" . php-function-call-traditional) ("(") ("\"foo\"" . php-string) ("), ") - ("Attr2" . php-function-call) + ("Attr2" . php-function-call-traditional) ("(") ("\"bar\"" . php-string) (")] diff --git a/tests/8.0/attribute/function.php.faces b/tests/8.0/attribute/function.php.faces index da2aea6c..00cedf07 100644 --- a/tests/8.0/attribute/function.php.faces +++ b/tests/8.0/attribute/function.php.faces @@ -11,10 +11,10 @@ #[WithoutArgument] #[") - ("SingleArgument" . php-function-call) + ("SingleArgument" . php-function-call-traditional) ("(0)] #[") - ("FewArguments" . php-function-call) + ("FewArguments" . php-function-call-traditional) ("(") ("'Hello'" . php-string) (", ") @@ -27,9 +27,9 @@ ("() {} #[WithoutArgument]#[") - ("SingleArgument" . php-function-call) + ("SingleArgument" . php-function-call-traditional) ("(0)]#[") - ("FewArguments" . php-function-call) + ("FewArguments" . php-function-call-traditional) ("(") ("'Hello'" . php-string) (", ") diff --git a/tests/constants.php.faces b/tests/constants.php.faces index 28f9523d..6718eb44 100644 --- a/tests/constants.php.faces +++ b/tests/constants.php.faces @@ -46,7 +46,7 @@ (";\n") ("SomeClass" . php-constant) ("::" . php-paamayim-nekudotayim) - ("classIdentifier" . php-static-method-call) + ("classIdentifier" . php-static-method-call-traditional) ("();\n\n") ("__halt_compiler" . php-keyword) ("();\n\n") diff --git a/tests/identifiers.php.faces b/tests/identifiers.php.faces index fbb56dfa..df098c90 100644 --- a/tests/identifiers.php.faces +++ b/tests/identifiers.php.faces @@ -43,15 +43,15 @@ ("the constant face. Just like c++-mode \"NS::Class::method()\"\n" . font-lock-comment-face) ("ClassName" . php-constant) ("::" . php-paamayim-nekudotayim) - ("method" . php-static-method-call) + ("method" . php-static-method-call-traditional) ("();\n") ("\\SpaceName\\ClassName" . php-constant) ("::" . php-paamayim-nekudotayim) - ("method" . php-static-method-call) + ("method" . php-static-method-call-traditional) ("();\n") ("\\My_Class" . php-constant) ("::" . php-paamayim-nekudotayim) - ("method" . php-static-method-call) + ("method" . php-static-method-call-traditional) ("();\n\n") ("__halt_compiler" . php-keyword) ("();\n\n") diff --git a/tests/issue-197.php.faces b/tests/issue-197.php.faces index 94f2abef..85469d9d 100644 --- a/tests/issue-197.php.faces +++ b/tests/issue-197.php.faces @@ -21,10 +21,10 @@ ("$" . php-variable-sigil) ("test" . php-variable-name) ("->" . php-object-op) - ("int" . php-method-call) + ("int" . php-method-call-traditional) ("();\n") ("$" . php-variable-sigil) ("test" . php-variable-name) ("->" . php-object-op) - ("string" . php-method-call) + ("string" . php-method-call-traditional) ("();\n")) diff --git a/tests/issue-201.php.faces b/tests/issue-201.php.faces index 5801ea2a..5c3ccda8 100644 --- a/tests/issue-201.php.faces +++ b/tests/issue-201.php.faces @@ -16,13 +16,13 @@ (";\n") ("self" . php-keyword) ("::" . php-paamayim-nekudotayim) - ("test" . php-static-method-call) + ("test" . php-static-method-call-traditional) ("();\n") ("static" . php-keyword) ("::" . php-paamayim-nekudotayim) - ("test" . php-static-method-call) + ("test" . php-static-method-call-traditional) ("();\n") ("parent" . php-keyword) ("::" . php-paamayim-nekudotayim) - ("test" . php-static-method-call) + ("test" . php-static-method-call-traditional) ("();\n")) diff --git a/tests/issue-439.php.faces b/tests/issue-439.php.faces index 595bcbab..bc3094e6 100644 --- a/tests/issue-439.php.faces +++ b/tests/issue-439.php.faces @@ -52,7 +52,7 @@ (" ") ("<<<\"いろは\"\nLet'go Justin\nいろは" . php-string) (";\n\n") - ("var_dump" . php-function-call) + ("var_dump" . php-function-call-traditional) ("(") ("<<<\"ABC\"\nLet'go Justin\nABC" . php-string) (");\n\n") @@ -60,7 +60,7 @@ (" (1 ") ("===" . php-comparison-op) (" 1) {\n ") - ("var_dump" . php-function-call) + ("var_dump" . php-function-call-traditional) ("(") ("<<<\"ABC\"\n Let'go Justin\n ABC" . php-string) (");\n}\n")) diff --git a/tests/lang/class/anonymous-class.php.faces b/tests/lang/class/anonymous-class.php.faces index 415bcaa2..bd0df9ce 100644 --- a/tests/lang/class/anonymous-class.php.faces +++ b/tests/lang/class/anonymous-class.php.faces @@ -17,7 +17,7 @@ ("// " . font-lock-comment-delimiter-face) ("###php-mode-test### ((indent 4))\n" . font-lock-comment-face) ("};\n\n") - ("is_object" . php-function-call) + ("is_object" . php-function-call-traditional) ("(1, ") ("new" . php-keyword) (" ") diff --git a/tests/lang/doc-comment/comments.php.24.faces b/tests/lang/doc-comment/comments.php.24.faces index ca033603..06f70485 100644 --- a/tests/lang/doc-comment/comments.php.24.faces +++ b/tests/lang/doc-comment/comments.php.24.faces @@ -134,7 +134,7 @@ (" ") ("=" . php-assignment-op) (" ") - ("hoge" . php-function-call) + ("hoge" . php-function-call-traditional) ("();\n\n ") ("// " . font-lock-comment-delimiter-face) ("one-line comment\n" . font-lock-comment-face) diff --git a/tests/lang/doc-comment/comments.php.27.faces b/tests/lang/doc-comment/comments.php.27.faces index 9b2fe992..70c23fb3 100644 --- a/tests/lang/doc-comment/comments.php.27.faces +++ b/tests/lang/doc-comment/comments.php.27.faces @@ -135,7 +135,7 @@ (" ") ("=" . php-assignment-op) (" ") - ("hoge" . php-function-call) + ("hoge" . php-function-call-traditional) ("();\n\n ") ("// " . font-lock-comment-delimiter-face) ("one-line comment\n" . font-lock-comment-face) diff --git a/tests/lang/doc-comment/comments.php.faces b/tests/lang/doc-comment/comments.php.faces index ca033603..06f70485 100644 --- a/tests/lang/doc-comment/comments.php.faces +++ b/tests/lang/doc-comment/comments.php.faces @@ -134,7 +134,7 @@ (" ") ("=" . php-assignment-op) (" ") - ("hoge" . php-function-call) + ("hoge" . php-function-call-traditional) ("();\n\n ") ("// " . font-lock-comment-delimiter-face) ("one-line comment\n" . font-lock-comment-face) diff --git a/tests/lang/function/calls.php.faces b/tests/lang/function/calls.php.faces index 19d681c5..7713374a 100644 --- a/tests/lang/function/calls.php.faces +++ b/tests/lang/function/calls.php.faces @@ -9,73 +9,73 @@ ("foo" . php-variable-name) (")) {\n 1") ("+" . php-arithmetic-op) - ("bar" . php-function-call) + ("bar" . php-function-call-traditional) ("()+") - ("foo" . php-function-call) + ("foo" . php-function-call-traditional) ("();\n}\n\n") ("$" . php-variable-sigil) ("foo" . php-variable-name) ("->" . php-object-op) - ("string" . php-method-call) + ("string" . php-method-call-traditional) ("();\n") ("$" . php-variable-sigil) ("foo" . php-variable-name) ("->" . php-object-op) - ("isset" . php-method-call) + ("isset" . php-method-call-traditional) ("();\n\n\n") ("$" . php-variable-sigil) ("a" . php-variable-name) ("->" . php-object-op) - ("b" . php-method-call) + ("b" . php-method-call-traditional) ("();\n") ("$" . php-variable-sigil) ("a" . php-variable-name) (" ") ("=" . php-assignment-op) (" ") - ("a" . php-function-call) + ("a" . php-function-call-traditional) ("();\n") ("$" . php-variable-sigil) ("aaa" . php-variable-name) (" ") ("=" . php-assignment-op) (" ") - ("aaa" . php-function-call) + ("aaa" . php-function-call-traditional) ("();\n") ("$" . php-variable-sigil) ("_aa" . php-variable-name) (" ") ("=" . php-assignment-op) (" ") - ("_aa" . php-function-call) + ("_aa" . php-function-call-traditional) ("();\n") ("$" . php-variable-sigil) ("a_a" . php-variable-name) (" ") ("=" . php-assignment-op) (" ") - ("a_a" . php-function-call) + ("a_a" . php-function-call-traditional) ("();\n") ("$" . php-variable-sigil) ("aa_" . php-variable-name) (" ") ("=" . php-assignment-op) (" ") - ("aa_" . php-function-call) + ("aa_" . php-function-call-traditional) ("();\n") ("$" . php-variable-sigil) ("a1c" . php-variable-name) (" ") ("=" . php-assignment-op) (" ") - ("a1c" . php-function-call) + ("a1c" . php-function-call-traditional) ("();\n") ("$" . php-variable-sigil) ("あ" . php-variable-name) (" ") ("=" . php-assignment-op) (" ") - ("あ" . php-function-call) + ("あ" . php-function-call-traditional) ("();\n") ("$" . php-variable-sigil) ("_a" . php-variable-name) diff --git a/tests/lang/function/closure.php.faces b/tests/lang/function/closure.php.faces index 1d671f72..9bf83b50 100644 --- a/tests/lang/function/closure.php.faces +++ b/tests/lang/function/closure.php.faces @@ -1,7 +1,7 @@ ;; -*- mode: emacs-lisp -*- (("" . php-object-op) - ("funCall" . php-method-call) + ("funCall" . php-method-call-traditional) ("();\n")) From 59814bd80c59894022bc5950fb3bdf02420e8a89 Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Mon, 22 Jul 2024 16:43:15 -0700 Subject: [PATCH 098/125] ci: Bump Emacs 29.x to 4 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6e755ae2..41fa23bb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,7 +23,7 @@ jobs: - "26.3" - "27.2" - "28.2" - - "29.3" + - "29.4" experimental: [false] include: - os: ubuntu-latest From a0a14e79db522251196bbe76ff804cf90d3be2a7 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Thu, 12 Sep 2024 03:22:36 +0900 Subject: [PATCH 099/125] Just call syntax-ppss-flush-cache instead of an explicit property. This issue was first introduced in #316 as a workaround for a problem with Emacs 25 not coloring properly. This approach was disadvantageous for large files, and although performance was improved in #531, we often suffered from flickering. --- CHANGELOG.md | 4 ++++ lisp/php-mode.el | 9 ++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a62ff7a..c854979b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this * `php-method-call` → `php-method-call-traditional` * `php-static-method-call` → `php-static-method-call-traditional` * Add variables for the `php-function-call`, `php-method-call`, and `php-static-method-call` faces, defaulting to the `-traditional` face. + * Changes how php-syntax-propertize-rules are applied for the first time. ([#785] and [#786]) + * This change is expected to make heredoc and attribute coloring more stable and reduce flicker. ### Removed @@ -39,6 +41,8 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this [#777]: https://github.com/emacs-php/php-mode/pull/777 [#780]: https://github.com/emacs-php/php-mode/issues/780 [#782]: https://github.com/emacs-php/php-mode/issues/782 +[#785]: https://github.com/emacs-php/php-mode/issues/785 +[#786]: https://github.com/emacs-php/php-mode/pull/786 [@bricka]: https://github.com/bricka [emacs-php/php-ts-mode#68]: https://github.com/emacs-php/php-ts-mode/pull/68 [PEAR Coding Standards]: https://pear.php.net/manual/en/standards.php diff --git a/lisp/php-mode.el b/lisp/php-mode.el index cfb1f17f..67fc8138 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -1,6 +1,6 @@ ;;; php-mode.el --- Major mode for editing PHP code -*- lexical-binding: t; -*- -;; Copyright (C) 2023 Friends of Emacs-PHP development +;; Copyright (C) 2024 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 @@ -1242,12 +1242,7 @@ After setting the stylevars run hook `php-mode-STYLENAME-hook'." :filter-args #'php-acm-backend-tabnine-candidate-expand-filter-args) (when (eval-when-compile (>= emacs-major-version 25)) - (with-silent-modifications - (save-excursion - (let* ((start (point-min)) - (end (min (point-max) - (+ start syntax-propertize-chunk-size)))) - (php-syntax-propertize-function start end)))))) + (syntax-ppss-flush-cache (point-min)))) (declare-function semantic-create-imenu-index "semantic/imenu" (&optional stream)) From 30da67bb25025c9f50c71ff7c5fe8e3e4cadea36 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Fri, 13 Sep 2024 06:40:16 +0900 Subject: [PATCH 100/125] Update module_id_prefixes --- script/data/module_id_prefixes.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/script/data/module_id_prefixes.php b/script/data/module_id_prefixes.php index bd379958..93a01f5e 100644 --- a/script/data/module_id_prefixes.php +++ b/script/data/module_id_prefixes.php @@ -496,6 +496,7 @@ 'curl' => [ 'curlfile.', 'function.curl-', + 'function.curl_upkeep', ], 'dba' => [ 'function.dba-', @@ -705,6 +706,9 @@ 'function.recode', 'function.recode-', ], + 'rnp' => [ + 'function.rnp-', + ], 'runkit7' => [ 'function.runkit7-', ], @@ -721,6 +725,9 @@ 'shmop' => [ 'function.shmop-', ], + 'simdjson' => [ + 'function.simdjson-' + ], 'simplexml' => [ 'function.dom-import-simplexml', 'function.simplexml-', From 7b946c3461303e3d23e6b4f9fdc13766af7617da Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Fri, 13 Sep 2024 06:46:41 +0900 Subject: [PATCH 101/125] Bump up version 1.26.0 --- CHANGELOG.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c854979b..0da62eba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,14 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles. -## Unreleased + + +## [1.26.0] - 2024-09-13 ### Added * Add `php-base-mode` which is the base of php related modes ([#772]) - * `php-base-mode` is designed as a common parent mode for `php-mode` and [`php-ts-mode`](https://github.com/emacs-php/php-ts-mode). + * `php-base-mode` is designed as a common parent mode for `php-mode` ~~and [`php-ts-mode`](https://github.com/emacs-php/php-ts-mode)~~. ### Changed From 9a2fe1c6c34f4f22f11efff0caf1d4e7c8ea233a Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Fri, 13 Sep 2024 07:17:45 +0900 Subject: [PATCH 102/125] Bump up version 1.26.1 --- CHANGELOG.md | 7 ++++++- Eask | 2 +- lisp/php-align.el | 2 +- lisp/php-complete.el | 2 +- lisp/php-defs.el | 2 +- lisp/php-face.el | 2 +- lisp/php-flymake.el | 2 +- lisp/php-ide-phpactor.el | 2 +- lisp/php-ide.el | 2 +- lisp/php-mode-debug.el | 2 +- lisp/php-mode.el | 4 ++-- lisp/php-project.el | 2 +- lisp/php.el | 2 +- 13 files changed, 19 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0da62eba..2408957b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this -## [1.26.0] - 2024-09-13 +## [1.26.1] - 2024-09-13 ### Added @@ -49,6 +49,11 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this [emacs-php/php-ts-mode#68]: https://github.com/emacs-php/php-ts-mode/pull/68 [PEAR Coding Standards]: https://pear.php.net/manual/en/standards.php +## [1.26.0] - 2024-09-13 + +> [!NOTE] +> This version was cancelled due to a release error. + ## [1.25.1] - 2023-11-24 ### Added diff --git a/Eask b/Eask index 23cc3463..2a90ee52 100644 --- a/Eask +++ b/Eask @@ -1,5 +1,5 @@ (package "php-mode" - "1.25.1" + "1.26.1" "Major mode for editing PHP code") (website-url "https://github.com/emacs-php/php-mode") diff --git a/lisp/php-align.el b/lisp/php-align.el index de4fe3cf..e9acc469 100644 --- a/lisp/php-align.el +++ b/lisp/php-align.el @@ -7,7 +7,7 @@ ;; Maintainer: USAMI Kenta ;; Keywords: php languages convenience align ;; Homepage: https://github.com/emacs-php/php-mode -;; Version: 1.25.1 +;; Version: 1.26.1 ;; License: GPL-3.0-or-later ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-complete.el b/lisp/php-complete.el index 28ac52fe..f2b1aa42 100644 --- a/lisp/php-complete.el +++ b/lisp/php-complete.el @@ -6,7 +6,7 @@ ;; Author: USAMI Kenta ;; Created: 18 Sep 2022 -;; Version: 1.25.1 +;; Version: 1.26.1 ;; Keywords: languages, php ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-defs.el b/lisp/php-defs.el index 37bd682d..8be83138 100644 --- a/lisp/php-defs.el +++ b/lisp/php-defs.el @@ -4,7 +4,7 @@ ;; Author: USAMI Kenta ;; Created: 5 Mar 2022 -;; Version: 1.25.1 +;; Version: 1.26.1 ;; Keywords: languages, php ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-face.el b/lisp/php-face.el index 4f16a816..147fb813 100644 --- a/lisp/php-face.el +++ b/lisp/php-face.el @@ -4,7 +4,7 @@ ;; Author: USAMI Kenta ;; Created: 5 May 2019 -;; Version: 1.25.1 +;; Version: 1.26.1 ;; Keywords: faces, php ;; Homepage: https://github.com/emacs-php/php-mode ;; License: GPL-3.0-or-later diff --git a/lisp/php-flymake.el b/lisp/php-flymake.el index 37e4aea4..8efad224 100644 --- a/lisp/php-flymake.el +++ b/lisp/php-flymake.el @@ -4,7 +4,7 @@ ;; Author: USAMI Kenta ;; Created: 5 Mar 2022 -;; Version: 1.25.1 +;; Version: 1.26.1 ;; Keywords: tools, languages, php ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-ide-phpactor.el b/lisp/php-ide-phpactor.el index 831f49be..f0a98c82 100644 --- a/lisp/php-ide-phpactor.el +++ b/lisp/php-ide-phpactor.el @@ -5,7 +5,7 @@ ;; Author: USAMI Kenta ;; Keywords: tools, files ;; URL: https://github.com/emacs-php/php-mode -;; Version: 1.25.1 +;; Version: 1.26.1 ;; License: GPL-3.0-or-later ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-ide.el b/lisp/php-ide.el index f73d5bc3..a48cf1e0 100644 --- a/lisp/php-ide.el +++ b/lisp/php-ide.el @@ -5,7 +5,7 @@ ;; Author: USAMI Kenta ;; Keywords: tools, files ;; URL: https://github.com/emacs-php/php-mode -;; Version: 1.25.1 +;; Version: 1.26.1 ;; License: GPL-3.0-or-later ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-mode-debug.el b/lisp/php-mode-debug.el index a3e2d1da..efe6e48e 100644 --- a/lisp/php-mode-debug.el +++ b/lisp/php-mode-debug.el @@ -5,7 +5,7 @@ ;; Author: USAMI Kenta ;; URL: https://github.com/emacs-php/php-mode ;; Keywords: maint -;; Version: 1.25.1 +;; Version: 1.26.1 ;; License: GPL-3.0-or-later ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php-mode.el b/lisp/php-mode.el index 67fc8138..d9b73264 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -9,13 +9,13 @@ ;; Maintainer: USAMI Kenta ;; URL: https://github.com/emacs-php/php-mode ;; Keywords: languages php -;; Version: 1.25.1 +;; Version: 1.26.1 ;; Package-Requires: ((emacs "26.1")) ;; License: GPL-3.0-or-later (eval-and-compile (make-obsolete-variable - (defconst php-mode-version-number "1.25.1" "PHP Mode version number.") + (defconst php-mode-version-number "1.26.1" "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 diff --git a/lisp/php-project.el b/lisp/php-project.el index 6d20e455..81899803 100644 --- a/lisp/php-project.el +++ b/lisp/php-project.el @@ -5,7 +5,7 @@ ;; Author: USAMI Kenta ;; Keywords: tools, files ;; URL: https://github.com/emacs-php/php-mode -;; Version: 1.25.1 +;; Version: 1.26.1 ;; License: GPL-3.0-or-later ;; This program is free software; you can redistribute it and/or modify diff --git a/lisp/php.el b/lisp/php.el index e78c7c97..aa09b5df 100644 --- a/lisp/php.el +++ b/lisp/php.el @@ -5,7 +5,7 @@ ;; Author: USAMI Kenta ;; Created: 5 Dec 2018 -;; Version: 1.25.1 +;; Version: 1.26.1 ;; Keywords: languages, php ;; Homepage: https://github.com/emacs-php/php-mode ;; License: GPL-3.0-or-later From 6af9d90e27c0c708c387a41f929f958cbf996fb9 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Fri, 13 Sep 2024 07:27:46 +0900 Subject: [PATCH 103/125] Removed CI in Emacs 26.3 --- .github/workflows/test.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 41fa23bb..cc9294f5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,6 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] emacs-version: - - "26.3" - "27.2" - "28.2" - "29.4" @@ -36,8 +35,6 @@ jobs: emacs-version: snapshot experimental: true exclude: - - os: macos-latest - emacs-version: "26.3" - os: macos-latest emacs-version: "27.2" steps: From fb2c1ed5df3e3ac84b7b6cb325c32e4ba8afa18a Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Fri, 13 Sep 2024 07:28:33 +0900 Subject: [PATCH 104/125] Raised minimum supported version to Emacs 27.1 --- lisp/php-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/php-mode.el b/lisp/php-mode.el index d9b73264..0cee34d5 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -10,7 +10,7 @@ ;; URL: https://github.com/emacs-php/php-mode ;; Keywords: languages php ;; Version: 1.26.1 -;; Package-Requires: ((emacs "26.1")) +;; Package-Requires: ((emacs "27.1")) ;; License: GPL-3.0-or-later (eval-and-compile From e3087db57e6b1682eb80af2916f106ac19472ce3 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Fri, 13 Sep 2024 07:38:46 +0900 Subject: [PATCH 105/125] Update README --- README.ja.md | 5 ++--- README.md | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/README.ja.md b/README.ja.md index 5c0dd082..a4af81d9 100644 --- a/README.ja.md +++ b/README.ja.md @@ -1,9 +1,8 @@

Emacs PHP Mode

-[![Emacs: 29.2](https://img.shields.io/badge/Emacs-29.2-blue.svg)](https://www.gnu.org/software/emacs/) +[![Emacs: 29.4](https://img.shields.io/badge/Emacs-29.4-blue.svg)](https://www.gnu.org/software/emacs/) [![lang: PHP 8.3](https://img.shields.io/badge/lang-PHP%208.3-brightgreen.svg)](https://php.net/manual/migration83.php) -[![lang: PHP 7](https://img.shields.io/badge/lang-PHP%207-green.svg)](https://php.net/downloads.php) [![Build Status](https://github.com/emacs-php/php-mode/workflows/CI/badge.svg)](https://github.com/emacs-php/php-mode/actions) [![GPL v3](https://img.shields.io/badge/license-GPL_v3-green.svg)][gpl-v3]
[![NonGNU ELPA][nongnu-elpa-badge]][nongnu-elpa] @@ -25,7 +24,7 @@ A powerful and flexible Emacs major mode for editing PHP scripts ## インストール -**PHP ModeはEmacs 26.1以降で動作します**。対応バージョンの詳細は[Supported Version]をお読みください。Emacs 28以降では単に以下のコマンドを実行するだけでインストールできます。 +**PHP ModeはEmacs 27.1以降で動作します**。対応バージョンの詳細は[Supported Version]をお読みください。Emacs 28以降では単に以下のコマンドを実行するだけでインストールできます。 ``` M-x package-install php-mode diff --git a/README.md b/README.md index b2726c5d..f546d25a 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,8 @@

Emacs PHP Mode

-[![Emacs: 29.2](https://img.shields.io/badge/Emacs-29.2-blue.svg)](https://www.gnu.org/software/emacs/) +[![Emacs: 29.4](https://img.shields.io/badge/Emacs-29.4-blue.svg)](https://www.gnu.org/software/emacs/) [![lang: PHP 8.3](https://img.shields.io/badge/lang-PHP%208.3-brightgreen.svg)](https://www.php.net/manual/migration83.php) -[![lang: PHP 7](https://img.shields.io/badge/lang-PHP%207-green.svg)](https://www.php.net/downloads.php) [![Build Status](https://github.com/emacs-php/php-mode/workflows/CI/badge.svg)](https://github.com/emacs-php/php-mode/actions) [![GPL v3](https://img.shields.io/badge/license-GPL_v3-green.svg)][gpl-v3]
[![NonGNU ELPA][nongnu-elpa-badge]][nongnu-elpa] @@ -25,7 +24,7 @@ Please submit any bug reports or feature requests by creating issues on [the Git ## Installation -**PHP Mode works with Emacs 26.1 or later**. For details on supported versions, see [Supported Version]. Emacs 28 or later can be installed simply by running the following command. +**PHP Mode works with Emacs 27.1 or later**. For details on supported versions, see [Supported Version]. Emacs 28 or later can be installed simply by running the following command. ``` M-x package-install php-mode From e64e1fe51e9298b1ff5a586f7e89652ead8577b2 Mon Sep 17 00:00:00 2001 From: Phil Sainty Date: Fri, 13 Sep 2024 23:39:39 +1200 Subject: [PATCH 106/125] Improve php-syntax-propertize-extend-region efficiency If the first pair of searches found a heredoc which spanned the entire region, don't perform the second pair of searches, as we already know the new region bounds. If we do need the second pair of searches, bound the backwards search at the original region START position. --- lisp/php-mode.el | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lisp/php-mode.el b/lisp/php-mode.el index 0cee34d5..0f58a9a8 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -1038,17 +1038,24 @@ HEREDOC-START." (unwind-protect (let (new-start new-end) (goto-char start) + ;; Consider bounding this backwards search by `beginning-of-defun'. + ;; (Benchmarking for a wide range of cases may be needed to decide + ;; whether that's an improvement, as `php-beginning-of-defun' also + ;; uses `re-search-backward'.) (when (re-search-backward php-heredoc-start-re nil t) (let ((maybe (point))) (when (and (re-search-forward (php-heredoc-end-re (match-string 0)) nil t) (> (point) start)) - (setq new-start maybe)))) - (goto-char end) - (when (re-search-backward php-heredoc-start-re nil t) - (if (re-search-forward (php-heredoc-end-re (match-string 0)) nil t) + (setq new-start maybe) (when (> (point) end) - (setq new-end (point))) - (setq new-end (point-max)))) + (setq new-end (point)))))) + (unless new-end + (goto-char end) + (when (re-search-backward php-heredoc-start-re start t) + (if (re-search-forward (php-heredoc-end-re (match-string 0)) nil t) + (when (> (point) end) + (setq new-end (point))) + (setq new-end (point-max))))) (when (or new-start new-end) (cons (or new-start start) (or new-end end)))) ;; Cleanup From d9f6672052c122d7c90361e58c36229d40ea5cb8 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Thu, 24 Oct 2024 21:31:32 +0900 Subject: [PATCH 107/125] Fix Emacs 30 byte-compile errors --- lisp/php-ide-phpactor.el | 8 ++++---- lisp/php-mode.el | 4 ++-- lisp/php.el | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lisp/php-ide-phpactor.el b/lisp/php-ide-phpactor.el index f0a98c82..109cd461 100644 --- a/lisp/php-ide-phpactor.el +++ b/lisp/php-ide-phpactor.el @@ -30,8 +30,7 @@ (require 'phpactor nil t) (require 'popup nil t) (require 'smart-jump nil t) -(eval-when-compile - (require 'cl-lib)) +(require 'cl-lib) (defvar-local php-ide-phpactor-buffer nil) (defvar-local php-ide-phpactor-hover-last-pos nil) @@ -55,10 +54,11 @@ (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") + :type '(set (const :tag "All" all) (const hover) (const navigation)) - :safe (lambda (v) (and (listp v))) + :safe (lambda (xs) (and (listp xs) + (cl-every (lambda (x) (memq x '(all hover navigation))) xs))) :group 'php-ide-phpactor) (defvar php-ide-phpactor-timer nil diff --git a/lisp/php-mode.el b/lisp/php-mode.el index 0f58a9a8..6a6523e1 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -191,7 +191,7 @@ Turning this on will open it whenever `php-mode' is loaded." #'php-flymake)) "Flymake function to replace, if NIL do not replace." :tag "PHP Mode Replace Flymake Diag Function" - :type '(choice 'function + :type '(choice function (const :tag "Disable to replace" nil))) (define-obsolete-variable-alias 'php-do-not-use-semantic-imenu 'php-mode-do-not-use-semantic-imenu "1.20.0") @@ -253,7 +253,7 @@ 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." :tag "PHP Mode Warn If MuMaMo Off" - :type '(choice (const :tag "Warn" t) (const "Don't warn" nil))) + :type '(choice (const :tag "Warn" t) (const :tag "Don't warn" nil))) (defcustom php-mode-coding-style 'pear "Select default coding style to use with `php-mode'. diff --git a/lisp/php.el b/lisp/php.el index aa09b5df..7176cb8c 100644 --- a/lisp/php.el +++ b/lisp/php.el @@ -99,8 +99,8 @@ You can replace \"en\" with your ISO language code." "Function to search PHP Manual at cursor position." :group 'php :tag "PHP Search Documentation Function" - :type '(choice (const :tag "Use online documentation" #'php-search-web-documentation) - (const :tag "Use local documentation" #'php-local-manual-search) + :type '(choice (const :tag "Use online documentation" php-search-web-documentation) + (const :tag "Use local documentation" php-local-manual-search) (function :tag "Use other function"))) (defcustom php-search-documentation-browser-function nil @@ -453,7 +453,7 @@ can be used to match against definitions for that classlike." (defcustom php-imenu-generic-expression 'php-imenu-generic-expression-default "Default Imenu generic expression for PHP Mode. See `imenu-generic-expression'." - :type '(choice (alist :key-type string :value-type list) + :type '(choice (alist :key-type string :value-type (list string)) (const php-imenu-generic-expression-legacy) (const php-imenu-generic-expression-simple) variable) From a59e92e2334f10bca8cdae0d9ac0210e1212abfe Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Thu, 19 Dec 2024 12:52:57 +0900 Subject: [PATCH 108/125] Use when-let* instead of when-let to support Emacs 30 --- lisp/php-format.el | 2 +- lisp/php-ide.el | 8 ++++---- lisp/php-project.el | 2 +- lisp/php.el | 7 +++---- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lisp/php-format.el b/lisp/php-format.el index cfa71a57..a26477f6 100644 --- a/lisp/php-format.el +++ b/lisp/php-format.el @@ -176,7 +176,7 @@ files) return sym)) (setq-local php-format-command cmd)) - (when-let (tup (plist-get (cdr-safe (assq cmd php-format-formatter-alist)) :command)) + (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))) diff --git a/lisp/php-ide.el b/lisp/php-ide.el index a48cf1e0..5d1201fb 100644 --- a/lisp/php-ide.el +++ b/lisp/php-ide.el @@ -166,7 +166,7 @@ (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)) + ((when-let* (command (assq php-ide-eglot-executable php-ide-lsp-command-alist)) (cond ((functionp command) (funcall command)) ((listp command) command)))))) @@ -196,9 +196,9 @@ ACTIVATE: T is given when activeting, NIL when deactivating PHP-IDE." "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)) + (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))) diff --git a/lisp/php-project.el b/lisp/php-project.el index 81899803..caa16eb3 100644 --- a/lisp/php-project.el +++ b/lisp/php-project.el @@ -267,7 +267,7 @@ Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.") This function is compatible with `project-find-functions'." (let ((default-directory dir)) - (when-let (root (php-project-get-root-dir)) + (when-let* (root (php-project-get-root-dir)) (if (file-exists-p (expand-file-name ".git" root)) (cons 'vc root) (cons 'transient root))))) diff --git a/lisp/php.el b/lisp/php.el index 7176cb8c..437776c6 100644 --- a/lisp/php.el +++ b/lisp/php.el @@ -553,15 +553,14 @@ The order is reversed by calling as follows: (c-backward-token-2 1 nil)) collect (cond - ((when-let (bounds (php--thing-at-point-bounds-of-string-at-point)) + ((when-let* (bounds (php--thing-at-point-bounds-of-string-at-point)) (prog1 (buffer-substring-no-properties (car bounds) (cdr bounds)) (goto-char (car bounds))))) ((looking-at php-re-token-symbols) (prog1 (match-string-no-properties 0) (goto-char (match-beginning 0)))) - (t - (buffer-substring-no-properties (point) - (save-excursion (php--c-end-of-token) (point)))))))))) + ((buffer-substring-no-properties (point) + (save-excursion (php--c-end-of-token) (point)))))))))) (defun php-get-pattern () "Find the pattern we want to complete. From c2f416b3c94ff47319fefa839579e190c973dbb0 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Thu, 19 Dec 2024 12:46:07 +0900 Subject: [PATCH 109/125] Update php-phpdoc-type-names to support PHPStan 2.0.4 --- lisp/php-mode.el | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/lisp/php-mode.el b/lisp/php-mode.el index 6a6523e1..867a84fe 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -1301,18 +1301,20 @@ for \\[find-tag] (which see)." ;; Font Lock (defconst php-phpdoc-type-names - (list "string" "integer" "int" "boolean" "bool" "float" - "double" "object" "mixed" "array" "resource" - "void" "null" "false" "true" "self" "static" - "callable" "iterable" "number" - ;; PHPStan and Psalm types - "array-key" "associative-array" "callable-array" "callable-object" - "callable-string" "class-string" "empty" "enum-string" "list" - "literal-string" "negative-int" "non-positive-int" "non-negative-int" - "never" "never-return" "never-returns" "no-return" "non-empty-array" - "non-empty-list" "non-empty-string" "non-falsy-string" - "numeric" "numeric-string" "positive-int" "scalar" - "trait-string" "truthy-string" "key-of" "value-of") + '(;; PHPStan and Psalm types + "__stringandstringable" "array" "array-key" "associative-array" "bool" "boolean" + "callable" "callable-array" "callable-object" "callable-string" "class-string" + "closed-resource" "double" "empty" "empty-scalar" "enum-string" "false" "float" + "int" "integer" "interface-string" "iterable" "list" "literal-string" "lowercase-string" + "mixed" "negative-int" "never" "never-return" "never-returns" "no-return" "non-empty-array" + "non-empty-list" "non-empty-literal-string" "non-empty-lowercase-string" "non-empty-mixed" + "non-empty-scalar" "non-empty-string" "non-empty-uppercase-string" "non-falsy-string" + "non-negative-int" "non-positive-int" "non-zero-int" "noreturn" "null" "number" "numeric" + "numeric-string" "object" "open-resource" "parent" "positive-int" "pure-callable" + "pure-closure" "resource" "scalar" "self" "static" "string" "trait-string" "true" + "truthy-string" "uppercase-string" "void" + ;; PHPStan Generic Types + "key-of" "value-of" "int-mask-of" "int-mask" "__benevolent" "template-type" "new") "A list of type and pseudotype names that can be used in PHPDoc.") (make-obsolete-variable 'php-phpdoc-type-keywords 'php-phpdoc-type-names "1.24.2") From 9f0695e705ce900dadd858d81d3faa20ed4c9bf4 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Thu, 19 Dec 2024 14:38:38 +0900 Subject: [PATCH 110/125] Fix malformed when-let* --- lisp/php-format.el | 2 +- lisp/php-ide.el | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lisp/php-format.el b/lisp/php-format.el index a26477f6..578ee52b 100644 --- a/lisp/php-format.el +++ b/lisp/php-format.el @@ -176,7 +176,7 @@ files) return sym)) (setq-local php-format-command cmd)) - (when-let* (tup (plist-get (cdr-safe (assq cmd php-format-formatter-alist)) :command)) + (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))) diff --git a/lisp/php-ide.el b/lisp/php-ide.el index 5d1201fb..4e1ec8b4 100644 --- a/lisp/php-ide.el +++ b/lisp/php-ide.el @@ -166,7 +166,7 @@ (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)) + ((when-let* ((command (assq php-ide-eglot-executable php-ide-lsp-command-alist))) (cond ((functionp command) (funcall command)) ((listp command) command)))))) @@ -196,9 +196,9 @@ ACTIVATE: T is given when activeting, NIL when deactivating PHP-IDE." "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)) + (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))) From 69e9c16fda61c3aef9219bf55adadcbba62c0586 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Thu, 19 Dec 2024 14:40:41 +0900 Subject: [PATCH 111/125] Fix malformed when-let* again --- lisp/php-project.el | 2 +- lisp/php.el | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/php-project.el b/lisp/php-project.el index caa16eb3..0b59e2ce 100644 --- a/lisp/php-project.el +++ b/lisp/php-project.el @@ -267,7 +267,7 @@ Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.") This function is compatible with `project-find-functions'." (let ((default-directory dir)) - (when-let* (root (php-project-get-root-dir)) + (when-let* ((root (php-project-get-root-dir))) (if (file-exists-p (expand-file-name ".git" root)) (cons 'vc root) (cons 'transient root))))) diff --git a/lisp/php.el b/lisp/php.el index 437776c6..c08227b1 100644 --- a/lisp/php.el +++ b/lisp/php.el @@ -553,7 +553,7 @@ The order is reversed by calling as follows: (c-backward-token-2 1 nil)) collect (cond - ((when-let* (bounds (php--thing-at-point-bounds-of-string-at-point)) + ((when-let* ((bounds (php--thing-at-point-bounds-of-string-at-point))) (prog1 (buffer-substring-no-properties (car bounds) (cdr bounds)) (goto-char (car bounds))))) ((looking-at php-re-token-symbols) From 5722ecdf5ce0ecc4567482b8af34da75d4eb2223 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Thu, 19 Dec 2024 21:21:08 +0900 Subject: [PATCH 112/125] Support PHP 8.4 property-hooks --- lisp/php-mode.el | 4 +- tests/8.4/property-hooks.php | 33 +++++++ tests/8.4/property-hooks.php.faces | 146 +++++++++++++++++++++++++++++ tests/php-mode-test.el | 8 +- 4 files changed, 188 insertions(+), 3 deletions(-) create mode 100644 tests/8.4/property-hooks.php create mode 100644 tests/8.4/property-hooks.php.faces diff --git a/lisp/php-mode.el b/lisp/php-mode.el index 867a84fe..e1736b28 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -1519,7 +1519,9 @@ for \\[find-tag] (which see)." ;; Not operator (!) is defined in "before cc-mode" section above. ("\\(&&\\|||\\)" 1 'php-logical-op) ;; string interpolation ("$var, ${var}, {$var}") - (php-mode--string-interpolated-variable-font-lock-find 0 nil))) + (php-mode--string-interpolated-variable-font-lock-find 0 nil) + (,(rx symbol-start (group (or "get" "set")) (+ (syntax whitespace)) (or "{" "=>")) + 1 'php-builtin))) "Detailed highlighting for PHP Mode.") (defvar php-font-lock-keywords php-font-lock-keywords-3 diff --git a/tests/8.4/property-hooks.php b/tests/8.4/property-hooks.php new file mode 100644 index 00000000..aa50f965 --- /dev/null +++ b/tests/8.4/property-hooks.php @@ -0,0 +1,33 @@ + $this->firstName . ' ' . $this->lastName; + } + + // All write operations go through this hook, and the result is what is written. + // Read access happens normally. + public string $firstName { + set => ucfirst(strtolower($value)); + } + + // All write operations go through this hook, which has to write to the backing value itself. + // Read access happens normally. + public string $lastName { + set { + if (strlen($value) < 2) { + throw new \InvalidArgumentException('Too short'); + } + $this->lastName = $value; + } + } +} + +$p = new Person(); + +$p->firstName = 'peter'; +print $p->firstName; // Prints "Peter" +$p->lastName = 'Peterson'; +print $p->fullName; // Prints "Peter Peterson" diff --git a/tests/8.4/property-hooks.php.faces b/tests/8.4/property-hooks.php.faces new file mode 100644 index 00000000..89ec60a6 --- /dev/null +++ b/tests/8.4/property-hooks.php.faces @@ -0,0 +1,146 @@ +;; -*- mode: emacs-lisp -*- +(("" . php-comparison-op) + (" ") + ("$" . php-this-sigil) + ("this" . php-this) + ("->" . php-object-op) + ("firstName" . php-property-name) + (" . ") + ("' '" . php-string) + (" . ") + ("$" . php-this-sigil) + ("this" . php-this) + ("->" . php-object-op) + ("lastName" . php-property-name) + (";\n }\n\n ") + ("// " . font-lock-comment-delimiter-face) + ("All write operations go through this hook, and the result is what is written.\n" . font-lock-comment-face) + (" ") + ("// " . font-lock-comment-delimiter-face) + ("Read access happens normally.\n" . font-lock-comment-face) + (" ") + ("public" . php-keyword) + (" ") + ("string" . php-class) + (" ") + ("$" . php-variable-sigil) + ("firstName" . php-variable-name) + (" {\n ") + ("set" . php-builtin) + (" ") + ("=" . php-assignment-op) + (">" . php-comparison-op) + (" ") + ("ucfirst" . php-function-call-traditional) + ("(") + ("strtolower" . php-function-call-traditional) + ("(") + ("$" . php-variable-sigil) + ("value" . php-variable-name) + ("));\n }\n\n ") + ("// " . font-lock-comment-delimiter-face) + ("All write operations go through this hook, which has to write to the backing value itself.\n" . font-lock-comment-face) + (" ") + ("// " . font-lock-comment-delimiter-face) + ("Read access happens normally.\n" . font-lock-comment-face) + (" ") + ("public" . php-keyword) + (" ") + ("string" . php-class) + (" ") + ("$" . php-variable-sigil) + ("lastName" . php-variable-name) + (" {\n ") + ("set" . php-builtin) + (" {\n ") + ("if" . php-keyword) + (" (") + ("strlen" . php-function-call-traditional) + ("(") + ("$" . php-variable-sigil) + ("value" . php-variable-name) + (") ") + ("<" . php-comparison-op) + (" 2) {\n ") + ("throw" . php-keyword) + (" ") + ("new" . php-keyword) + (" ") + ("\\InvalidArgumentException" . font-lock-type-face) + ("(") + ("'Too short'" . php-string) + (");\n }\n ") + ("$" . php-this-sigil) + ("this" . php-this) + ("->" . php-object-op) + ("lastName" . php-property-name) + (" ") + ("=" . php-assignment-op) + (" ") + ("$" . php-variable-sigil) + ("value" . php-variable-name) + (";\n }\n }\n}\n\n") + ("$" . php-variable-sigil) + ("p" . php-variable-name) + (" ") + ("=" . php-assignment-op) + (" ") + ("new" . php-keyword) + (" ") + ("Person" . font-lock-type-face) + ("();\n\n") + ("$" . php-variable-sigil) + ("p" . php-variable-name) + ("->" . php-object-op) + ("firstName" . php-property-name) + (" ") + ("=" . php-assignment-op) + (" ") + ("'peter'" . php-string) + (";\n") + ("print" . php-keyword) + (" ") + ("$" . php-variable-sigil) + ("p" . php-variable-name) + ("->" . php-object-op) + ("firstName" . php-property-name) + ("; ") + ("// " . font-lock-comment-delimiter-face) + ("Prints \"Peter\"\n" . font-lock-comment-face) + ("$" . php-variable-sigil) + ("p" . php-variable-name) + ("->" . php-object-op) + ("lastName" . php-property-name) + (" ") + ("=" . php-assignment-op) + (" ") + ("'Peterson'" . php-string) + (";\n") + ("print" . php-keyword) + (" ") + ("$" . php-variable-sigil) + ("p" . php-variable-name) + ("->" . php-object-op) + ("fullName" . php-property-name) + ("; ") + ("// " . font-lock-comment-delimiter-face) + ("Prints \"Peter Peterson\"\n" . font-lock-comment-face)) diff --git a/tests/php-mode-test.el b/tests/php-mode-test.el index 9890e0c8..4d36579b 100644 --- a/tests/php-mode-test.el +++ b/tests/php-mode-test.el @@ -1,6 +1,6 @@ -;;; php-mode-test.el --- Tests for php-mode +;;; php-mode-test.el --- Tests for php-mode -*- lexical-binding: t -*- -;; Copyright (C) 2018-2019 Friends of Emacs-PHP development +;; Copyright (C) 2018-2024 Friends of Emacs-PHP development ;; Copyright (C) 2013 Daniel Hackney ;; 2014, 2015 Eric James Michael Ritz @@ -669,6 +669,10 @@ Meant for `php-mode-test-issue-503'." (with-php-mode-test ("8.1/enum.php" :faces t)) (with-php-mode-test ("8.1/readonly.php" :faces t))) +(ert-deftest php-mode-test-php84 () + "Test highlighting language constructs added in PHP 8.4." + (with-php-mode-test ("8.4/property-hooks.php" :faces t))) + (ert-deftest php-mode-test-lang () "Test highlighting for language constructs." (with-php-mode-test ("lang/class/anonymous-class.php" :indent t :magic t :faces t)) From 652a5a706a31eafdd6a541fcc4dfc134d19d11c9 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Thu, 19 Dec 2024 21:54:16 +0900 Subject: [PATCH 113/125] Update AUTHORS.md --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 2c25aaee..6aceea50 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -84,6 +84,7 @@ Names Sorted Alphabetically: - Norio Suzuki - Olaf The Viking - Peter Oliver +- Phil Sainty - Philippe Ivaldi - Piotr Kwiecinski - Rex McMaster From 8ea767e038013333ccbdf7a238ae241c687086e3 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Thu, 19 Dec 2024 22:36:59 +0900 Subject: [PATCH 114/125] Update README to support Emacs 30 and PHP 8.4 --- README.ja.md | 13 +++++++++---- README.md | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/README.ja.md b/README.ja.md index a4af81d9..f9312302 100644 --- a/README.ja.md +++ b/README.ja.md @@ -1,8 +1,8 @@

Emacs PHP Mode

-[![Emacs: 29.4](https://img.shields.io/badge/Emacs-29.4-blue.svg)](https://www.gnu.org/software/emacs/) -[![lang: PHP 8.3](https://img.shields.io/badge/lang-PHP%208.3-brightgreen.svg)](https://php.net/manual/migration83.php) +[![Emacs: 30.0](https://img.shields.io/badge/Emacs-30.0-blue.svg)](https://www.gnu.org/software/emacs/) +[![lang: PHP 8.4](https://img.shields.io/badge/lang-PHP%208.4-brightgreen.svg)](https://www.php.net/releases/8.4/) [![Build Status](https://github.com/emacs-php/php-mode/workflows/CI/badge.svg)](https://github.com/emacs-php/php-mode/actions) [![GPL v3](https://img.shields.io/badge/license-GPL_v3-green.svg)][gpl-v3]
[![NonGNU ELPA][nongnu-elpa-badge]][nongnu-elpa] @@ -17,10 +17,15 @@ A powerful and flexible Emacs major mode for editing PHP scripts [GitHubプロジェクト][php-mode]にissueを作成してバグ報告や機能リクエストを送ってください。 > [!NOTE] -> [最新版][releases]のPHP ModeはEmacs 29をサポートしています。
アップグレードに伴うトラブルは[Discussions][disscussions-emacs29]に気軽に書き込んでください。 +> [最新版][releases]のPHP ModeはEmacs 30をサポートしています。
アップグレードに伴うトラブルは[Discussions][disscussions-emacs30]に気軽に書き込んでください。 + +> [!WARNING] +> Emacsをアップグレードした直後に初めてPHPファイルを開いたときに、CC Mode関連のエラーが発生する可能性があります。これは以前のバージョンのEmacsでバイトコンパイルされたPHP Modeがディスクにキャッシュされているために起こるので、PHP Modeの再インストールによって解決します。 +> +> **`M-x php-mode-debug-reinstall`** または **`M-x package-reinstall php-mode`** コマンドをお試しください。 [releases]: https://github.com/emacs-php/php-mode/releases -[disscussions-emacs29]: https://github.com/emacs-php/php-mode/discussions/751 +[disscussions-emacs30]: https://github.com/emacs-php/php-mode/discussions/798 ## インストール diff --git a/README.md b/README.md index f546d25a..8ba8a04b 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@

Emacs PHP Mode

-[![Emacs: 29.4](https://img.shields.io/badge/Emacs-29.4-blue.svg)](https://www.gnu.org/software/emacs/) -[![lang: PHP 8.3](https://img.shields.io/badge/lang-PHP%208.3-brightgreen.svg)](https://www.php.net/manual/migration83.php) +[![Emacs: 30.0](https://img.shields.io/badge/Emacs-30.0-blue.svg)](https://www.gnu.org/software/emacs/) +[![lang: PHP 8.4](https://img.shields.io/badge/lang-PHP%208.4-brightgreen.svg)](https://www.php.net/releases/8.4/) [![Build Status](https://github.com/emacs-php/php-mode/workflows/CI/badge.svg)](https://github.com/emacs-php/php-mode/actions) [![GPL v3](https://img.shields.io/badge/license-GPL_v3-green.svg)][gpl-v3]
[![NonGNU ELPA][nongnu-elpa-badge]][nongnu-elpa] @@ -17,10 +17,15 @@ English   |   [日本語](README.ja.md) Please submit any bug reports or feature requests by creating issues on [the GitHub page for PHP Mode][php-mode]. > [!NOTE] -> The [latest version][releases] of PHP Mode supports Emacs 29.
Please feel free to [write to disucuss][disscussions-emacs29] if you have problems upgrading to Emacs 29. +> The [latest version][releases] of PHP Mode supports Emacs 30.
Please feel free to [write to disucuss][disscussions-emacs30] if you have problems upgrading to Emacs 29. + +> [!WARNING] +> After upgrading Emacs, when you open a PHP file for the first time, you may encounter errors related to CC Mode. These errors occur because a previously byte-compiled version of PHP Mode, cached on your disk, differs from the newly installed one. Reinstalling PHP Mode should resolve the issue. +> +> Try running **`M-x php-mode-debug-reinstall`** or **`M-x package-reinstall php-mode`**. [releases]: https://github.com/emacs-php/php-mode/releases -[disscussions-emacs29]: https://github.com/emacs-php/php-mode/discussions/751 +[disscussions-emacs30]: https://github.com/emacs-php/php-mode/discussions/798 ## Installation From 346ee2ab798868ac8865bf4d05253ab62f0070ee Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Fri, 20 Dec 2024 00:53:18 +0900 Subject: [PATCH 115/125] Update CHANGELOG for 1.27.0 --- CHANGELOG.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2408957b..1aa2e9cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,35 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this +## [1.27.0] - 2024-12-20 + +### Added + + * Support PHP 8.4 property-hooks ([#797]) + +### Changed + + * Improve `php-syntax-propertize-extend-region` efficiency ([#789], thanks [@phil-s]!) + * Update `php-phpdoc-type-names` to support [PHPStan 2.0.4] ([#795]) + +### Fixed + + * Fix Emacs 30 byte-compile errors ([#792]) + * Use `when-let*` instead of `when-let` to enhance Emacs 30 compatibility ([#796]) + +### Removed + + * Drop support for Emacs 26 ([#788]) + +[@phil-s]: https://github.com/phil-s +[PHPStan 2.0.4]: https://github.com/phpstan/phpstan/releases/tag/2.0.4 +[#788]: https://github.com/emacs-php/php-mode/pull/788 +[#789]: https://github.com/emacs-php/php-mode/pull/789 +[#792]: https://github.com/emacs-php/php-mode/pull/792 +[#795]: https://github.com/emacs-php/php-mode/pull/795 +[#796]: https://github.com/emacs-php/php-mode/pull/796 +[#797]: https://github.com/emacs-php/php-mode/pull/797 + ## [1.26.1] - 2024-09-13 ### Added From 878e31369c81010d0ec296b23ef62dfdf87bd506 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Fri, 20 Dec 2024 01:43:28 +0900 Subject: [PATCH 116/125] Update README --- README.ja.md | 4 ++-- README.md | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/README.ja.md b/README.ja.md index f9312302..81c0f510 100644 --- a/README.ja.md +++ b/README.ja.md @@ -17,7 +17,7 @@ A powerful and flexible Emacs major mode for editing PHP scripts [GitHubプロジェクト][php-mode]にissueを作成してバグ報告や機能リクエストを送ってください。 > [!NOTE] -> [最新版][releases]のPHP ModeはEmacs 30をサポートしています。
アップグレードに伴うトラブルは[Discussions][disscussions-emacs30]に気軽に書き込んでください。 +> [最新版][releases]のPHP ModeはEmacs 30をサポートしています。
アップグレードに伴うトラブルは[Discussions][discussions-emacs30]に気軽に書き込んでください。 > [!WARNING] > Emacsをアップグレードした直後に初めてPHPファイルを開いたときに、CC Mode関連のエラーが発生する可能性があります。これは以前のバージョンのEmacsでバイトコンパイルされたPHP Modeがディスクにキャッシュされているために起こるので、PHP Modeの再インストールによって解決します。 @@ -25,7 +25,7 @@ A powerful and flexible Emacs major mode for editing PHP scripts > **`M-x php-mode-debug-reinstall`** または **`M-x package-reinstall php-mode`** コマンドをお試しください。 [releases]: https://github.com/emacs-php/php-mode/releases -[disscussions-emacs30]: https://github.com/emacs-php/php-mode/discussions/798 +[discussions-emacs30]: https://github.com/emacs-php/php-mode/discussions/798 ## インストール diff --git a/README.md b/README.md index 8ba8a04b..490b3f08 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,8 @@ English   |   [日本語](README.ja.md) Please submit any bug reports or feature requests by creating issues on [the GitHub page for PHP Mode][php-mode]. > [!NOTE] -> The [latest version][releases] of PHP Mode supports Emacs 30.
Please feel free to [write to disucuss][disscussions-emacs30] if you have problems upgrading to Emacs 29. +> The [latest version][releases] of PHP Mode supports Emacs 30. +> Please feel free to [open a discussion][discussions-emacs30] if you have any issues upgrading to Emacs 30. > [!WARNING] > After upgrading Emacs, when you open a PHP file for the first time, you may encounter errors related to CC Mode. These errors occur because a previously byte-compiled version of PHP Mode, cached on your disk, differs from the newly installed one. Reinstalling PHP Mode should resolve the issue. @@ -25,25 +26,26 @@ Please submit any bug reports or feature requests by creating issues on [the Git > Try running **`M-x php-mode-debug-reinstall`** or **`M-x package-reinstall php-mode`**. [releases]: https://github.com/emacs-php/php-mode/releases -[disscussions-emacs30]: https://github.com/emacs-php/php-mode/discussions/798 +[discussions-emacs30]: https://github.com/emacs-php/php-mode/discussions/798 ## Installation -**PHP Mode works with Emacs 27.1 or later**. For details on supported versions, see [Supported Version]. Emacs 28 or later can be installed simply by running the following command. +**PHP Mode works with Emacs 27.1 or later.** For details on supported versions, see [Supported Version]. +On Emacs 28 or later, you can install it simply by running: ``` M-x package-install php-mode ``` -By [adding MELPA to `package-archives`][melpa-getting-started], you can extend Emacs with many packages from the web. +By [adding MELPA to `package-archives`][melpa-getting-started], you can extend Emacs with numerous packages from the web. -If you don't want to depend on a package manager, you can install Lisp files directly in the traditional way. See [Manual installation][wiki-manual-installation] for our recommended setup method. +If you prefer not to rely on a package manager, you can install the Lisp files directly in the traditional manner. See [Manual installation][wiki-manual-installation] for our recommended method. ## Configuration ### Personal Settings -You can add configurations for PHP mode in the .emacs file (`~/.emacs.d/init.el`): +You can add configurations for PHP Mode in your `.emacs` file (`~/.emacs.d/init.el`): ```lisp (defun my-php-mode-init () @@ -67,7 +69,7 @@ You can add configurations for PHP mode in the .emacs file (`~/.emacs.d/init.el` ### Project Setting -You can add project-specific settings by creating a `.dir-locals.el` or `.dir-locals-2.el` file in the project's root directory. It is recommended not to put these files under version control, as they depend on the packages installed in each user's Emacs. +You can add project-specific settings by creating a `.dir-locals.el` or `.dir-locals-2.el` file in the project's root directory. It is recommended not to put these files under version control, as they depend on the packages installed on each user's Emacs. ```lisp ((nil @@ -77,13 +79,12 @@ You can add project-specific settings by creating a `.dir-locals.el` or `.dir-lo ## Reporting Bugs -When reporting a bug please run the function `M-x php-mode-debug` and include its output in your bug report. This helps up reproduce any problem you may have. +When reporting a bug, please run `M-x php-mode-debug` and include its output in your bug report. This helps us reproduce any issues you may be experiencing. ## How to Contribute Please see [CONTRIBUTING.md](CONTRIBUTING.md#english). - ## Copyright PHP Mode is licensed under [GNU General Public License Version 3][gpl-v3] (GPLv3). From 6af84c2b4f558eec14ae74dbe6fb979da24d5b86 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sun, 22 Dec 2024 14:59:36 +0900 Subject: [PATCH 117/125] Use when-let* instead of let and when --- lisp/php.el | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lisp/php.el b/lisp/php.el index c08227b1..2e05d2a5 100644 --- a/lisp/php.el +++ b/lisp/php.el @@ -664,17 +664,15 @@ Currently there are `php-mode' and `php-ts-mode'." (defun php-current-class () "Insert current class name if cursor in class context." (interactive) - (let ((matched (php-get-current-element php--re-classlike-pattern))) - (when matched - (insert (concat matched php-class-suffix-when-insert))))) + (when-let* ((matched (php-get-current-element php--re-classlike-pattern))) + (insert (concat matched php-class-suffix-when-insert)))) ;;;###autoload (defun php-current-namespace () "Insert current namespace if cursor in namespace context." (interactive) - (let ((matched (php-get-current-element php--re-namespace-pattern))) - (when matched - (insert (concat matched php-namespace-suffix-when-insert))))) + (when-let* ((matched (php-get-current-element php--re-namespace-pattern))) + (insert (concat matched php-namespace-suffix-when-insert)))) ;;;###autoload (defun php-copyit-fqsen () From 0a33fc0ae4a3c645b434703d2af373647076566c Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Fri, 10 Jan 2025 05:38:20 +0900 Subject: [PATCH 118/125] Fix array alignment issue when an empty line is present Fixed https://github.com/emacs-php/php-mode/issues/793 --- lisp/php-mode.el | 7 ++++--- tests/indent/issue-793.php | 9 +++++++++ tests/php-mode-test.el | 14 +++++++------- 3 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 tests/indent/issue-793.php diff --git a/lisp/php-mode.el b/lisp/php-mode.el index e1736b28..afd51294 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -627,8 +627,7 @@ but only if the setting is enabled." ((assq 'defun-block-intro c-syntactic-context) nil) ((assq 'defun-close c-syntactic-context) nil) ((assq 'statement-cont c-syntactic-context) nil) - (t - (save-excursion + ((save-excursion (beginning-of-line) (let ((beginning-of-langelem (cdr langelem)) (beginning-of-current-line (point)) @@ -651,8 +650,10 @@ but only if the setting is enabled." (skip-chars-backward " \r\n") (backward-char 1)) (and (not (eq (point) beginning-of-current-line)) + (not (php-in-string-or-comment-p)) (not (looking-at-p ",")) - (not (php-in-string-or-comment-p)))) + (save-excursion + (backward-char) (not (looking-at-p ","))))) '+) (t nil))))))) diff --git a/tests/indent/issue-793.php b/tests/indent/issue-793.php new file mode 100644 index 00000000..917666d4 --- /dev/null +++ b/tests/indent/issue-793.php @@ -0,0 +1,9 @@ + 1, // ###php-mode-test### ((indent 4)) + 'bar' => 2, + +'buz' => 3, // ###php-mode-test### ((indent 4)) +'buzbuz' => 4, // ###php-mode-test### ((indent 4)) +]; diff --git a/tests/php-mode-test.el b/tests/php-mode-test.el index 4d36579b..6881ec54 100644 --- a/tests/php-mode-test.el +++ b/tests/php-mode-test.el @@ -644,14 +644,14 @@ Meant for `php-mode-test-issue-503'." (goto-char (point-min)) (should (eq (php-mode-test-in-function-p nil) nil)))) -(ert-deftest php-mode-test-issue-623 () - "Proper alignment object -> accessor." - (with-php-mode-test ("indent/issue-623.php" :indent t :magic t))) - -(ert-deftest php-mode-test-issue-702 () - "Proper alignment arglist." +(ert-deftest php-mode-test-indentation-issues () + ;; Proper alignment object -> accessor. + (with-php-mode-test ("indent/issue-623.php" :indent t :magic t)) + ;; Proper alignment arglist. (with-php-mode-test ("indent/issue-702.php" :indent t :magic t)) - (with-php-mode-test ("indent/issue-726.php" :indent t :magic t))) + (with-php-mode-test ("indent/issue-726.php" :indent t :magic t)) + ;; Proper alignment arglist that contains empty lines. + (with-php-mode-test ("indent/issue-793.php" :indent t :magic t))) (ert-deftest php-mode-test-php74 () "Test highlighting language constructs added in PHP 7.4." From 5b6cc1c068ba759dcf30067ad1e048b3693a40d7 Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Mon, 24 Feb 2025 14:59:51 -0800 Subject: [PATCH 119/125] ci: Test Emacs 30.1 --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cc9294f5..d3f9e107 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,6 +23,7 @@ jobs: - "27.2" - "28.2" - "29.4" + - "30.1" experimental: [false] include: - os: ubuntu-latest From b9d7f07b1a3824e117fd82370a41801399f4aae8 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Tue, 1 Apr 2025 02:10:30 +0900 Subject: [PATCH 120/125] Addreadonly class modifier to imenu --- CHANGELOG.md | 9 ++++++++- lisp/php.el | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1aa2e9cc..61154bc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,14 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles. - +## Unreleased + +### Changed + + * Add `readonly` class modifier to [Imenu] ([#802]) + +[Imenu]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Imenu.html +[#802]: https://github.com/emacs-php/php-mode/pull/802 ## [1.27.0] - 2024-12-20 diff --git a/lisp/php.el b/lisp/php.el index 2e05d2a5..c3491fa9 100644 --- a/lisp/php.el +++ b/lisp/php.el @@ -325,12 +325,18 @@ can be used to match against definitions for that classlike." ;; First see if 'abstract' or 'final' appear, although really these ;; are not valid for all values of `type' that the function ;; accepts. - "^\\s-*\\(?:\\(?:abstract\\|final\\)\\s-+\\)?" + (eval-when-compile + (rx line-start + (* (syntax whitespace)) + (? (or "abstract" "final" "readonly") + (+ (syntax whitespace))))) ;; The classlike type type ;; Its name, which is the first captured group in the regexp. We ;; allow backslashes in the name to handle namespaces, but again ;; this is not necessarily correct for all values of `type'. + ;; (rx (+ (syntax whitespace)) + ;; (group (+ (or (syntax word) "\\" (syntax symbol))))) "\\s-+\\(\\(?:\\sw\\|\\\\\\|\\s_\\)+\\)"))) (defconst php-imenu-generic-expression-default From 4a42c293d7644bf1129d6327c5d3d2de721b45bc Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Tue, 1 Apr 2025 02:10:55 +0900 Subject: [PATCH 121/125] Add `enum` support to `php-current-class` --- CHANGELOG.md | 1 + lisp/php.el | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61154bc3..feb711f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this ### Changed * Add `readonly` class modifier to [Imenu] ([#802]) + * Add `enum` support to `php-current-class` ([#802]) [Imenu]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Imenu.html [#802]: https://github.com/emacs-php/php-mode/pull/802 diff --git a/lisp/php.el b/lisp/php.el index c3491fa9..6a2f40f8 100644 --- a/lisp/php.el +++ b/lisp/php.el @@ -471,7 +471,7 @@ can be used to match against definitions for that classlike." (defconst php--re-classlike-pattern (eval-when-compile - (php-create-regexp-for-classlike (regexp-opt '("class" "interface" "trait"))))) + (php-create-regexp-for-classlike (regexp-opt '("class" "interface" "trait" "enum"))))) (defvar php--analysis-syntax-table (eval-when-compile From 462b62248f7b3c6550ceea1b44760ddd951ab7ab Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Tue, 22 Apr 2025 17:20:13 -0700 Subject: [PATCH 122/125] fix: Warning missing lexical-binding cookie --- Eask | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Eask b/Eask index 2a90ee52..88e00bf2 100644 --- a/Eask +++ b/Eask @@ -1,3 +1,5 @@ +;; -*- mode: eask; lexical-binding: t -*- + (package "php-mode" "1.26.1" "Major mode for editing PHP code") From a84469e6a6c95977fdc6ba967b931df5f33e08e3 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sat, 24 May 2025 15:28:56 +0900 Subject: [PATCH 123/125] Removes hardcoding of implicit paths in php that are not guaranteed to exist --- CHANGELOG.md | 2 ++ lisp/php.el | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index feb711f9..115ef78d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,9 +8,11 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this * Add `readonly` class modifier to [Imenu] ([#802]) * Add `enum` support to `php-current-class` ([#802]) + * Remove hardcoding of implicit paths in `php` that are not guaranteed to exist ([#803]) [Imenu]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Imenu.html [#802]: https://github.com/emacs-php/php-mode/pull/802 +[#803]: https://github.com/emacs-php/php-mode/pull/803 ## [1.27.0] - 2024-12-20 diff --git a/lisp/php.el b/lisp/php.el index 6a2f40f8..9ce9eecf 100644 --- a/lisp/php.el +++ b/lisp/php.el @@ -49,7 +49,7 @@ :link '(url-link :tag "Official Site" "https://github.com/emacs-php/php-mode") :link '(url-link :tag "PHP Mode Wiki" "https://github.com/emacs-php/php-mode/wiki")) -(defcustom php-executable (or (executable-find "php") "/usr/bin/php") +(defcustom php-executable (or (executable-find "php") "php") "The location of the PHP executable." :group 'php :tag "PHP Executable" From aaaa85c7cdefcd5032df0328f52ea720e7718930 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 26 May 2025 23:00:22 +0900 Subject: [PATCH 124/125] Impl php-phpdbg-disassemble-file and php-parse-file --- lisp/php.el | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/lisp/php.el b/lisp/php.el index 9ce9eecf..ef46272c 100644 --- a/lisp/php.el +++ b/lisp/php.el @@ -55,6 +55,18 @@ :tag "PHP Executable" :type 'string) +(defcustom php-phpdbg-executable (list "phpdbg") + "The location of the PHPDBG executable." + :group 'php + :tag "PHP PHPDBG Executable" + :type '(repeat string)) + +(defcustom php-php-parse-executabe nil + "The location of the php-parse executable." + :group 'php + :tag "PHP php-parse Executable" + :type '(repeat string)) + (defcustom php-site-url "https://www.php.net/" "Default PHP.net site URL. @@ -804,5 +816,29 @@ When `DOCUMENT-ROOT' is NIL, the document root is obtained from `ROUTER-OR-DIR'. #'file-exists-p)))) (find-file file)) + +(defun php-phpdbg-disassemble-file (file) + "Read PHP FILE and print opcodes." + (interactive (list (if (or buffer-file-name (zerop (prefix-numeric-value current-prefix-arg))) + buffer-file-name + (expand-file-name + (read-file-name "Select PHP file: " default-directory buffer-file-name))))) + (let ((args `(,@php-phpdbg-executable "-dopcache.enable_cli=1" "-p*" ,file))) + (compile (mapconcat #'shell-quote-argument args " ")))) + +(defun php-parse-file (file) + "Parse PHP FILE and print node tree." + (interactive (list (if (or buffer-file-name (zerop (prefix-numeric-value current-prefix-arg))) + buffer-file-name + (expand-file-name + (read-file-name "Select PHP file: " default-directory buffer-file-name))))) + (let* ((project-dir (php-project-get-root-dir)) + (executable (or php-php-parse-executabe + (file-executable-p (expand-file-name "vendor/bin/php-parse" project-dir)) + (executable-find "php-parse") + (user-error "`php-parse' command not found"))) + (args `(,@(if (listp executable) executable (list executable)) ,file))) + (compile (mapconcat #'shell-quote-argument args " ")))) + (provide 'php) ;;; php.el ends here From 40b8abed3079771e060dd99a56703520dabf5be4 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Mon, 2 Jun 2025 22:08:47 +0900 Subject: [PATCH 125/125] Use save-match-data in php-local-manual.el --- lisp/php-local-manual.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lisp/php-local-manual.el b/lisp/php-local-manual.el index ba4f854e..eec5cc3a 100644 --- a/lisp/php-local-manual.el +++ b/lisp/php-local-manual.el @@ -194,6 +194,7 @@ current `tags-file-name'." (setq php-local-manual--completion-table php-table)))) (defun php-local-manual-build-table-from-file (filename) + "Build a table of PHP function names from FILENAME." (let ((table (make-vector 1022 0)) (buf (find-file-noselect filename))) (with-current-buffer buf @@ -208,10 +209,11 @@ current `tags-file-name'." (defun php-local-manual-build-table-from-path (path) "Return list of PHP function name from `PATH' directory." - (cl-loop for file in (directory-files path nil "^function\\..+\\.html$") - if (string-match "\\.\\([-a-zA-Z_0-9]+\\)\\.html$" file) - collect (replace-regexp-in-string - "-" "_" (substring file (match-beginning 1) (match-end 1)) t))) + (save-match-data + (cl-loop for file in (directory-files path nil "^function\\..+\\.html$") + if (string-match "\\.\\([-a-zA-Z_0-9]+\\)\\.html$" file) + collect (replace-regexp-in-string + "-" "_" (substring file (match-beginning 1) (match-end 1)) t)))) (provide 'php-local-manual) ;;; php-local-manual.el ends here