From 06da1d7aa5ddabd2cda93039a0df92e1f7b18011 Mon Sep 17 00:00:00 2001 From: fabacino Date: Mon, 23 Apr 2018 17:14:28 +0200 Subject: [PATCH] Fix highlighting of return types on different lines for abstract functions If a class name is specified as the return type of an abstract function and positioned on another line than the `function` keyword, the class name was not highlighted at all. This commit highlights such class names as return types. --- php-mode.el | 4 ++-- tests/type-hints.php | 6 ++++++ tests/type-hints.php.faces | 20 ++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/php-mode.el b/php-mode.el index a1b8208e..08d1d5b5 100644 --- a/php-mode.el +++ b/php-mode.el @@ -15,7 +15,7 @@ (defconst php-mode-version-number "1.19.0" "PHP Mode version number.") -(defconst php-mode-modified "2018-04-08" +(defconst php-mode-modified "2018-04-23" "PHP Mode build date.") ;; This file is free software; you can redistribute it and/or @@ -1700,7 +1700,7 @@ a completion list." ;; Highlight return types in functions and methods. ("function.+:\\s-*\\??\\(\\(?:\\sw\\|\\s_\\)+\\)" 1 font-lock-type-face) - (")\\s-*:\\s-*\\??\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*\{" 1 font-lock-type-face) + (")\\s-*:\\s-*\\??\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*\\(?:\{\\|;\\)" 1 font-lock-type-face) ;; Highlight class names used as nullable type hints ("\\?\\(\\(:?\\sw\\|\\s_\\)+\\)\\s-+\\$" 1 font-lock-type-face) diff --git a/tests/type-hints.php b/tests/type-hints.php index e5033f86..0fbb3892 100644 --- a/tests/type-hints.php +++ b/tests/type-hints.php @@ -125,6 +125,12 @@ public function getNullableObject( ): ?stdClass { } + abstract public function getOtherObject( + ): stdClass; + + abstract public function getOtherNullableObject( + ): ?stdClass; + public function getNsObject( ): \path\to\my\Object { } diff --git a/tests/type-hints.php.faces b/tests/type-hints.php.faces index 7b33ed6d..f5ba455a 100644 --- a/tests/type-hints.php.faces +++ b/tests/type-hints.php.faces @@ -343,6 +343,26 @@ ("(\n ): ?") ("stdClass" . font-lock-type-face) (" {\n }\n\n ") + ("abstract" . php-keyword) + (" ") + ("public" . php-keyword) + (" ") + ("function" . php-keyword) + (" ") + ("getOtherObject" . php-function-name) + ("(\n ): ") + ("stdClass" . font-lock-type-face) + (";\n\n ") + ("abstract" . php-keyword) + (" ") + ("public" . php-keyword) + (" ") + ("function" . php-keyword) + (" ") + ("getOtherNullableObject" . php-function-name) + ("(\n ): ?") + ("stdClass" . font-lock-type-face) + (";\n\n ") ("public" . php-keyword) (" ") ("function" . php-keyword)