Skip to content

Commit fb11df8

Browse files
authored
Merge pull request #728 from emacs-php/fix/use-constant
Fix `use const` font-lock
2 parents be716f0 + 30c331b commit fb11df8

File tree

5 files changed

+23
-19
lines changed

5 files changed

+23
-19
lines changed

lisp/php-face.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
:group 'php-faces
146146
:tag "PHP Constant")
147147

148-
(defface php-constant-assign '((t (:inherit font-lock-type-face)))
148+
(defface php-constant-assign '((t (:inherit php-constant)))
149149
"PHP Mode face used to highlight constant assigning (\"const\" statement)."
150150
:group 'php-faces
151151
:tag "PHP Constant Assign")

lisp/php-mode.el

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -496,10 +496,10 @@ PHP does not have an C-like \"enum\" keyword."
496496
php nil)
497497

498498
(c-lang-defconst c-typeless-decl-kwds
499-
php (append (c-lang-const c-class-decl-kwds) '("function")))
499+
php (append (c-lang-const c-class-decl-kwds php) '("function" "const")))
500500

501501
(c-lang-defconst c-modifier-kwds
502-
php '("abstract" "const" "final" "static" "case" "readonly"))
502+
php '("abstract" "final" "static" "case" "readonly"))
503503

504504
(c-lang-defconst c-protection-kwds
505505
"Access protection label keywords in classes."
@@ -1396,11 +1396,6 @@ for \\[find-tag] (which see)."
13961396
("\\_<\\(?:implements\\|extends\\)\\_>" . 'php-class-declaration-spec)
13971397
;; Namespace declaration
13981398
("\\_<namespace\\_>" . 'php-namespace-declaration)
1399-
;; import constant statement
1400-
(,(rx symbol-start (group "use" (+ (syntax whitespace)) "const")
1401-
(+ (syntax whitespace)))
1402-
(1 'php-import-declaration)
1403-
(,(rx (group (+ (or (syntax word) (syntax symbol) "\\" "{" "}")))) nil nil (1 'php-constant-assign)))
14041399
;; import statement
14051400
("\\_<use\\_>" . 'php-import-declaration)
14061401
;; Class modifiers (abstract, final)
@@ -1488,6 +1483,11 @@ for \\[find-tag] (which see)."
14881483
(+ (syntax whitespace)))
14891484
(1 'php-import-declaration)
14901485
(,(rx (group (+ (or (syntax word) (syntax symbol) "\\" "{" "}")))) nil nil (1 'php-function-name t)))
1486+
;; import constant statement
1487+
(,(rx symbol-start (group "use" (+ (syntax whitespace)) "const")
1488+
(+ (syntax whitespace)))
1489+
(1 'php-import-declaration)
1490+
(,(rx (group (+ (or (syntax word) (syntax symbol) "\\" "{" "}")))) nil nil (1 'php-constant-assign t)))
14911491
;; Highlight function calls
14921492
("\\(\\_<\\(?:\\sw\\|\\s_\\)+?\\_>\\)\\s-*(" 1 'php-function-call)
14931493
;; Highlight all upper-cased symbols as constant

tests/lang/doc-comment/comments.php.27.faces

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
("\n ")
7272
("const" . php-keyword)
7373
(" ")
74-
("SAMPLE" . font-lock-type-face)
74+
("SAMPLE" . php-constant-assign)
7575
(" ")
7676
("=" . php-assignment-op)
7777
(" ")

tests/lang/doc-comment/comments.php.faces

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
("\n ")
7171
("const" . php-keyword)
7272
(" ")
73-
("SAMPLE" . font-lock-type-face)
73+
("SAMPLE" . php-constant-assign)
7474
(" ")
7575
("=" . php-assignment-op)
7676
(" ")

tests/lang/import/import-constant.php.faces

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,29 @@
55
(" ")
66
("Foo" . font-lock-type-face)
77
(";\n\n")
8-
("use const" . php-import-declaration)
8+
("use" . php-import-declaration)
99
(" ")
10-
("Foo\\" . php-constant-assign)
11-
("BAR" . font-lock-type-face)
10+
("const" . php-keyword)
11+
(" ")
12+
("Foo\\BAR" . php-constant-assign)
1213
(";\n")
13-
("use const" . php-import-declaration)
14+
("use" . php-import-declaration)
1415
(" ")
15-
("Foo" . font-lock-type-face)
16-
("\\{BUZ" . php-constant-assign)
16+
("const" . php-keyword)
17+
(" ")
18+
("Foo\\{BUZ" . php-constant-assign)
1719
(", ")
1820
("BUZBUZ}" . php-constant-assign)
1921
(";\n")
20-
("use const" . php-import-declaration)
22+
("use" . php-import-declaration)
23+
(" ")
24+
("const" . php-keyword)
2125
(" ")
22-
("PHP_VERSION" . font-lock-type-face)
26+
("PHP_VERSION" . php-constant-assign)
2327
(";\n\n")
2428
("const" . php-keyword)
2529
(" ")
26-
("FOO" . font-lock-type-face)
30+
("FOO" . php-constant-assign)
2731
(" ")
2832
("=" . php-assignment-op)
2933
(" ")

0 commit comments

Comments
 (0)