From 1e0636482b96885b778b0303281c76092e3e1aba Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Mon, 23 Dec 2019 12:45:36 +0100 Subject: [PATCH 1/4] Add class declaration face Fix php class declaration regex and inherit --- php-face.el | 5 +++++ php-mode.el | 3 +++ 2 files changed, 8 insertions(+) diff --git a/php-face.el b/php-face.el index b5b401da..4fc9542b 100644 --- a/php-face.el +++ b/php-face.el @@ -201,6 +201,11 @@ :group 'php-faces :tag "PHPDoc Class Name") +(defface php-class-declaration '((t (:inherit php-keyword))) + "Face used to class declarations." + :group 'php-faces + :tag "PHP Class Declaration") + (define-obsolete-face-alias 'php-annotations-annotation-face 'php-doc-annotation-tag "1.19.0") (provide 'php-face) diff --git a/php-mode.el b/php-mode.el index 3c9d8355..aea4208a 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1494,6 +1494,9 @@ a completion list." ;; only add patterns here if you want to prevent cc-mode from applying ;; a different face. `( + ;; Class declaration keywords (class, trait, interface) + ("class\\|trait\\|interface" . 'php-class-declaration) + ;; Highlight variables, e.g. 'var' in '$var' and '$obj->var', but ;; not in $obj->var() ("\\(->\\)\\(\\sw+\\)\\s-*(" (1 'php-object-op) (2 'php-method-call)) From db3ca4aba65b9ec1537fc065f73e48d427d00b48 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sun, 1 Mar 2020 21:14:28 +0900 Subject: [PATCH 2/4] Fix class faces --- tests/7.4/typed-property.php.faces | 2 +- tests/issue-136.php.faces | 2 +- tests/lang/class/anonymous-class.php.faces | 6 +++--- tests/lang/doc-comment/annotation.php.faces | 4 ++-- tests/lang/doc-comment/comments.php.24.faces | 2 +- tests/lang/doc-comment/comments.php.27.faces | 2 +- tests/lang/doc-comment/comments.php.faces | 2 +- tests/lang/doc-comment/issue-8.php.faces | 2 +- tests/type-hints.php.faces | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/7.4/typed-property.php.faces b/tests/7.4/typed-property.php.faces index 74dc9a1c..fac03f33 100644 --- a/tests/7.4/typed-property.php.faces +++ b/tests/7.4/typed-property.php.faces @@ -1,7 +1,7 @@ ;; -*- mode: emacs-lisp -*- ((" Date: Sun, 1 Mar 2020 21:14:58 +0900 Subject: [PATCH 3/4] Fix class highlighting --- php-mode.el | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/php-mode.el b/php-mode.el index aea4208a..9a90373b 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1494,9 +1494,6 @@ a completion list." ;; only add patterns here if you want to prevent cc-mode from applying ;; a different face. `( - ;; Class declaration keywords (class, trait, interface) - ("class\\|trait\\|interface" . 'php-class-declaration) - ;; Highlight variables, e.g. 'var' in '$var' and '$obj->var', but ;; not in $obj->var() ("\\(->\\)\\(\\sw+\\)\\s-*(" (1 'php-object-op) (2 'php-method-call)) @@ -1536,6 +1533,8 @@ a completion list." 1 'php-class) ;; Support the ::class constant in PHP5.6 ("\\sw+\\(::\\)\\(class\\)\\b" (1 'php-paamayim-nekudotayim) (2 'php-magical-constant)) + ;; Class declaration keywords (class, trait, interface) + ("\\_<\\(class\\|trait\\|interface\\)\\_>" . 'php-class-declaration) ;; Highlight static method calls as such. This is necessary for method ;; names which are identical to keywords to be highlighted correctly. From e8a8266fc7279bda4cc0f8eda8243e9d8b5daf4f Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sun, 1 Mar 2020 21:15:41 +0900 Subject: [PATCH 4/4] Remove class, interface and trait from langage-construts.php --- tests/language-constructs.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/language-constructs.php b/tests/language-constructs.php index de6566ec..693f6ece 100644 --- a/tests/language-constructs.php +++ b/tests/language-constructs.php @@ -19,7 +19,6 @@ break; case; catch; -class ClassName; clone; const; continue; @@ -53,7 +52,6 @@ function; include_once; instanceof ClassName; insteadof ClassName; -interface ClassName; isset(); list(); namespace ClassName; @@ -68,7 +66,6 @@ interface ClassName; static; switch; throw; -trait ClassName; try; unset(); use ClassName;