Skip to content

Commit 45bb2bf

Browse files
committed
Drop the duplicated and unused keyword tables
php-keywords--magic-constants mirrored php.el's php-magical-constants plus "PHP_EOL", and the file's own commentary conceded the cost: "keep the two lists in sync if php-magical-constants ever changes". Nothing reads it -- both major modes build their php-magical-constant font-lock rule straight from php.el's list -- so remove it and leave php.el as the single source of truth. Note that the two lists were never interchangeable: PHP_EOL is a predefined runtime constant rather than a magic constant, so unifying them under one name would have started fontifying PHP_EOL as a magic constant. Predefined library constants stay out of this module; the commentary now says so. php-keywords--magic-methods has no reader either. It was supplemented wholesale from the PHP manual rather than derived from php-cc-mode.el, so it is not needed to reproduce the current fontification; drop it until something actually wants it. Also correct the commentary, which claimed php-mode.el was "not yet written": it exists, still fontifies through CC Mode, and does not require this file yet.
1 parent 7da776b commit 45bb2bf

1 file changed

Lines changed: 25 additions & 80 deletions

File tree

lisp/php-keywords.el

Lines changed: 25 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@
2828
;; 367-609 as of the `php-cc-mode' freeze) into plain, cc-mode independent
2929
;; `defconst' lists and pre-compiled `regexp-opt' regexps.
3030
;;
31-
;; The purpose is to give the upcoming cc-free `php-mode' font-lock
32-
;; implementation (see lisp/php-mode.el, not yet written) a single source
33-
;; of truth for PHP keywords, without requiring `cc-mode', `cc-langs' or
34-
;; `cc-fonts'.
31+
;; The purpose is to give the upcoming cc-mode independent `php-mode'
32+
;; font-lock implementation a single source of truth for PHP keywords,
33+
;; without requiring `cc-mode', `cc-langs' or `cc-fonts'. Nothing
34+
;; requires this file yet: the current `php-mode' still fontifies through
35+
;; CC Mode, so these tables have no effect until that work lands.
3536
;;
3637
;; Naming convention: for every category NAME there is
3738
;; - `php-keywords--NAME' a list of keyword strings (lower-case)
@@ -48,17 +49,16 @@
4849
;; `case-fold-search' to non-nil (or use `font-lock-defaults' with the
4950
;; KEYWORDS-CASE-FOLD slot set to t) while matching against them.
5051
;;
51-
;; Magic constants (`__LINE__' etc.) are the sole exception: by PHP
52-
;; convention they are always written in upper-case, and are therefore
53-
;; stored upper-case and are not meant to be matched case-insensitively.
54-
;; See `php-keywords--constants'.
52+
;; This file holds only the *syntactic* vocabulary of the language. Out
53+
;; of scope, and deliberately not duplicated here:
5554
;;
56-
;; This file intentionally does NOT duplicate lisp/php-defs.el, which
57-
;; holds the (large) table of built-in *function* names. Predefined
58-
;; runtime constants other than `true'/`false'/`null' and the magic
59-
;; constants (e.g. `PHP_INT_MAX') are likewise out of scope here; only
60-
;; `PHP_EOL' is included below because it was explicitly called out in
61-
;; the implementation blueprint as a commonly fontified constant.
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+
;; - predefined runtime constants such as `PHP_EOL' or `PHP_INT_MAX',
61+
;; which are library symbols rather than language keywords.
6262

6363
;;; Code:
6464

@@ -220,82 +220,27 @@ See the commentary in php-keywords.el for provenance.")
220220
Match against buffer text with `case-fold-search' bound to non-nil.")
221221

222222

223-
;;; 5. Language constants and magic constants
223+
;;; 5. Language constants
224224
;;
225-
;; Source:
226-
;; - `c-constant-kwds' -- "true" "false" "null" (case-insensitive
227-
;; PHP language constants; stored lower-case here, same convention
228-
;; as every other list in this file).
229-
;; - php.el's existing `php-magical-constants' -- "__CLASS__"
230-
;; "__DIR__" "__FILE__" "__FUNCTION__" "__LINE__" "__METHOD__"
231-
;; "__NAMESPACE__" "__TRAIT__". These are NOT re-derived from
232-
;; php-cc-mode.el (they are not part of the 367-609 c-lang-defconst
233-
;; block; php-cc-mode.el fontifies them by referring directly to
234-
;; `php-magical-constants' from php.el, see the
235-
;; `php-magical-constant' font-lock rule). They are duplicated
236-
;; into this file's `php-keywords--constants' so this module is
237-
;; self-contained and does not need to `require' php.el; keep the
238-
;; two lists in sync if `php-magical-constants' ever changes.
239-
;;
240-
;; Unlike every other category in this file, magic constants are
241-
;; conventionally written in upper-case only and are matched
242-
;; case-sensitively (that is how php-cc-mode.el's existing font-lock
243-
;; rule for `php-magical-constants' behaves). "true"/"false"/"null"
244-
;; remain lower-case/case-insensitive like the rest of the file.
225+
;; Source: `c-constant-kwds' -- "true" "false" "null" (case-insensitive
226+
;; PHP language constants; stored lower-case here, same convention as
227+
;; every other list in this file).
245228
;;
246-
;; Supplemented: "PHP_EOL", a predefined runtime constant (not a
247-
;; syntactic keyword) called out explicitly in the implementation
248-
;; blueprint (§6) as worth fontifying alongside the magic constants.
249-
;; It is the only predefined library constant included here -- the
250-
;; rest of PHP's predefined constants (PHP_INT_MAX, PHP_VERSION, ...)
251-
;; belong with built-in symbol tables such as lisp/php-defs.el, not in
252-
;; this "language keyword" module.
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.
253234
(defconst php-keywords--constants
254235
'("true" "false" "null")
255236
"PHP literal keywords `true', `false' and `null' (case-insensitive).
256-
See `php-keywords--magic-constants' for the separate, case-sensitive
257-
upper-case magic constants (`__LINE__' and friends) and `PHP_EOL'.")
237+
The upper-case magic constants (`__LINE__' and friends) are matched
238+
case-sensitively and live in php.el's `php-magical-constants'.")
258239

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

264-
(defconst php-keywords--magic-constants
265-
'("__CLASS__" "__DIR__" "__FILE__" "__FUNCTION__" "__LINE__"
266-
"__METHOD__" "__NAMESPACE__" "__TRAIT__" "PHP_EOL")
267-
"PHP magic constants and `PHP_EOL', kept upper-case and matched
268-
case-sensitively (do NOT bind `case-fold-search' to non-nil when using
269-
`php-keywords--magic-constants-re'). Mirrors php.el's
270-
`php-magical-constants' plus \"PHP_EOL\"; see the commentary above.")
271-
272-
(defconst php-keywords--magic-constants-re
273-
(regexp-opt php-keywords--magic-constants 'symbols)
274-
"`regexp-opt' of `php-keywords--magic-constants', symbol-bounded.
275-
Match case-sensitively (do not fold case).")
276-
277-
278-
;;; 6. Magic methods
279-
;;
280-
;; Source: none -- php-cc-mode.el's 367-609 `c-lang-defconst' block
281-
;; does not enumerate magic method names anywhere (grepped for
282-
;; "__construct", "__call", "__get", "__set", "magic" etc.: no hits).
283-
;; This whole category is supplemented from the PHP manual's list of
284-
;; magic methods (https://www.php.net/manual/language.oop5.magic.php),
285-
;; current through PHP 8.4.
286-
(defconst php-keywords--magic-methods
287-
'("__call" "__callstatic" "__clone" "__construct" "__debuginfo"
288-
"__destruct" "__get" "__invoke" "__isset" "__serialize" "__set"
289-
"__set_state" "__sleep" "__tostring" "__unserialize" "__unset"
290-
"__wakeup")
291-
"PHP magic method names, stored lower-case (case-insensitive, like
292-
ordinary PHP identifiers). Supplemented in full; not derived from
293-
php-cc-mode.el, see the commentary above.")
294-
295-
(defconst php-keywords--magic-methods-re
296-
(regexp-opt php-keywords--magic-methods 'symbols)
297-
"`regexp-opt' of `php-keywords--magic-methods', symbol-bounded.
298-
Match against buffer text with `case-fold-search' bound to non-nil.")
299-
300245
(provide 'php-keywords)
301246
;;; php-keywords.el ends here

0 commit comments

Comments
 (0)