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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this
* Shows whether it is on, what is configured, and what is available
* Add `php-ide-eglot-activate`, which registers `php-ide-eglot-executable` into `eglot-server-programs`
* Buffer-local, so only buffers that set the variable are affected; previously the variable had no effect on Eglot at all
* Add `php-cc-mode` as a forward-compatible alias for the CC Mode based `php-mode`
* Lets configuration and third-party code refer to the CC Mode implementation by the name it will keep once `php-mode` becomes cc-mode independent; loading it has no effect on `php-mode` itself
* `php-cc-mode-hook`, `php-cc-mode-lineup-cascaded-calls` and `php-cc-mode-enable-backup-style-variables` are provided as aliases of their current `php-mode-*` counterparts

### Changed

Expand Down
2 changes: 2 additions & 0 deletions Eask
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"lisp/php-complete.el"
"lisp/php-defs.el"
"lisp/php-indent.el"
"lisp/php-style.el"
"lisp/php-keywords.el"
"lisp/php-face.el"
"lisp/php-flymake.el"
Expand All @@ -23,6 +24,7 @@
"lisp/php-ide-phpactor.el"
"lisp/php-ide.el"
"lisp/php-align.el"
"lisp/php-cc-mode.el"
"lisp/php-mode-debug.el")

(script "test" "echo \"Error: no test specified\" && exit 1")
Expand Down
80 changes: 80 additions & 0 deletions lisp/php-cc-mode.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
;;; php-cc-mode.el --- Compatibility alias for the CC Mode based php-mode -*- lexical-binding: t; -*-

;; Copyright (C) 2026 Friends of Emacs-PHP development

;; Author: USAMI Kenta <tadsan@zonu.me>
;; Maintainer: USAMI Kenta <tadsan@zonu.me>
;; URL: https://github.com/emacs-php/php-mode
;; Keywords: languages php
;; License: GPL-3.0-or-later

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;; This file is a forward-compatibility shim introduced while PHP Mode is
;; being reworked to no longer depend on CC Mode.
;;
;; In the target design, the CC Mode based implementation is renamed to
;; `php-cc-mode' and the name `php-mode' is reused for a cc-mode
;; independent major mode. During the transition `php-mode' (in
;; php-mode.el) is still the CC Mode based implementation, so this file
;; only establishes the *names* that code will migrate to, without
;; changing any behavior:
;;
;; - `php-cc-mode' is provided as an alias for `php-mode', so that
;; configuration or third-party code written against the new name
;; works now and keeps working after the eventual swap.
;; - Variable names that will belong to `php-cc-mode' are provided as
;; aliases of their current `php-mode-*' counterparts.
;;
;; Loading this file has no effect on `php-mode' itself: it does not
;; register any `auto-mode-alist' / `interpreter-mode-alist' entry, and
;; it does not redefine `php-mode'. It is intentionally kept out of the
;; `php-mode' require graph and is loaded only when something asks for
;; `php-cc-mode'.

;;; Code:

(require 'php-mode)

;;;###autoload
(defalias 'php-cc-mode 'php-mode
"Major mode for editing PHP code, based on CC Mode.

This is currently an alias for `php-mode'. It exists so that code can
already refer to the CC Mode based implementation by the name it will
keep (`php-cc-mode') once the default `php-mode' becomes the cc-mode
independent implementation.")

;; Hook: configuration hung on `php-cc-mode-hook' should run for the CC
;; Mode based mode. While `php-cc-mode' is an alias for `php-mode', the
;; hook is an alias too, so setting either one has the same effect.
(defvaralias 'php-cc-mode-hook 'php-mode-hook
"Hook run when entering `php-cc-mode'.
Currently an alias for `php-mode-hook'.")

;; Variables that will be owned by `php-cc-mode' in the target design.
;; They are aliased to the current `php-mode-*' names so that either
;; spelling works during the transition.
(defvaralias 'php-cc-mode-lineup-cascaded-calls 'php-mode-lineup-cascaded-calls
"Indent chained method calls to the previous line.
Currently an alias for `php-mode-lineup-cascaded-calls'.")

(defvaralias 'php-cc-mode-enable-backup-style-variables 'php-mode-enable-backup-style-variables
"When non-nil, back up values set by hook and buffer local variables.
Currently an alias for `php-mode-enable-backup-style-variables'.")

(provide 'php-cc-mode)
;;; php-cc-mode.el ends here
46 changes: 4 additions & 42 deletions lisp/php-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,7 @@ Turning this on will open it whenever `php-mode' is loaded."
(when val
(speedbar 1))))

(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."
:tag "PHP Mode Template Compatibility"
:type 'boolean)
;; `php-mode-template-compatibility' is defined in php.el (shared).

(define-obsolete-variable-alias 'php-lineup-cascaded-calls 'php-mode-lineup-cascaded-calls "1.20.0")
(defcustom php-mode-lineup-cascaded-calls nil
Expand Down Expand Up @@ -216,31 +212,14 @@ enabled."
:tag "PHP Mode Hook"
:type 'hook)

(defcustom php-mode-pear-hook nil
"Hook called when a PHP PEAR file is opened with `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'."
:tag "PHP Mode Drupal Hook"
:type 'hook)

(defcustom php-mode-wordpress-hook nil
"Hook called when a WordPress file is opened with `php-mode'."
:tag "PHP Mode WordPress Hook"
:type 'hook)
;; `php-mode-pear-hook', `php-mode-drupal-hook', `php-mode-wordpress-hook'
;; and `php-mode-psr2-hook' are defined in php.el (shared).

(defcustom php-mode-symfony2-hook nil
"Hook called when a Symfony2 file is opened with `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'."
: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."
Expand All @@ -254,24 +233,7 @@ Turning this on will force PEAR rules on all PHP files."
:type '(choice (const :tag "Warn" t) (const :tag "Don't warn" nil)))
(make-obsolete-variable 'php-mode-warn-if-mumamo-off 'php-mode-warn-if-html-template "2.0.0")

(defcustom php-mode-coding-style 'pear
"Select default coding style to use with `php-mode'.
This variable can take one of the following symbol values:

`Default' - use a reasonable default style for PHP.
`PSR-2' - use PSR standards (PSR-2, PSR-12).
`PEAR' - use coding styles preferred for PEAR code and modules.
`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."
:tag "PHP Mode Coding Style"
:type '(choice (const :tag "Default" php)
(const :tag "PEAR" pear)
(const :tag "Drupal" drupal)
(const :tag "WordPress" wordpress)
(const :tag "Symfony2" symfony2)
(const :tag "PSR-2" psr2))
:initialize #'custom-initialize-default)
;; `php-mode-coding-style' is defined in php.el (shared).

;; Since this function has a bad influence on the environment of many users,
;; temporarily disable it
Expand Down
Loading
Loading