Skip to content

Commit 4792988

Browse files
authored
Merge pull request #784 from emacs-php/feature/php-function-call-face
Add `font-lock-function-call` compatible faces
2 parents c8e4c16 + ccd28de commit 4792988

21 files changed

+110
-61
lines changed

Diff for: AUTHORS.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Names Sorted Alphabetically:
2424

2525
- Aaron S. Hawley
2626
- Alan Pearce
27+
- Alex Figl-Brick
2728
- Andreas Röhler
2829
- Andrei Chițu
2930
- Antoine Brand

Diff for: CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this
1818
* Remove `$` from face names for interoperability with treesit ([#780], [emacs-php/php-ts-mode#68])
1919
* `php-$this``php-this`
2020
* `php-$this-sigil``php-this-sigil`
21+
* Add `php-function-call-standard` face inherit `font-lock-function-call-face` on Emacs 29.1 and above ([#782], thanks [@bricka]!)
22+
* Add `-tranditional` suffix to the `php-*-call` faces.
23+
* `php-function-call``php-function-call-traditional`
24+
* `php-method-call``php-method-call-traditional`
25+
* `php-static-method-call``php-static-method-call-traditional`
26+
* Add variables for the `php-function-call`, `php-method-call`, and `php-static-method-call` faces, defaulting to the `-traditional` face.
2127

2228
### Removed
2329

@@ -32,6 +38,8 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this
3238
[#776]: https://github.com/emacs-php/php-mode/discussions/776
3339
[#777]: https://github.com/emacs-php/php-mode/pull/777
3440
[#780]: https://github.com/emacs-php/php-mode/issues/780
41+
[#782]: https://github.com/emacs-php/php-mode/issues/782
42+
[@bricka]: https://github.com/bricka
3543
[emacs-php/php-ts-mode#68]: https://github.com/emacs-php/php-ts-mode/pull/68
3644
[PEAR Coding Standards]: https://pear.php.net/manual/en/standards.php
3745

Diff for: lisp/php-face.el

+28-6
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,42 @@
5555
:group 'php-faces
5656
:tag "PHP Function Name")
5757

58-
(defface php-function-call '((t ()))
58+
(defface php-function-call-standard `((t ,(when (eval-when-compile (get 'font-lock-function-call-face 'face-defface-spec))
59+
'(:inherit font-lock-function-call-face))))
5960
"PHP Mode face used to highlight function names in calles."
6061
:group 'php-faces
61-
:tag "PHP Function Call")
62+
:tag "PHP Function Call Standard")
6263

63-
(defface php-method-call '((t (:inherit php-function-call)))
64+
(defface php-function-call-traditional '((t ()))
65+
"PHP Mode face used to highlight function names in calles."
66+
:group 'php-faces
67+
:tag "PHP Function Call Traditional")
68+
69+
(define-obsolete-face-alias 'php-function-call 'php-function-call-traditional "1.26.0")
70+
71+
(defface php-method-call-standard '((t (:inherit php-function-call-standard)))
72+
"PHP Mode face used to highlight method names in calles."
73+
:group 'php-faces
74+
:tag "PHP Method Call Standard")
75+
76+
(defface php-method-call-traditional '((t (:inherit php-function-call-traditional)))
6477
"PHP Mode face used to highlight method names in calles."
6578
:group 'php-faces
66-
:tag "PHP Method Call")
79+
:tag "PHP Method Call Traditional")
80+
81+
(define-obsolete-face-alias 'php-method-call 'php-method-call-traditional "1.26.0")
82+
83+
(defface php-static-method-call-standard '((t (:inherit php-method-call-standard)))
84+
"PHP Mode face used to highlight static method names in calles."
85+
:group 'php-faces
86+
:tag "PHP Static Method Call Standard")
6787

68-
(defface php-static-method-call '((t (:inherit php-method-call)))
88+
(defface php-static-method-call-traditional '((t (:inherit php-method-call-traditional)))
6989
"PHP Mode face used to highlight static method names in calles."
7090
:group 'php-faces
71-
:tag "PHP Static Method Call")
91+
:tag "PHP Static Method Call Traditional")
92+
93+
(define-obsolete-face-alias 'php-static-method-call 'php-static-method-call-traditional "1.26.0")
7294

7395
(defface php-variable-name '((t (:inherit font-lock-variable-name-face)))
7496
"PHP Mode face used to highlight variable names."

Diff for: lisp/php-mode.el

+3-3
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ for \\[find-tag] (which see)."
13711371

13721372
;; Highlight variables, e.g. 'var' in '$var' and '$obj->var', but
13731373
;; not in $obj->var()
1374-
("\\(->\\)\\(\\sw+\\)\\s-*(" (1 'php-object-op) (2 'php-method-call))
1374+
("\\(->\\)\\(\\sw+\\)\\s-*(" (1 'php-object-op) (2 php-method-call))
13751375
("\\<\\(const\\)\\s-+\\(\\_<.+?\\_>\\)" (1 'php-keyword) (2 'php-constant-assign))
13761376

13771377
;; Logical operator (!)
@@ -1413,7 +1413,7 @@ for \\[find-tag] (which see)."
14131413

14141414
;; Highlight static method calls as such. This is necessary for method
14151415
;; names which are identical to keywords to be highlighted correctly.
1416-
("\\sw+::\\(\\sw+\\)(" 1 'php-static-method-call)
1416+
("\\sw+::\\(\\sw+\\)(" 1 php-static-method-call)
14171417
;; Multiple catch (FooException | BarException $e)
14181418
(,(rx symbol-start "catch" symbol-end
14191419
(* (syntax whitespace)) "(" (* (syntax whitespace))
@@ -1457,7 +1457,7 @@ for \\[find-tag] (which see)."
14571457
(1 'php-import-declaration)
14581458
(,(rx (group (+ (or (syntax word) (syntax symbol) "\\" "{" "}")))) nil nil (1 'php-constant-assign t)))
14591459
;; Highlight function calls
1460-
("\\(\\_<\\(?:\\sw\\|\\s_\\)+?\\_>\\)\\s-*(" 1 'php-function-call)
1460+
("\\(\\_<\\(?:\\sw\\|\\s_\\)+?\\_>\\)\\s-*(" 1 php-function-call)
14611461
;; Highlight all upper-cased symbols as constant
14621462
("\\<\\([A-Z_][A-Z0-9_]+\\)\\>" 1 'php-constant)
14631463

Diff for: lisp/php.el

+18
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,24 @@ a completion list."
209209
:group 'php
210210
:tag "PHP Topsy Separator"
211211
:type 'string)
212+
213+
(defcustom php-function-call 'php-function-call-traditional
214+
"Face name to use for method call."
215+
:group 'php
216+
:tag "PHP Function Call"
217+
:type 'face)
218+
219+
(defcustom php-method-call 'php-method-call-traditional
220+
"Face name to use for method call."
221+
:group 'php
222+
:tag "PHP Method Call"
223+
:type 'face)
224+
225+
(defcustom php-static-method-call 'php-static-method-call-traditional
226+
"Face name to use for method call."
227+
:group 'php
228+
:tag "PHP Static Method Call"
229+
:type 'face)
212230

213231
;;; PHP Keywords
214232
(defconst php-magical-constants

Diff for: tests/7.4/typed-property.php.faces

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
(" ")
4949
("print" . php-function-name)
5050
("()\n {\n ")
51-
("var_dump" . php-function-call)
51+
("var_dump" . php-function-call-traditional)
5252
("(")
5353
("$" . php-this-sigil)
5454
("this" . php-this)
@@ -60,5 +60,5 @@
6060
("Typed" . font-lock-type-face)
6161
(")")
6262
("->" . php-object-op)
63-
("print" . php-method-call)
63+
("print" . php-method-call-traditional)
6464
("();\n"))

Diff for: tests/8.0/attribute/class.php.faces

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
2525
#[WithoutArgument]
2626
#[")
27-
("SingleArgument" . php-function-call)
27+
("SingleArgument" . php-function-call-traditional)
2828
("(0)]
2929
#[")
30-
("FewArguments" . php-function-call)
30+
("FewArguments" . php-function-call-traditional)
3131
("(")
3232
("'Hello'" . php-string)
3333
(", ")
@@ -40,9 +40,9 @@
4040
("() {}
4141
4242
#[WithoutArgument] #[")
43-
("SingleArgument" . php-function-call)
43+
("SingleArgument" . php-function-call-traditional)
4444
("(0)] #[")
45-
("FewArguments" . php-function-call)
45+
("FewArguments" . php-function-call-traditional)
4646
("(")
4747
("'Hello'" . php-string)
4848
(", ")
@@ -55,11 +55,11 @@
5555
("() {}
5656
5757
#[")
58-
("Attr2" . php-function-call)
58+
("Attr2" . php-function-call-traditional)
5959
("(")
6060
("\"foo\"" . php-string)
6161
("), ")
62-
("Attr2" . php-function-call)
62+
("Attr2" . php-function-call-traditional)
6363
("(")
6464
("\"bar\"" . php-string)
6565
(")]

Diff for: tests/8.0/attribute/function.php.faces

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
1212
#[WithoutArgument]
1313
#[")
14-
("SingleArgument" . php-function-call)
14+
("SingleArgument" . php-function-call-traditional)
1515
("(0)]
1616
#[")
17-
("FewArguments" . php-function-call)
17+
("FewArguments" . php-function-call-traditional)
1818
("(")
1919
("'Hello'" . php-string)
2020
(", ")
@@ -27,9 +27,9 @@
2727
("() {}
2828
2929
#[WithoutArgument]#[")
30-
("SingleArgument" . php-function-call)
30+
("SingleArgument" . php-function-call-traditional)
3131
("(0)]#[")
32-
("FewArguments" . php-function-call)
32+
("FewArguments" . php-function-call-traditional)
3333
("(")
3434
("'Hello'" . php-string)
3535
(", ")

Diff for: tests/constants.php.faces

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
(";\n")
4747
("SomeClass" . php-constant)
4848
("::" . php-paamayim-nekudotayim)
49-
("classIdentifier" . php-static-method-call)
49+
("classIdentifier" . php-static-method-call-traditional)
5050
("();\n\n")
5151
("__halt_compiler" . php-keyword)
5252
("();\n\n")

Diff for: tests/identifiers.php.faces

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@
4343
("the constant face. Just like c++-mode \"NS::Class::method()\"\n" . font-lock-comment-face)
4444
("ClassName" . php-constant)
4545
("::" . php-paamayim-nekudotayim)
46-
("method" . php-static-method-call)
46+
("method" . php-static-method-call-traditional)
4747
("();\n")
4848
("\\SpaceName\\ClassName" . php-constant)
4949
("::" . php-paamayim-nekudotayim)
50-
("method" . php-static-method-call)
50+
("method" . php-static-method-call-traditional)
5151
("();\n")
5252
("\\My_Class" . php-constant)
5353
("::" . php-paamayim-nekudotayim)
54-
("method" . php-static-method-call)
54+
("method" . php-static-method-call-traditional)
5555
("();\n\n")
5656
("__halt_compiler" . php-keyword)
5757
("();\n\n")

Diff for: tests/issue-197.php.faces

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
("$" . php-variable-sigil)
2222
("test" . php-variable-name)
2323
("->" . php-object-op)
24-
("int" . php-method-call)
24+
("int" . php-method-call-traditional)
2525
("();\n")
2626
("$" . php-variable-sigil)
2727
("test" . php-variable-name)
2828
("->" . php-object-op)
29-
("string" . php-method-call)
29+
("string" . php-method-call-traditional)
3030
("();\n"))

Diff for: tests/issue-201.php.faces

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
(";\n")
1717
("self" . php-keyword)
1818
("::" . php-paamayim-nekudotayim)
19-
("test" . php-static-method-call)
19+
("test" . php-static-method-call-traditional)
2020
("();\n")
2121
("static" . php-keyword)
2222
("::" . php-paamayim-nekudotayim)
23-
("test" . php-static-method-call)
23+
("test" . php-static-method-call-traditional)
2424
("();\n")
2525
("parent" . php-keyword)
2626
("::" . php-paamayim-nekudotayim)
27-
("test" . php-static-method-call)
27+
("test" . php-static-method-call-traditional)
2828
("();\n"))

Diff for: tests/issue-439.php.faces

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@
5252
(" ")
5353
("<<<\"いろは\"\nLet'go Justin\nいろは" . php-string)
5454
(";\n\n")
55-
("var_dump" . php-function-call)
55+
("var_dump" . php-function-call-traditional)
5656
("(")
5757
("<<<\"ABC\"\nLet'go Justin\nABC" . php-string)
5858
(");\n\n")
5959
("if" . php-keyword)
6060
(" (1 ")
6161
("===" . php-comparison-op)
6262
(" 1) {\n ")
63-
("var_dump" . php-function-call)
63+
("var_dump" . php-function-call-traditional)
6464
("(")
6565
("<<<\"ABC\"\n Let'go Justin\n ABC" . php-string)
6666
(");\n}\n"))

Diff for: tests/lang/class/anonymous-class.php.faces

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
("// " . font-lock-comment-delimiter-face)
1818
("###php-mode-test### ((indent 4))\n" . font-lock-comment-face)
1919
("};\n\n")
20-
("is_object" . php-function-call)
20+
("is_object" . php-function-call-traditional)
2121
("(1, ")
2222
("new" . php-keyword)
2323
(" ")

Diff for: tests/lang/doc-comment/comments.php.24.faces

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
(" ")
135135
("=" . php-assignment-op)
136136
(" ")
137-
("hoge" . php-function-call)
137+
("hoge" . php-function-call-traditional)
138138
("();\n\n ")
139139
("// " . font-lock-comment-delimiter-face)
140140
("one-line comment\n" . font-lock-comment-face)

Diff for: tests/lang/doc-comment/comments.php.27.faces

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
(" ")
136136
("=" . php-assignment-op)
137137
(" ")
138-
("hoge" . php-function-call)
138+
("hoge" . php-function-call-traditional)
139139
("();\n\n ")
140140
("// " . font-lock-comment-delimiter-face)
141141
("one-line comment\n" . font-lock-comment-face)

Diff for: tests/lang/doc-comment/comments.php.faces

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
(" ")
135135
("=" . php-assignment-op)
136136
(" ")
137-
("hoge" . php-function-call)
137+
("hoge" . php-function-call-traditional)
138138
("();\n\n ")
139139
("// " . font-lock-comment-delimiter-face)
140140
("one-line comment\n" . font-lock-comment-face)

0 commit comments

Comments
 (0)