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
29 changes: 19 additions & 10 deletions lisp/php-keywords.el
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@
;; of scope, and deliberately not duplicated here:
;;
;; - built-in function names -- see lisp/php-defs.el;
;; - the magic constants (`__LINE__' and friends), which are written
;; upper-case and matched case-sensitively -- php.el owns that list
;; as `php-magical-constants', and both major modes build their
;; font-lock rule from it directly;
;; - predefined runtime constants such as `PHP_EOL' or `PHP_INT_MAX',
;; which are library symbols rather than language keywords.
;;
;; `php-magical-constants' is the one exception to the naming convention
;; above. It is a long-standing public symbol that php.el used to own,
;; and both major modes build their font-lock rule straight from it, so
;; it keeps its name; php.el requires this file and re-exports it.

;;; Code:

Expand Down Expand Up @@ -226,21 +227,29 @@ Match against buffer text with `case-fold-search' bound to non-nil.")
;; PHP language constants; stored lower-case here, same convention as
;; every other list in this file).
;;
;; The magic constants (`__CLASS__', `__LINE__', ...) are intentionally
;; NOT mirrored here. They are not part of php-cc-mode.el's 367-609
;; c-lang-defconst block either: both major modes fontify them straight
;; from php.el's `php-magical-constants', which stays the single source
;; of truth for that list.
;; The magic constants (`__CLASS__', `__LINE__', ...) are not part of
;; php-cc-mode.el's 367-609 c-lang-defconst block: both major modes
;; fontify them straight from `php-magical-constants', which php.el used
;; to define and which now sits below, next to the rest of the
;; vocabulary.
(defconst php-keywords--constants
'("true" "false" "null")
"PHP literal keywords `true', `false' and `null' (case-insensitive).
The upper-case magic constants (`__LINE__' and friends) are matched
case-sensitively and live in php.el's `php-magical-constants'.")
case-sensitively; see `php-magical-constants'.")

(defconst php-keywords--constants-re
(regexp-opt php-keywords--constants 'symbols)
"`regexp-opt' of `php-keywords--constants', symbol-bounded.
Match against buffer text with `case-fold-search' bound to non-nil.")

(defconst php-magical-constants
'("__CLASS__" "__DIR__" "__FILE__" "__FUNCTION__" "__LINE__"
"__METHOD__" "__NAMESPACE__" "__TRAIT__")
"Magical keyword that is expanded at compile time.

These are different from \"constants\" in strict terms.
see https://www.php.net/manual/language.constants.predefined.php")

(provide 'php-keywords)
;;; php-keywords.el ends here
9 changes: 1 addition & 8 deletions lisp/php.el
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
(require 'cc-engine)
(require 'flymake)
(require 'php-core)
(require 'php-keywords)
(require 'php-project)
(require 'rx)

Expand Down Expand Up @@ -244,14 +245,6 @@ out and get `php-default-major-mode' instead."
:type 'face)

;;; PHP Keywords
(defconst php-magical-constants
'("__CLASS__" "__DIR__" "__FILE__" "__FUNCTION__" "__LINE__"
"__METHOD__" "__NAMESPACE__" "__TRAIT__")
"Magical keyword that is expanded at compile time.

These are different from \"constants\" in strict terms.
see https://www.php.net/manual/language.constants.predefined.php")

(defconst php-re-token-symbols
(eval-when-compile
(regexp-opt (list "&" "&=" "array(" "(array)" "&&" "||" "(bool)" "(boolean)" "break;" "?>" "%>"
Expand Down
Loading