Skip to content

Commit 2822593

Browse files
authored
Merge pull request #583 from emacs-php/face-function-call
Highlight function calls as php-function-call
2 parents 09e0a25 + fad74f8 commit 2822593

10 files changed

+137
-8
lines changed

Diff for: php-face.el

+27-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,32 @@
8686
:group 'php-faces
8787
:tag "PHP Variable Sigil")
8888

89-
(defface php-object-op '((t (:inherit default)))
89+
(defface php-operator '((t (:inherit default)))
90+
"PHP Mode face used to operators."
91+
:group 'php-faces
92+
:tag "PHP Operator")
93+
94+
(defface php-assignment-op '((t (:inherit php-operator)))
95+
"PHP Mode face used to assignment operators (=, +=, ...)."
96+
:group 'php-faces
97+
:tag "PHP Object Op")
98+
99+
(defface php-comparison-op '((t (:inherit php-operator)))
100+
"PHP Mode face used to comparison operators (==, !=, ===, ...)."
101+
:group 'php-faces
102+
:tag "PHP Comparison Op")
103+
104+
(defface php-logical-op '((t (:inherit php-operator)))
105+
"PHP Mode face used to logical operators (&&, ||, ?:)."
106+
:group 'php-faces
107+
:tag "PHP Logical Op")
108+
109+
(defface php-string-op '((t (:inherit php-operator)))
110+
"PHP Mode face used to logical operators (.)."
111+
:group 'php-faces
112+
:tag "PHP String Op")
113+
114+
(defface php-object-op '((t (:inherit php-operator)))
90115
"PHP Mode face used to object operators (->)."
91116
:group 'php-faces
92117
:tag "PHP Object Op")
@@ -131,7 +156,7 @@
131156
:group 'php-faces
132157
:tag "PHP $this Sigil")
133158

