From 8891afcbb2e28a09a09a4e52e54a717bc26fad6f Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Fri, 20 Dec 2019 10:01:35 +0100 Subject: [PATCH 01/29] Add => to assignment operators --- php-mode.el | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/php-mode.el b/php-mode.el index 93e95410..4c22632a 100644 --- a/php-mode.el +++ b/php-mode.el @@ -688,6 +688,7 @@ but only if the setting is enabled" (case-label . +) (class-open . 0) (comment-intro . 0) + (inexpr-class . 0) (inlambda . 0) (inline-open . 0) (namespace-open . 0) @@ -1550,7 +1551,7 @@ a completion list." ("\\(\\$\\)\\(this\\)\\>" (1 'php-$this-sigil) (2 'php-$this)) ("\\(\\$+\\)\\(\\sw+\\)" (1 'php-variable-sigil) (2 'php-variable-name)) ("\\(->\\)\\([a-zA-Z0-9_]+\\)" (1 'php-object-op) (2 'php-property-name)) - + ;; Highlight function/method names ("\\]+?\\([\-+./%]?=\\)[^=]+?\\)" 2 'php-assignment-op) + ("\\([^=]+?\\([\-+./%]?=\\)[^==, ...) ("\\([!=]=\\{1,2\\}[>]?\\|[<>]=?\\)" 1 'php-comparison-op) @@ -1670,8 +1671,7 @@ a completion list." ;; Logical operators (and, or, &&, ...) ;; Not operator (!) is defined in "before cc-mode" section above. - ("\\(&&\\|\|\|\\)" 1 'php-logical-op) - )) + ("\\(&&\\|||\\)" 1 'php-logical-op))) "Detailed highlighting for PHP Mode.") (defvar php-font-lock-keywords php-font-lock-keywords-3 From ab9a0f0a4eb9aafced3bae334964a604938b8384 Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Mon, 23 Dec 2019 12:45:36 +0100 Subject: [PATCH 02/29] Add class declaration face --- php-face.el | 5 +++++ php-mode.el | 3 +++ 2 files changed, 8 insertions(+) diff --git a/php-face.el b/php-face.el index 5bd821e5..91fc1951 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 font-lock-keyword-face))) + "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 4c22632a..646364de 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1539,6 +1539,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 a1469dd830746e7e39f02a81a940dae98916288d Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Mon, 23 Dec 2019 12:52:59 +0100 Subject: [PATCH 03/29] Fix php class declaration regex and inherit --- php-face.el | 2 +- php-mode.el | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/php-face.el b/php-face.el index 91fc1951..bbb2a6c6 100644 --- a/php-face.el +++ b/php-face.el @@ -201,7 +201,7 @@ :group 'php-faces :tag "PHPDoc Class Name") -(defface php-class-declaration '((t (:inherit font-lock-keyword-face))) +(defface php-class-declaration '((t (:inherit php-keyword))) "Face used to class declarations." :group 'php-faces :tag "PHP Class Declaration") diff --git a/php-mode.el b/php-mode.el index 646364de..160807d7 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1540,7 +1540,7 @@ a completion list." ;; a different face. `( ;; Class declaration keywords (class, trait, interface) - ("\\class\\|trait\\interface" . 'php-class-declaration) + ("class\\|trait\\|interface" . 'php-class-declaration) ;; Highlight variables, e.g. 'var' in '$var' and '$obj->var', but ;; not in $obj->var() From 00eeb2f18f2ed9a315b06fe473d4b1994433e8c2 Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Mon, 23 Dec 2019 13:03:16 +0100 Subject: [PATCH 04/29] Add php class declaration specification face --- php-face.el | 7 ++++++- php-mode.el | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/php-face.el b/php-face.el index bbb2a6c6..e8721e35 100644 --- a/php-face.el +++ b/php-face.el @@ -202,10 +202,15 @@ :tag "PHPDoc Class Name") (defface php-class-declaration '((t (:inherit php-keyword))) - "Face used to class declarations." + "Face used to highlight class declaration keywords" :group 'php-faces :tag "PHP Class Declaration") +(defface php-class-declaration-spec '((t (:inherit php-keyword))) + "Face used to highlight class declaration specification keywords (implements, extends)" + :group 'php-faces + :tag "PHP Class Declaration Specification") + (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 160807d7..52621df9 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1541,6 +1541,9 @@ a completion list." `( ;; Class declaration keywords (class, trait, interface) ("class\\|trait\\|interface" . 'php-class-declaration) + + ;; Class declaration specification keywords (implements, extends) + ("implements\\|extends" . 'php-class-declaration-spec) ;; Highlight variables, e.g. 'var' in '$var' and '$obj->var', but ;; not in $obj->var() From 26b994819cfdf291eb3be252a88da43470df4ba0 Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Mon, 23 Dec 2019 13:09:50 +0100 Subject: [PATCH 05/29] Add namespace declaration face --- php-face.el | 5 +++++ php-mode.el | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/php-face.el b/php-face.el index e8721e35..5aaf3963 100644 --- a/php-face.el +++ b/php-face.el @@ -211,6 +211,11 @@ :group 'php-faces :tag "PHP Class Declaration Specification") +(defface php-namespace-declaration '((t (:inherit php-keyword))) + "Face used to highlight namespace declaration keyword." + :group 'php-faces + :tag "PHP Namespace 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 52621df9..91f07205 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1,4 +1,4 @@ -;;; php-mode.el --- Major mode for editing PHP code +3;;; php-mode.el --- Major mode for editing PHP code ;; Copyright (C) 2018-2019 Friends of Emacs-PHP development ;; Copyright (C) 1999, 2000, 2001, 2003, 2004 Turadg Aleahmad @@ -1544,6 +1544,9 @@ a completion list." ;; Class declaration specification keywords (implements, extends) ("implements\\|extends" . 'php-class-declaration-spec) + + ;; Namespace declaration + ("namespace" . 'php-namespace-declaration) ;; Highlight variables, e.g. 'var' in '$var' and '$obj->var', but ;; not in $obj->var() From c68ab57fd4234dffcfc8f1aaddce2888c97ed7cd Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Mon, 23 Dec 2019 13:16:33 +0100 Subject: [PATCH 06/29] Add import statement face --- php-face.el | 6 ++++++ php-mode.el | 3 +++ 2 files changed, 9 insertions(+) diff --git a/php-face.el b/php-face.el index 5aaf3963..cface1b8 100644 --- a/php-face.el +++ b/php-face.el @@ -216,6 +216,12 @@ :group 'php-faces :tag "PHP Namespace Declaration") + +(defface php-import-declaration '((t (:inherit php-keyword))) + "Face used to highlight import statements (use ... as ...)" + :group 'php-faces + :tag "PHP Import Statement") + (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 91f07205..cf53929e 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1547,6 +1547,9 @@ a completion list." ;; Namespace declaration ("namespace" . 'php-namespace-declaration) + + ;; import statement + ("use\\|as" . 'php-import-declaration) ;; Highlight variables, e.g. 'var' in '$var' and '$obj->var', but ;; not in $obj->var() From 2cb9b54e649311a346e6ee95fd4e21a81858304f Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Mon, 23 Dec 2019 15:17:25 +0100 Subject: [PATCH 07/29] Improve import statement --- php-mode.el | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/php-mode.el b/php-mode.el index cf53929e..f4261786 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1,4 +1,4 @@ -3;;; php-mode.el --- Major mode for editing PHP code +;;; php-mode.el --- Major mode for editing PHP code ;; Copyright (C) 2018-2019 Friends of Emacs-PHP development ;; Copyright (C) 1999, 2000, 2001, 2003, 2004 Turadg Aleahmad @@ -1546,10 +1546,11 @@ a completion list." ("implements\\|extends" . 'php-class-declaration-spec) ;; Namespace declaration - ("namespace" . 'php-namespace-declaration) + ("namespace" . 'php-namespace-declaration) - ;; import statement - ("use\\|as" . 'php-import-declaration) + ;; import statement (use ... as ...) + ("\\(use[[:space:]]\\)\\(?:[[:word:]\\]\\)" (1 'php-import-declaration)) + ("\\(?:[[:word:]\\]\\)\\([[:space:]]as\\)" (1 'php-import-declaration)) ;; Highlight variables, e.g. 'var' in '$var' and '$obj->var', but ;; not in $obj->var() @@ -1638,7 +1639,7 @@ a completion list." ;; Highlight class name after "use .. as" ("\\ Date: Mon, 23 Dec 2019 15:44:55 +0100 Subject: [PATCH 08/29] Add class modifiers --- php-face.el | 6 +++++- php-mode.el | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/php-face.el b/php-face.el index cface1b8..11720a12 100644 --- a/php-face.el +++ b/php-face.el @@ -216,12 +216,16 @@ :group 'php-faces :tag "PHP Namespace Declaration") - (defface php-import-declaration '((t (:inherit php-keyword))) "Face used to highlight import statements (use ... as ...)" :group 'php-faces :tag "PHP Import Statement") +(defface php-modifiers-class '((t (:inherit php-keyword))) + "Face used to highlight class modifiers (final, abstract)" + :group 'php-faces + :tag "PHP Class Modifiers") + (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 f4261786..97ae44f9 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1551,6 +1551,9 @@ a completion list." ;; import statement (use ... as ...) ("\\(use[[:space:]]\\)\\(?:[[:word:]\\]\\)" (1 'php-import-declaration)) ("\\(?:[[:word:]\\]\\)\\([[:space:]]as\\)" (1 'php-import-declaration)) + + ;; Class modifiers (abstract, final) + ("\\(abstract\\|final\\)[[:space:]]\\(?:class\\)" (1 'php-modifiers-class)) ;; Highlight variables, e.g. 'var' in '$var' and '$obj->var', but ;; not in $obj->var() From 451fb6002df84ee05c5622d34eaf502ccc0e753e Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Mon, 23 Dec 2019 15:49:23 +0100 Subject: [PATCH 09/29] Add sanity check for class declaration (We don't want to match get_class() --- php-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php-mode.el b/php-mode.el index 97ae44f9..534cda89 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1540,7 +1540,7 @@ a completion list." ;; a different face. `( ;; Class declaration keywords (class, trait, interface) - ("class\\|trait\\|interface" . 'php-class-declaration) + ("\\(class\\|trait\\|interface\\)[^(]" (1 'php-class-declaration)) ;; Class declaration specification keywords (implements, extends) ("implements\\|extends" . 'php-class-declaration-spec) From f79dfa96d18290015d9c10f49554e1733739934d Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Mon, 23 Dec 2019 16:22:58 +0100 Subject: [PATCH 10/29] Add method modifiers --- php-face.el | 5 +++++ php-mode.el | 3 +++ 2 files changed, 8 insertions(+) diff --git a/php-face.el b/php-face.el index 11720a12..f4989bb6 100644 --- a/php-face.el +++ b/php-face.el @@ -226,6 +226,11 @@ :group 'php-faces :tag "PHP Class Modifiers") +(defface php-modifiers-method '((t (:inherit php-keyword))) + "Face used to highlight method modifiers (final, abstract)" + :group 'php-faces + :tag "PHP Method Modifiers") + (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 534cda89..81c24a8f 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1554,6 +1554,9 @@ a completion list." ;; Class modifiers (abstract, final) ("\\(abstract\\|final\\)[[:space:]]\\(?:class\\)" (1 'php-modifiers-class)) + + ;; Method modifiers (abstract, final, static) + ("\\(abstract\\|final\\)[[:space:]]\\(?:static[[:space:]]\\)?\\(?:public\\|private\\|protected\\)" (1 'php-modifiers-method)) ;; Highlight variables, e.g. 'var' in '$var' and '$obj->var', but ;; not in $obj->var() From f4cdd8755f88b15242776ff78839efdc7c1a04cd Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Thu, 2 Jan 2020 09:26:22 +0100 Subject: [PATCH 11/29] rename php modifiers faces; added php-property-acess face --- php-face.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/php-face.el b/php-face.el index f4989bb6..6c4c5ead 100644 --- a/php-face.el +++ b/php-face.el @@ -221,16 +221,21 @@ :group 'php-faces :tag "PHP Import Statement") -(defface php-modifiers-class '((t (:inherit php-keyword))) +(defface php-class-modifiers '((t (:inherit php-keyword))) "Face used to highlight class modifiers (final, abstract)" :group 'php-faces :tag "PHP Class Modifiers") -(defface php-modifiers-method '((t (:inherit php-keyword))) +(defface php-method-modifiers '((t (:inherit php-keyword))) "Face used to highlight method modifiers (final, abstract)" :group 'php-faces :tag "PHP Method Modifiers") +(defface php-property-access '((t (:inherit php-keyword))) + "Face used to highlight property access keywords (public, protected, public)" + :group 'php-faces + :tag "PHP Property Access") + (define-obsolete-face-alias 'php-annotations-annotation-face 'php-doc-annotation-tag "1.19.0") (provide 'php-face) From 49ee230400e604892da83bbb5b77da9936f54039 Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Thu, 2 Jan 2020 09:29:04 +0100 Subject: [PATCH 12/29] Simplify method-modifiers regex --- php-mode.el | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/php-mode.el b/php-mode.el index 81c24a8f..d6564b69 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1553,10 +1553,16 @@ a completion list." ("\\(?:[[:word:]\\]\\)\\([[:space:]]as\\)" (1 'php-import-declaration)) ;; Class modifiers (abstract, final) - ("\\(abstract\\|final\\)[[:space:]]\\(?:class\\)" (1 'php-modifiers-class)) + ("\\(abstract\\|final\\)[[:space:]]\\(?:class\\)" (1 'php-class-modifiers)) - ;; Method modifiers (abstract, final, static) - ("\\(abstract\\|final\\)[[:space:]]\\(?:static[[:space:]]\\)?\\(?:public\\|private\\|protected\\)" (1 'php-modifiers-method)) + ;; Method modifiers (abstract, final) + ("\\(abstract\\|final\\)[[:space:]]\\(?:static\\|public\\|private\\|protected\\)" (1 'php-method-modifiers)) + + ;; Method access protection + + + ;; Property access protection + ;("\\(private\\|protected\\|public\\)\\(?:[[:space:]]const[[:space:]][[:word:]]\\|[[:space:]]\$[[:word:]]\\)" (1 'php-property-access)) ;; Highlight variables, e.g. 'var' in '$var' and '$obj->var', but ;; not in $obj->var() From 79096c87d0bae56c268924d043e75f53fd6cbfc6 Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Thu, 2 Jan 2020 09:49:31 +0100 Subject: [PATCH 13/29] Add php method access and static modifier faces --- php-face.el | 22 ++++++++++++++++------ php-mode.el | 5 ++++- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/php-face.el b/php-face.el index 6c4c5ead..ba222992 100644 --- a/php-face.el +++ b/php-face.el @@ -202,12 +202,12 @@ :tag "PHPDoc Class Name") (defface php-class-declaration '((t (:inherit php-keyword))) - "Face used to highlight class declaration keywords" + "Face used to highlight class declaration keywords." :group 'php-faces :tag "PHP Class Declaration") (defface php-class-declaration-spec '((t (:inherit php-keyword))) - "Face used to highlight class declaration specification keywords (implements, extends)" + "Face used to highlight class declaration specification keywords (implements, extends)." :group 'php-faces :tag "PHP Class Declaration Specification") @@ -217,22 +217,32 @@ :tag "PHP Namespace Declaration") (defface php-import-declaration '((t (:inherit php-keyword))) - "Face used to highlight import statements (use ... as ...)" + "Face used to highlight import statements (use ... as ...)." :group 'php-faces :tag "PHP Import Statement") (defface php-class-modifiers '((t (:inherit php-keyword))) - "Face used to highlight class modifiers (final, abstract)" + "Face used to highlight class modifiers (final, abstract)." :group 'php-faces :tag "PHP Class Modifiers") (defface php-method-modifiers '((t (:inherit php-keyword))) - "Face used to highlight method modifiers (final, abstract)" + "Face used to highlight method modifiers (final, abstract)." :group 'php-faces :tag "PHP Method Modifiers") +(defface php-method-access '((t (:inherit php-keyword))) + "Face used to highlight method access keywords (public, protected, private)." + :group 'php-faces + :tag "PHP Method Access") + +(defface php-method-static '((t (:inherit php-keyword))) + "Face used to highlight static keyword in method declaration." + :group 'php-faces + :tag "PHP Method Static") + (defface php-property-access '((t (:inherit php-keyword))) - "Face used to highlight property access keywords (public, protected, public)" + "Face used to highlight property access keywords (public, protected, private)." :group 'php-faces :tag "PHP Property Access") diff --git a/php-mode.el b/php-mode.el index d6564b69..6fb60b58 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1559,7 +1559,10 @@ a completion list." ("\\(abstract\\|final\\)[[:space:]]\\(?:static\\|public\\|private\\|protected\\)" (1 'php-method-modifiers)) ;; Method access protection - + ("\\(private\\|protected\\|public\\)[[:space:]]\\(?:static\\|function\\)" (1 'php-method-access)) + + ;; Method static modifier + ("\\(static\\)[[:space:]]\\(?:public\\|protected\\|private\\|function\\)" (1 'php-method-static)) ;; Property access protection ;("\\(private\\|protected\\|public\\)\\(?:[[:space:]]const[[:space:]][[:word:]]\\|[[:space:]]\$[[:word:]]\\)" (1 'php-property-access)) From 3ddbffaee7b8afc62f9780bdd1e60dc5899e59e0 Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Thu, 2 Jan 2020 10:04:23 +0100 Subject: [PATCH 14/29] Make position of abstract/final keywords irrelevant in method declaration --- php-mode.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/php-mode.el b/php-mode.el index 6fb60b58..d980fea1 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1556,13 +1556,13 @@ a completion list." ("\\(abstract\\|final\\)[[:space:]]\\(?:class\\)" (1 'php-class-modifiers)) ;; Method modifiers (abstract, final) - ("\\(abstract\\|final\\)[[:space:]]\\(?:static\\|public\\|private\\|protected\\)" (1 'php-method-modifiers)) + ("\\(abstract\\|final\\)[[:space:]]\\(?:static\\|public\\|private\\|protected\\|function\\)" (1 'php-method-modifiers)) - ;; Method access protection - ("\\(private\\|protected\\|public\\)[[:space:]]\\(?:static\\|function\\)" (1 'php-method-access)) + ;; Method access protection (public, protected, private) + ("\\(private\\|protected\\|public\\)[[:space:]]\\(?:static\\|function\\|abstract|\\final\\)" (1 'php-method-access)) ;; Method static modifier - ("\\(static\\)[[:space:]]\\(?:public\\|protected\\|private\\|function\\)" (1 'php-method-static)) + ("\\(static\\)[[:space:]]\\(?:public\\|protected\\|private\\|function\\|abstract\\|final\\)" (1 'php-method-static)) ;; Property access protection ;("\\(private\\|protected\\|public\\)\\(?:[[:space:]]const[[:space:]][[:word:]]\\|[[:space:]]\$[[:word:]]\\)" (1 'php-property-access)) From cc050dfb11f9ea25e8fba6f624b8e7ae805edbd3 Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Thu, 2 Jan 2020 13:00:25 +0100 Subject: [PATCH 15/29] Change method faces to not collide with property faces; Add property access face --- php-face.el | 10 ++++++++++ php-mode.el | 15 +++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/php-face.el b/php-face.el index ba222992..42a6091e 100644 --- a/php-face.el +++ b/php-face.el @@ -246,6 +246,16 @@ :group 'php-faces :tag "PHP Property Access") +(defface php-property-const '((t (:inherit php-keyword))) + "Face used to highlight const keyword in property declaration." + :group 'php-faces + :tag "PHP Property Const") + +(defface php-property-static '((t (:inherit php-keyword))) + "Face used to highlight static keyword in property declaration." + :group 'php-faces + :tag "PHP Property Static") + (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 d980fea1..61fb60f5 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1556,16 +1556,23 @@ a completion list." ("\\(abstract\\|final\\)[[:space:]]\\(?:class\\)" (1 'php-class-modifiers)) ;; Method modifiers (abstract, final) - ("\\(abstract\\|final\\)[[:space:]]\\(?:static\\|public\\|private\\|protected\\|function\\)" (1 'php-method-modifiers)) + ("\\(abstract\\|final\\)\\(?:[[:space:]]static\\|[[:space:]]public\\|[[:space:]]private\\|[[:space:]]protected\\)*\\(?:[[:space:]]function\\)" (1 'php-method-modifiers)) ;; Method access protection (public, protected, private) - ("\\(private\\|protected\\|public\\)[[:space:]]\\(?:static\\|function\\|abstract|\\final\\)" (1 'php-method-access)) + ("\\(private\\|protected\\|public\\)\\(?:[[:space:]]static\\|[[:space:]]final\\|[[:space:]]abstract\\)*\\(?:[[:space:]]function\\)" (1 'php-method-access)) ;; Method static modifier - ("\\(static\\)[[:space:]]\\(?:public\\|protected\\|private\\|function\\|abstract\\|final\\)" (1 'php-method-static)) + ("\\(static\\)\\(?:[[:space:]]private\\|[[:space:]]protected\\|[[:space:]]public\\|[[:space:]]final\\|[[:space:]]abstract\\)*\\(?:[[:space:]]function\\)" (1 'php-method-static)) + + ;; Property constants + ("\\(const\\)[[:space:]]\\(?:[^\$][[:word:]]\\)" (1 'php-property-const)) ;; Property access protection - ;("\\(private\\|protected\\|public\\)\\(?:[[:space:]]const[[:space:]][[:word:]]\\|[[:space:]]\$[[:word:]]\\)" (1 'php-property-access)) + ("\\(private\\|protected\\|public\\)\\(?:[[:space:]]static\\|[[:space:]]const\\)?\\(?:[[:space:]]\$?[[:word:]]+\\)\\(?:[[:space:]]*=[[:space:]]*[^;]+\\)?\\(?:;\\)" (1 'php-property-access)) + ;("\\(private\\|protected\\|public\\)[[:space:]]\\(?:const[[:space:]][^\$][[:word:]]\\|\$[[:word:]]\\)" (1 'php-property-access)) + + ;; Property static modifier + ;;("\\(static\\)[[:space:]]\\(?:public\\|protected\\|private\\)" (1 'php-property-static)) ;; Highlight variables, e.g. 'var' in '$var' and '$obj->var', but ;; not in $obj->var() From 908cfa71de83e0cf39a3388d6fcf45ce1084c997 Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Thu, 2 Jan 2020 13:09:42 +0100 Subject: [PATCH 16/29] Add property constant regex --- php-mode.el | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/php-mode.el b/php-mode.el index 61fb60f5..38dad406 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1569,11 +1569,10 @@ a completion list." ;; Property access protection ("\\(private\\|protected\\|public\\)\\(?:[[:space:]]static\\|[[:space:]]const\\)?\\(?:[[:space:]]\$?[[:word:]]+\\)\\(?:[[:space:]]*=[[:space:]]*[^;]+\\)?\\(?:;\\)" (1 'php-property-access)) - ;("\\(private\\|protected\\|public\\)[[:space:]]\\(?:const[[:space:]][^\$][[:word:]]\\|\$[[:word:]]\\)" (1 'php-property-access)) ;; Property static modifier - ;;("\\(static\\)[[:space:]]\\(?:public\\|protected\\|private\\)" (1 'php-property-static)) - + ("\\(static\\)\\(?:[[:space:]]private\\|[[:space:]]protected\\|[[:space:]]public\\)?\\(?:[[:space:]]\$?[[:word:]]+\\)\\(?:[[:space:]]*=[[:space:]]*[^;]+\\)?\\(?:;\\)" (1 'php-property-static)) + ;; 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 249281d856af9a746f7f72766a5932ddb1b0a968 Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Thu, 2 Jan 2020 14:00:12 +0100 Subject: [PATCH 17/29] Add block statement face --- php-face.el | 5 +++++ php-mode.el | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/php-face.el b/php-face.el index 42a6091e..ba040d22 100644 --- a/php-face.el +++ b/php-face.el @@ -256,6 +256,11 @@ :group 'php-faces :tag "PHP Property Static") +(defface php-block-statement '((t (:inherit php-keyword))) + "Face used to highlight block statements (if, elseif, for, foreach, while, declare, switch, catch)." + :group 'php-faces + :tag "PHP Block Statement") + (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 38dad406..c784570a 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1572,7 +1572,10 @@ a completion list." ;; Property static modifier ("\\(static\\)\\(?:[[:space:]]private\\|[[:space:]]protected\\|[[:space:]]public\\)?\\(?:[[:space:]]\$?[[:word:]]+\\)\\(?:[[:space:]]*=[[:space:]]*[^;]+\\)?\\(?:;\\)" (1 'php-property-static)) - + + ;; Block statements (if, elseif, for, foreach, catch, switch, while, declare) + ("\\(if\\|elseif\\|for\\|foreach\\|catch\\|switch\\|while\\|declare\\)\\(?:[[:space:]]*\([[:space:]]*.*[[:space:]]*\)\\)" (1 'php-block-statement)) + ;; 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 a702767286cf2c64f9224d062344a0b9bcabd6cd Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Thu, 2 Jan 2020 14:06:23 +0100 Subject: [PATCH 18/29] Simplify block statement regex --- php-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php-mode.el b/php-mode.el index c784570a..7a094135 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1574,7 +1574,7 @@ a completion list." ("\\(static\\)\\(?:[[:space:]]private\\|[[:space:]]protected\\|[[:space:]]public\\)?\\(?:[[:space:]]\$?[[:word:]]+\\)\\(?:[[:space:]]*=[[:space:]]*[^;]+\\)?\\(?:;\\)" (1 'php-property-static)) ;; Block statements (if, elseif, for, foreach, catch, switch, while, declare) - ("\\(if\\|elseif\\|for\\|foreach\\|catch\\|switch\\|while\\|declare\\)\\(?:[[:space:]]*\([[:space:]]*.*[[:space:]]*\)\\)" (1 'php-block-statement)) + ("if\\|elseif\\|for\\|foreach\\|catch\\|switch\\|while\\|declare" . 'php-block-statement) ;; Highlight variables, e.g. 'var' in '$var' and '$obj->var', but ;; not in $obj->var() From 71f6998b2f2db7aaf9c8d2d76fee3034c02f4a93 Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Thu, 2 Jan 2020 14:30:11 +0100 Subject: [PATCH 19/29] Add flow-control, print and include statement faces --- php-face.el | 15 +++++++++++++++ php-mode.el | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/php-face.el b/php-face.el index ba040d22..bc493135 100644 --- a/php-face.el +++ b/php-face.el @@ -261,6 +261,21 @@ :group 'php-faces :tag "PHP Block Statement") +(defface php-flow-control-statement '((t (:inherit php-keyword))) + "Face used to highlight flow control statements (break, continue, die, exit, goto, return, throw)." + :group 'php-faces + :tag "PHP Flow Control Statement") + +(defface php-print-statement '((t (:inherit php-keyword))) + "Face used to highlight print statements (echo, print, var_dump)." + :group 'php-faces + :tag "PHP Print Statement") + +(defface php-include-statement '((t (:inherit php-keyword))) + "Face used to highlight include statements (include, include_once, require, require_once)." + :group 'php-faces + :tag "PHP Include Statement") + (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 7a094135..8e727352 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1575,6 +1575,15 @@ a completion list." ;; Block statements (if, elseif, for, foreach, catch, switch, while, declare) ("if\\|elseif\\|for\\|foreach\\|catch\\|switch\\|while\\|declare" . 'php-block-statement) + + ;; Flow control statements (break, continue, die, exit, goto, return, throw) + ("break\\|continue\\|die\\|exit\\|goto\\|return\\|throw" . 'php-flow-control-statement) + + ;; Print statements (echo, print, var_dump) + ("echo\\|print\\|var_dump" . 'php-print-statement) + + ;; Include statements (include, include_once, require, require_once) + ("include[^_]\\|include_once\\|require[^_]\\|require_once" . 'php-include-statement) ;; Highlight variables, e.g. 'var' in '$var' and '$obj->var', but ;; not in $obj->var() From c7abe0007fc1754c3527d9d7caae5cb8ae7ca23a Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Thu, 2 Jan 2020 14:38:47 +0100 Subject: [PATCH 20/29] Add constant keyword face --- php-face.el | 5 +++++ php-mode.el | 3 +++ 2 files changed, 8 insertions(+) diff --git a/php-face.el b/php-face.el index bc493135..1583afd0 100644 --- a/php-face.el +++ b/php-face.el @@ -276,6 +276,11 @@ :group 'php-faces :tag "PHP Include Statement") +(defface php-constant-keyword '((t (:inherit php-keyword))) + "Face used to highlight constant keywords (true, false, null)." + :group 'php-faces + :tag "PHP Constant Keywords") + (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 8e727352..114bded6 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1584,6 +1584,9 @@ a completion list." ;; Include statements (include, include_once, require, require_once) ("include[^_]\\|include_once\\|require[^_]\\|require_once" . 'php-include-statement) + + ;; Constant keywords + ("true\\|false\\|null" . 'php-constant-keyword) ;; Highlight variables, e.g. 'var' in '$var' and '$obj->var', but ;; not in $obj->var() From 9722ce8349b279de88a661ec8ae18ea9f79f1940 Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Thu, 2 Jan 2020 15:04:46 +0100 Subject: [PATCH 21/29] Add number face --- php-face.el | 5 +++++ php-mode.el | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/php-face.el b/php-face.el index 1583afd0..a9a555e2 100644 --- a/php-face.el +++ b/php-face.el @@ -281,6 +281,11 @@ :group 'php-faces :tag "PHP Constant Keywords") +(defface php-number '((t (:inherit default))) + "Face used to highlight numbers." + :group 'php-faces + :tag "PHP Numbers") + (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 114bded6..e5edc3ae 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1587,7 +1587,7 @@ a completion list." ;; Constant keywords ("true\\|false\\|null" . 'php-constant-keyword) - + ;; 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)) @@ -1720,7 +1720,10 @@ a completion list." ;; Logical operators (and, or, &&, ...) ;; Not operator (!) is defined in "before cc-mode" section above. - ("\\(&&\\|||\\)" 1 'php-logical-op))) + ("\\(&&\\|||\\)" 1 'php-logical-op) + + ;; Numbers + ("[0-9]+\\.?" . 'php-number))) "Detailed highlighting for PHP Mode.") (defvar php-font-lock-keywords php-font-lock-keywords-3 From c8c76cfc91d1f6674661ef4176eda830ffd063aa Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Thu, 2 Jan 2020 16:10:57 +0100 Subject: [PATCH 22/29] Add php-string-quote face --- php-face.el | 5 +++++ php-mode.el | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/php-face.el b/php-face.el index a9a555e2..1c781e1b 100644 --- a/php-face.el +++ b/php-face.el @@ -286,6 +286,11 @@ :group 'php-faces :tag "PHP Numbers") +(defface php-string-quote '((t (:inherit php-string))) + "Face used to highlight quotes surrounding a string." + :group 'php-faces + :tag "PHP String Quotes") + (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 e5edc3ae..b65b3736 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1721,7 +1721,7 @@ a completion list." ;; Logical operators (and, or, &&, ...) ;; Not operator (!) is defined in "before cc-mode" section above. ("\\(&&\\|||\\)" 1 'php-logical-op) - + ;; Numbers ("[0-9]+\\.?" . 'php-number))) "Detailed highlighting for PHP Mode.") @@ -1767,7 +1767,8 @@ The output will appear in the buffer *PHP*." '(progn (font-lock-add-keywords 'php-mode - `((php-string-intepolated-variable-font-lock-find)) + `((php-string-intepolated-variable-font-lock-find) + ("\\s\"\\|\\s|" 0 'php-string-quote t)) 'append))) From 91dbba53b7211c9b68402d1d7ab373392f29f978 Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Thu, 2 Jan 2020 16:20:47 +0100 Subject: [PATCH 23/29] Add block-delimiter face; fix wrong description --- php-face.el | 7 ++++++- php-mode.el | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/php-face.el b/php-face.el index 1c781e1b..075280af 100644 --- a/php-face.el +++ b/php-face.el @@ -117,7 +117,7 @@ :tag "PHP Increment/Decrement Op") (defface php-string-op '((t (:inherit php-operator))) - "PHP Mode face used to logical operators (.)." + "PHP Mode face used to string operator (.)." :group 'php-faces :tag "PHP String Op") @@ -291,6 +291,11 @@ :group 'php-faces :tag "PHP String Quotes") +(defface php-block-delimiter '((t (:inherit default))) + "Face used to highlight block delimiters ((, ), [, ], {, })" + :group 'php-faces + :tag "PHP Block Delimiters") + (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 b65b3736..9cb33a34 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1722,6 +1722,9 @@ a completion list." ;; Not operator (!) is defined in "before cc-mode" section above. ("\\(&&\\|||\\)" 1 'php-logical-op) + ;; Block delimiters ((, ), [, ], {, }) + ("\(\\|\)\\|\[\\|\]\\|\{\\|\}" . 'php-block-delimiter) + ;; Numbers ("[0-9]+\\.?" . 'php-number))) "Detailed highlighting for PHP Mode.") From d52ff615003ac34c178731a810ee6ca12fb84780 Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Thu, 2 Jan 2020 16:43:41 +0100 Subject: [PATCH 24/29] Add string and type operator faces --- php-face.el | 5 +++++ php-mode.el | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/php-face.el b/php-face.el index 075280af..3eb9146a 100644 --- a/php-face.el +++ b/php-face.el @@ -296,6 +296,11 @@ :group 'php-faces :tag "PHP Block Delimiters") +(defface php-type-operator '((t (:inherit default))) + "Face used to highlight type operators (insteadof, instanceof)" + :group 'php-faces + :tag "PHP Type Operators") + (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 9cb33a34..4030c494 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1582,6 +1582,9 @@ a completion list." ;; Print statements (echo, print, var_dump) ("echo\\|print\\|var_dump" . 'php-print-statement) + ;; Type operators (insteadof, instanceof) + ("insteadof\\|instanceof" . 'php-type-operator) + ;; Include statements (include, include_once, require, require_once) ("include[^_]\\|include_once\\|require[^_]\\|require_once" . 'php-include-statement) @@ -1722,6 +1725,9 @@ a completion list." ;; Not operator (!) is defined in "before cc-mode" section above. ("\\(&&\\|||\\)" 1 'php-logical-op) + ;; String operator (.) + ("\\(?:[^0-9[:space:]]\\)\\([[:space:]]*\\.[[:space:]]*\\)\\(?:[^0-9[:space:]]\\)" . (1 'php-string-op)) + ;; Block delimiters ((, ), [, ], {, }) ("\(\\|\)\\|\[\\|\]\\|\{\\|\}" . 'php-block-delimiter) From 74533cb790de61b415e12adf2cf6f388b6663d0a Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Thu, 2 Jan 2020 17:07:32 +0100 Subject: [PATCH 25/29] Fix [, ] in php-block-delimiter --- php-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php-mode.el b/php-mode.el index 4030c494..e3a083fa 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1729,7 +1729,7 @@ a completion list." ("\\(?:[^0-9[:space:]]\\)\\([[:space:]]*\\.[[:space:]]*\\)\\(?:[^0-9[:space:]]\\)" . (1 'php-string-op)) ;; Block delimiters ((, ), [, ], {, }) - ("\(\\|\)\\|\[\\|\]\\|\{\\|\}" . 'php-block-delimiter) + ("\(\\|\)\\|\\[\\|\\]\\|\{\\|\}" . 'php-block-delimiter) ;; Numbers ("[0-9]+\\.?" . 'php-number))) From 6589e7faf529a7da4527a6b05fca683f092911fc Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Fri, 3 Jan 2020 09:38:59 +0100 Subject: [PATCH 26/29] Adapt block statement regex to not catch occurences in strings --- php-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php-mode.el b/php-mode.el index e3a083fa..1243c98a 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1574,7 +1574,7 @@ a completion list." ("\\(static\\)\\(?:[[:space:]]private\\|[[:space:]]protected\\|[[:space:]]public\\)?\\(?:[[:space:]]\$?[[:word:]]+\\)\\(?:[[:space:]]*=[[:space:]]*[^;]+\\)?\\(?:;\\)" (1 'php-property-static)) ;; Block statements (if, elseif, for, foreach, catch, switch, while, declare) - ("if\\|elseif\\|for\\|foreach\\|catch\\|switch\\|while\\|declare" . 'php-block-statement) + ("\\(if\\|elseif\\|for\\|foreach\\|catch\\|switch\\|while\\|declare\\)\\(?:[[:space:]]*(\\)" (1 'php-block-statement)) ;; Flow control statements (break, continue, die, exit, goto, return, throw) ("break\\|continue\\|die\\|exit\\|goto\\|return\\|throw" . 'php-flow-control-statement) From c0794e8f87774bcebe08ccd21f59e9c23140f142 Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Fri, 3 Jan 2020 09:46:37 +0100 Subject: [PATCH 27/29] Normalize some of the face names --- php-face.el | 20 ++++++++++---------- php-mode.el | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/php-face.el b/php-face.el index 3eb9146a..6a497f74 100644 --- a/php-face.el +++ b/php-face.el @@ -219,17 +219,17 @@ (defface php-import-declaration '((t (:inherit php-keyword))) "Face used to highlight import statements (use ... as ...)." :group 'php-faces - :tag "PHP Import Statement") + :tag "PHP Import Declaration") -(defface php-class-modifiers '((t (:inherit php-keyword))) +(defface php-class-modifier '((t (:inherit php-keyword))) "Face used to highlight class modifiers (final, abstract)." :group 'php-faces - :tag "PHP Class Modifiers") + :tag "PHP Class Modifier") -(defface php-method-modifiers '((t (:inherit php-keyword))) +(defface php-method-modifier '((t (:inherit php-keyword))) "Face used to highlight method modifiers (final, abstract)." :group 'php-faces - :tag "PHP Method Modifiers") + :tag "PHP Method Modifier") (defface php-method-access '((t (:inherit php-keyword))) "Face used to highlight method access keywords (public, protected, private)." @@ -279,27 +279,27 @@ (defface php-constant-keyword '((t (:inherit php-keyword))) "Face used to highlight constant keywords (true, false, null)." :group 'php-faces - :tag "PHP Constant Keywords") + :tag "PHP Constant Keyword") (defface php-number '((t (:inherit default))) "Face used to highlight numbers." :group 'php-faces - :tag "PHP Numbers") + :tag "PHP Number") (defface php-string-quote '((t (:inherit php-string))) "Face used to highlight quotes surrounding a string." :group 'php-faces - :tag "PHP String Quotes") + :tag "PHP String Quote") (defface php-block-delimiter '((t (:inherit default))) "Face used to highlight block delimiters ((, ), [, ], {, })" :group 'php-faces - :tag "PHP Block Delimiters") + :tag "PHP Block Delimiter") (defface php-type-operator '((t (:inherit default))) "Face used to highlight type operators (insteadof, instanceof)" :group 'php-faces - :tag "PHP Type Operators") + :tag "PHP Type Op") (define-obsolete-face-alias 'php-annotations-annotation-face 'php-doc-annotation-tag "1.19.0") diff --git a/php-mode.el b/php-mode.el index 1243c98a..90eda39e 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1553,10 +1553,10 @@ a completion list." ("\\(?:[[:word:]\\]\\)\\([[:space:]]as\\)" (1 'php-import-declaration)) ;; Class modifiers (abstract, final) - ("\\(abstract\\|final\\)[[:space:]]\\(?:class\\)" (1 'php-class-modifiers)) + ("\\(abstract\\|final\\)[[:space:]]\\(?:class\\)" (1 'php-class-modifier)) ;; Method modifiers (abstract, final) - ("\\(abstract\\|final\\)\\(?:[[:space:]]static\\|[[:space:]]public\\|[[:space:]]private\\|[[:space:]]protected\\)*\\(?:[[:space:]]function\\)" (1 'php-method-modifiers)) + ("\\(abstract\\|final\\)\\(?:[[:space:]]static\\|[[:space:]]public\\|[[:space:]]private\\|[[:space:]]protected\\)*\\(?:[[:space:]]function\\)" (1 'php-method-modifier)) ;; Method access protection (public, protected, private) ("\\(private\\|protected\\|public\\)\\(?:[[:space:]]static\\|[[:space:]]final\\|[[:space:]]abstract\\)*\\(?:[[:space:]]function\\)" (1 'php-method-access)) From 3b1e86387c78219c60163b70bf1ffb36961d7598 Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Fri, 3 Jan 2020 12:46:06 +0100 Subject: [PATCH 28/29] Add return type colon face --- php-face.el | 6 ++++++ php-mode.el | 3 +++ 2 files changed, 9 insertions(+) diff --git a/php-face.el b/php-face.el index 6a497f74..ca4e38c2 100644 --- a/php-face.el +++ b/php-face.el @@ -301,6 +301,12 @@ :group 'php-faces :tag "PHP Type Op") + +(defface php-return-type-colon '((t (:inherit default))) + "Face used to highlight : character in front of return type." + :group 'php-faces + :tag "PHP Return Type Colon") + (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 90eda39e..daff902f 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1699,6 +1699,9 @@ a completion list." ;; Highlight the ? character for nullable type hints. ("\\(\\?\\)\\(:?\\sw\\|\\s_\\|\\\\\\)+\\s-+\\$" 1 font-lock-type-face) + ;; Highlight the : character in front of return types. + ("\\(?:function[[:space:]]+[[:word:]]+([[:word:][:space:],\$\\]*)\\)\\(:\\)" (1 'php-return-type-colon)) + ;; Class names without a namespace are not highlighted at all when they ;; are used as nullable type hints or return types (both nullable and ;; non-nullable). We have to use separate regular expressions, because From 244267ed769e745c414af15ab6d42da39708f95d Mon Sep 17 00:00:00 2001 From: Demis Balbach Date: Fri, 3 Jan 2020 13:20:08 +0100 Subject: [PATCH 29/29] Add function-keyword face --- php-face.el | 6 +++++- php-mode.el | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/php-face.el b/php-face.el index ca4e38c2..f875d61d 100644 --- a/php-face.el +++ b/php-face.el @@ -301,12 +301,16 @@ :group 'php-faces :tag "PHP Type Op") - (defface php-return-type-colon '((t (:inherit default))) "Face used to highlight : character in front of return type." :group 'php-faces :tag "PHP Return Type Colon") +(defface php-function-keyword '((t (:inherit php-keyword))) + "Face used to highlight the 'function' keyword in declaration." + :group 'php-faces + :tag "PHP Function Keyword") + (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 daff902f..afd8cc8b 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1564,6 +1564,9 @@ a completion list." ;; Method static modifier ("\\(static\\)\\(?:[[:space:]]private\\|[[:space:]]protected\\|[[:space:]]public\\|[[:space:]]final\\|[[:space:]]abstract\\)*\\(?:[[:space:]]function\\)" (1 'php-method-static)) + ;; function keyword + ("\\(function\\)\\(?:[[:space:]]+[_[:word:]\\]+[[:space:]]*(\\)" (1 'php-function-keyword)) + ;; Property constants ("\\(const\\)[[:space:]]\\(?:[^\$][[:word:]]\\)" (1 'php-property-const))