|
53 | 53 | ;; of scope, and deliberately not duplicated here: |
54 | 54 | ;; |
55 | 55 | ;; - built-in function names -- see lisp/php-defs.el; |
56 | | -;; - the magic constants (`__LINE__' and friends), which are written |
57 | | -;; upper-case and matched case-sensitively -- php.el owns that list |
58 | | -;; as `php-magical-constants', and both major modes build their |
59 | | -;; font-lock rule from it directly; |
60 | 56 | ;; - predefined runtime constants such as `PHP_EOL' or `PHP_INT_MAX', |
61 | 57 | ;; which are library symbols rather than language keywords. |
| 58 | +;; |
| 59 | +;; `php-magical-constants' is the one exception to the naming convention |
| 60 | +;; above. It is a long-standing public symbol that php.el used to own, |
| 61 | +;; and both major modes build their font-lock rule straight from it, so |
| 62 | +;; it keeps its name; php.el requires this file and re-exports it. |
62 | 63 |
|
63 | 64 | ;;; Code: |
64 | 65 |
|
@@ -226,21 +227,29 @@ Match against buffer text with `case-fold-search' bound to non-nil.") |
226 | 227 | ;; PHP language constants; stored lower-case here, same convention as |
227 | 228 | ;; every other list in this file). |
228 | 229 | ;; |
229 | | -;; The magic constants (`__CLASS__', `__LINE__', ...) are intentionally |
230 | | -;; NOT mirrored here. They are not part of php-cc-mode.el's 367-609 |
231 | | -;; c-lang-defconst block either: both major modes fontify them straight |
232 | | -;; from php.el's `php-magical-constants', which stays the single source |
233 | | -;; of truth for that list. |
| 230 | +;; The magic constants (`__CLASS__', `__LINE__', ...) are not part of |
| 231 | +;; php-cc-mode.el's 367-609 c-lang-defconst block: both major modes |
| 232 | +;; fontify them straight from `php-magical-constants', which php.el used |
| 233 | +;; to define and which now sits below, next to the rest of the |
| 234 | +;; vocabulary. |
234 | 235 | (defconst php-keywords--constants |
235 | 236 | '("true" "false" "null") |
236 | 237 | "PHP literal keywords `true', `false' and `null' (case-insensitive). |
237 | 238 | The upper-case magic constants (`__LINE__' and friends) are matched |
238 | | -case-sensitively and live in php.el's `php-magical-constants'.") |
| 239 | +case-sensitively; see `php-magical-constants'.") |
239 | 240 |
|
240 | 241 | (defconst php-keywords--constants-re |
241 | 242 | (regexp-opt php-keywords--constants 'symbols) |
242 | 243 | "`regexp-opt' of `php-keywords--constants', symbol-bounded. |
243 | 244 | Match against buffer text with `case-fold-search' bound to non-nil.") |
244 | 245 |
|
| 246 | +(defconst php-magical-constants |
| 247 | + '("__CLASS__" "__DIR__" "__FILE__" "__FUNCTION__" "__LINE__" |
| 248 | + "__METHOD__" "__NAMESPACE__" "__TRAIT__") |
| 249 | + "Magical keyword that is expanded at compile time. |
| 250 | +
|
| 251 | +These are different from \"constants\" in strict terms. |
| 252 | +see https://www.php.net/manual/language.constants.predefined.php") |
| 253 | + |
245 | 254 | (provide 'php-keywords) |
246 | 255 | ;;; php-keywords.el ends here |
0 commit comments