diff --git a/php-face.el b/php-face.el index 613d0c6b..1e060082 100644 --- a/php-face.el +++ b/php-face.el @@ -86,7 +86,32 @@ :group 'php-faces :tag "PHP Variable Sigil") -(defface php-object-op '((t (:inherit default))) +(defface php-operator '((t (:inherit default))) + "PHP Mode face used to operators." + :group 'php-faces + :tag "PHP Operator") + +(defface php-assignment-op '((t (:inherit php-operator))) + "PHP Mode face used to assignment operators (=, +=, ...)." + :group 'php-faces + :tag "PHP Object Op") + +(defface php-comparison-op '((t (:inherit php-operator))) + "PHP Mode face used to comparison operators (==, !=, ===, ...)." + :group 'php-faces + :tag "PHP Comparison Op") + +(defface php-logical-op '((t (:inherit php-operator))) + "PHP Mode face used to logical operators (&&, ||, ?:)." + :group 'php-faces + :tag "PHP Logical Op") + +(defface php-string-op '((t (:inherit php-operator))) + "PHP Mode face used to logical operators (.)." + :group 'php-faces + :tag "PHP String Op") + +(defface php-object-op '((t (:inherit php-operator))) "PHP Mode face used to object operators (->)." :group 'php-faces :tag "PHP Object Op") @@ -131,7 +156,7 @@ :group 'php-faces :tag "PHP $this Sigil") -(defface php-errorcontrol-op '((t (:inherit font-lock-type-face))) +(defface php-errorcontrol-op '((t (:inherit font-lock-type-face))) "PHP Mode face used to highlight errorcontrol operators (@).." :group 'php-faces :tag "PHP ErrorControl Op") diff --git a/php-mode.el b/php-mode.el index d50b6b2d..2477d69f 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1610,6 +1610,8 @@ a completion list." ;; is usually overkill. `( ("\\<\\(@\\)" 1 'php-errorcontrol-op) + ;; Highlight function calls + ("\\(\\_<\\(?:\\sw\\|\\s_\\)+?\\_>\\)\\s-*(" 1 'php-function-call) ;; Highlight all upper-cased symbols as constant ("\\<\\([A-Z_][A-Z0-9_]+\\)\\>" 1 'php-constant) diff --git a/tests/7.4/typed-property.php.faces b/tests/7.4/typed-property.php.faces index 18135538..ffa15b00 100644 --- a/tests/7.4/typed-property.php.faces +++ b/tests/7.4/typed-property.php.faces @@ -58,7 +58,9 @@ ("print" . php-function-name) ("() { - var_dump(") + ") + ("var_dump" . php-function-call) + ("(") ("$" . php-$this-sigil) ("this" . php-$this) ("->" . php-object-op) diff --git a/tests/comments.php.24.faces b/tests/comments.php.24.faces index ed0e39b3..f98deb66 100644 --- a/tests/comments.php.24.faces +++ b/tests/comments.php.24.faces @@ -129,7 +129,9 @@ ("\n ") ("$" . php-variable-sigil) ("foo" . php-variable-name) - (" = hoge();\n\n ") + (" = ") + ("hoge" . php-function-call) + ("();\n\n ") ("// " . font-lock-comment-delimiter-face) ("one-line comment\n" . font-lock-comment-face) (" ") diff --git a/tests/comments.php.27.faces b/tests/comments.php.27.faces index 3867ad64..3c097d18 100644 --- a/tests/comments.php.27.faces +++ b/tests/comments.php.27.faces @@ -130,7 +130,9 @@ ("\n ") ("$" . php-variable-sigil) ("foo" . php-variable-name) - (" = hoge();\n\n ") + (" = ") + ("hoge" . php-function-call) + ("();\n\n ") ("// " . font-lock-comment-delimiter-face) ("one-line comment\n" . font-lock-comment-face) (" ") diff --git a/tests/comments.php.faces b/tests/comments.php.faces index 6248c704..54efd31b 100644 --- a/tests/comments.php.faces +++ b/tests/comments.php.faces @@ -129,7 +129,9 @@ ("\n ") ("$" . php-variable-sigil) ("foo" . php-variable-name) - (" = hoge();\n\n ") + (" = ") + ("hoge" . php-function-call) + ("();\n\n ") ("// " . font-lock-comment-delimiter-face) ("one-line comment\n" . font-lock-comment-face) (" ") diff --git a/tests/issue-439.php.faces b/tests/issue-439.php.faces index cc06b621..0bb3252c 100644 --- a/tests/issue-439.php.faces +++ b/tests/issue-439.php.faces @@ -39,11 +39,15 @@ ("g" . php-variable-name) (" = ") ("<<<\"いろは\"\nLet'go Justin\nいろは" . php-string) - (";\n\nvar_dump(") + (";\n\n") + ("var_dump" . php-function-call) + ("(") ("<<<\"ABC\"\nLet'go Justin\nABC" . php-string) (");\n\n") ("if" . php-keyword) - (" (1 === 1) {\n var_dump(") + (" (1 === 1) {\n ") + ("var_dump" . php-function-call) + ("(") ("<<<\"ABC\"\n Let'go Justin\n ABC" . php-string) (");\n}\n") ) diff --git a/tests/lang/function/calls.php b/tests/lang/function/calls.php new file mode 100644 index 00000000..85cba778 --- /dev/null +++ b/tests/lang/function/calls.php @@ -0,0 +1,19 @@ +string(); +$foo->isset(); + + +$a->b(); +$a = a(); +$aaa = aaa(); +$_aa = _aa(); +$a_a = a_a(); +$aa_ = aa_(); +$a1c = a1c(); +$あ = あ(); +$_a = $a(); diff --git a/tests/lang/function/calls.php.faces b/tests/lang/function/calls.php.faces new file mode 100644 index 00000000..8cac4259 --- /dev/null +++ b/tests/lang/function/calls.php.faces @@ -0,0 +1,70 @@ +;; -*- mode: emacs-lisp -*- +(("" . php-object-op) + ("string" . php-method-call) + ("();\n") + ("$" . php-variable-sigil) + ("foo" . php-variable-name) + ("->" . php-object-op) + ("isset" . php-method-call) + ("();\n\n\n") + ("$" . php-variable-sigil) + ("a" . php-variable-name) + ("->" . php-object-op) + ("b" . php-method-call) + ("();\n") + ("$" . php-variable-sigil) + ("a" . php-variable-name) + (" = ") + ("a" . php-function-call) + ("();\n") + ("$" . php-variable-sigil) + ("aaa" . php-variable-name) + (" = ") + ("aaa" . php-function-call) + ("();\n") + ("$" . php-variable-sigil) + ("_aa" . php-variable-name) + (" = ") + ("_aa" . php-function-call) + ("();\n") + ("$" . php-variable-sigil) + ("a_a" . php-variable-name) + (" = ") + ("a_a" . php-function-call) + ("();\n") + ("$" . php-variable-sigil) + ("aa_" . php-variable-name) + (" = ") + ("aa_" . php-function-call) + ("();\n") + ("$" . php-variable-sigil) + ("a1c" . php-variable-name) + (" = ") + ("a1c" . php-function-call) + ("();\n") + ("$" . php-variable-sigil) + ("あ" . php-variable-name) + (" = ") + ("あ" . php-function-call) + ("();\n") + ("$" . php-variable-sigil) + ("_a" . php-variable-name) + (" = ") + ("$" . php-variable-sigil) + ("a" . php-variable-name) + ("();\n")) diff --git a/tests/php-mode-test.el b/tests/php-mode-test.el index 431998fd..1dd84d9b 100644 --- a/tests/php-mode-test.el +++ b/tests/php-mode-test.el @@ -680,6 +680,7 @@ Meant for `php-mode-test-issue-503'." (t t)))) (with-php-mode-test ("doc-comment/return-type.php" :faces t)) (with-php-mode-test ("doc-comment/inheritdoc.php" :faces t)) + (with-php-mode-test ("lang/function/calls.php" :faces t)) (with-php-mode-test ("lang/try-cactch/multiple.php" :faces t)) (with-php-mode-test ("lang/types/cast.php" :faces t)) (with-php-mode-test ("lang/types/function.php" :faces t))