Skip to content

Commit

Permalink
Merge pull request #461 from fabacino/bugfix/fix-return-type-highligh…
Browse files Browse the repository at this point in the history
…ting

Fix highlighting of return types for abstract functions
  • Loading branch information
zonuexe authored Apr 23, 2018
2 parents 52ae90a + 06da1d7 commit e85d963
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions php-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions tests/type-hints.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
}
Expand Down
20 changes: 20 additions & 0 deletions tests/type-hints.php.faces
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e85d963

Please sign in to comment.