134-
(defface php-errorcontrol-op '((t (:inherit font-lock-type-face)))
159+
(defface php-errorcontrol-op '((t (:inherit font-lock-type-face)))
135160
"PHP Mode face used to highlight errorcontrol operators (@).."
136161
:group 'php-faces
137162
:tag "PHP ErrorControl Op")

Diff for: php-mode.el

+2
Original file line numberDiff line numberDiff line change
@@ -1610,6 +1610,8 @@ a completion list."
16101610
;; is usually overkill.
16111611
`(
16121612
("\\<\\(@\\)" 1 'php-errorcontrol-op)
1613+
;; Highlight function calls
1614+
("\\(\\_<\\(?:\\sw\\|\\s_\\)+?\\_>\\)\\s-*(" 1 'php-function-call)
16131615
;; Highlight all upper-cased symbols as constant
16141616
("\\<\\([A-Z_][A-Z0-9_]+\\)\\>" 1 'php-constant)
16151617

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@
5858
("print" . php-function-name)
5959
("()
6060
{
61-
var_dump(")
61+
")
62+
("var_dump" . php-function-call)
63+
("(")
6264
("$" . php-$this-sigil)
6365
("this" . php-$this)
6466
("->" . php-object-op)

Diff for: tests/comments.php.24.faces

+3-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@
129129
("\n ")
130130
("$" . php-variable-sigil)
131131
("foo" . php-variable-name)
132-
(" = hoge();\n\n ")
132+
(" = ")
133+
("hoge" . php-function-call)
134+
("();\n\n ")
133135
("// " . font-lock-comment-delimiter-face)
134136
("one-line comment\n" . font-lock-comment-face)
135137
(" ")

Diff for: tests/comments.php.27.faces

+3-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@
130130
("\n ")
131131
("$" . php-variable-sigil)
132132
("foo" . php-variable-name)
133-
(" = hoge();\n\n ")
133+
(" = ")
134+
("hoge" . php-function-call)
135+
("();\n\n ")
134136
("// " . font-lock-comment-delimiter-face)
135137
("one-line comment\n" . font-lock-comment-face)
136138
(" ")

Diff for: tests/comments.php.faces

+3-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@
129129
("\n ")
130130
("$" . php-variable-sigil)
131131
("foo" . php-variable-name)
132-
(" = hoge();\n\n ")
132+
(" = ")
133+
("hoge" . php-function-call)
134+
("();\n\n ")
133135
("// " . font-lock-comment-delimiter-face)
134136
("one-line comment\n" . font-lock-comment-face)
135137
(" ")

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,15 @@
3939
("g" . php-variable-name)
4040
(" = ")
4141
("<<<\"いろは\"\nLet'go Justin\nいろは" . php-string)
42-
(";\n\nvar_dump(")
42+
(";\n\n")
43+
("var_dump" . php-function-call)
44+
("(")
4345
("<<<\"ABC\"\nLet'go Justin\nABC" . php-string)
4446
(");\n\n")
4547
("if" . php-keyword)
46-
(" (1 === 1) {\n var_dump(")
48+
(" (1 === 1) {\n ")
49+
("var_dump" . php-function-call)
50+
("(")
4751
("<<<\"ABC\"\n Let'go Justin\n ABC" . php-string)
4852
(");\n}\n")
4953
)

Diff for: tests/lang/function/calls.php

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
if (isset($foo)) {
4+
1+bar()+foo();
5+
}
6+
7+
$foo->string();
8+
$foo->isset();
9+
10+
11+
$a->b();
12+
$a = a();
13+
$aaa = aaa();
14+
$_aa = _aa();
15+
$a_a = a_a();
16+
$aa_ = aa_();
17+
$a1c = a1c();
18+
$ = ();
19+
$_a = $a();

Diff for: tests/lang/function/calls.php.faces

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
;; -*- mode: emacs-lisp -*-
2+
(("<?php" . php-php-tag)
3+
("\n\n")
4+
("if" . php-keyword)
5+
(" (")
6+
("isset" . php-keyword)
7+
("(")
8+
("$" . php-variable-sigil)
9+
("foo" . php-variable-name)
10+
(")) {\n 1+")
11+
("bar" . php-function-call)
12+
("()+")
13+
("foo" . php-function-call)
14+
("();\n}\n\n")
15+
("$" . php-variable-sigil)
16+
("foo" . php-variable-name)
17+
("->" . php-object-op)
18+
("string" . php-method-call)
19+
("();\n")
20+
("$" . php-variable-sigil)
21+
("foo" . php-variable-name)
22+
("->" . php-object-op)
23+
("isset" . php-method-call)
24+
("();\n\n\n")
25+
("$" . php-variable-sigil)
26+
("a" . php-variable-name)
27+
("->" . php-object-op)
28+
("b" . php-method-call)
29+
("();\n")
30+
("$" . php-variable-sigil)
31+
("a" . php-variable-name)
32+
(" = ")
33+
("a" . php-function-call)
34+
("();\n")
35+
("$" . php-variable-sigil)
36+
("aaa" . php-variable-name)
37+
(" = ")
38+
("aaa" . php-function-call)
39+
("();\n")
40+
("$" . php-variable-sigil)
41+
("_aa" . php-variable-name)
42+
(" = ")
43+
("_aa" . php-function-call)
44+
("();\n")
45+
("$" . php-variable-sigil)
46+
("a_a" . php-variable-name)
47+
(" = ")
48+
("a_a" . php-function-call)
49+
("();\n")
50+
("$" . php-variable-sigil)
51+
("aa_" . php-variable-name)
52+
(" = ")
53+
("aa_" . php-function-call)
54+
("();\n")
55+
("$" . php-variable-sigil)
56+
("a1c" . php-variable-name)
57+
(" = ")
58+
("a1c" . php-function-call)
59+
("();\n")
60+
("$" . php-variable-sigil)
61+
("" . php-variable-name)
62+
(" = ")
63+
("" . php-function-call)
64+
("();\n")
65+
("$" . php-variable-sigil)
66+
("_a" . php-variable-name)
67+
(" = ")
68+
("$" . php-variable-sigil)
69+
("a" . php-variable-name)
70+
("();\n"))

Diff for: tests/php-mode-test.el

+1
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@ Meant for `php-mode-test-issue-503'."
680680
(t t))))
681681
(with-php-mode-test ("doc-comment/return-type.php" :faces t))
682682
(with-php-mode-test ("doc-comment/inheritdoc.php" :faces t))
683+
(with-php-mode-test ("lang/function/calls.php" :faces t))
683684
(with-php-mode-test ("lang/try-cactch/multiple.php" :faces t))
684685
(with-php-mode-test ("lang/types/cast.php" :faces t))
685686
(with-php-mode-test ("lang/types/function.php" :faces t))

0 commit comments

Comments
 (0)