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

AUTHORS.md

Lines changed: 1 addition & 0 deletions
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

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
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

lisp/php-face.el

Lines changed: 28 additions & 6 deletions
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."

lisp/php-mode.el

Lines changed: 3 additions & 3 deletions
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

lisp/php.el

Lines changed: 18 additions & 0 deletions
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

tests/7.4/typed-property.php.faces

Lines changed: 2 additions & 2 deletions
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"))

tests/8.0/attribute/class.php.faces

Lines changed: 6 additions & 6 deletions
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
(")]

tests/8.0/attribute/function.php.faces

Lines changed: 4 additions & 4 deletions
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
(", ")

tests/constants.php.faces

Lines changed: 1 addition & 1 deletion
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")

tests/identifiers.php.faces

Lines changed: 3 additions & 3 deletions
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")

0 commit comments

Comments
 (0)