Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion php-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,14 @@ a completion list."
;; Highlight static method calls as such. This is necessary for method
;; names which are identical to keywords to be highlighted correctly.
("\\sw+::\\(\\sw+\\)(" 1 'php-static-method-call)

;; Multiple catch (FooException | BarException $e)
(,(rx symbol-start "catch" symbol-end
(* (syntax whitespace)) "(" (* (syntax whitespace))
(group (+ (or (syntax word) (syntax symbol)))))
(1 font-lock-type-face)
(,(rx (* (syntax whitespace)) "|" (* (syntax whitespace))
(group (+ (or (syntax word) (syntax symbol))) symbol-end))
nil nil (1 font-lock-type-face)))
;; While c-opt-cpp-* highlights the <?php opening tags, it is not
;; possible to make it highlight short open tags and closing tags
;; as well. So we force the correct face on all cases that
Expand Down
7 changes: 7 additions & 0 deletions tests/lang/try-cactch/multiple.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

try {
} catch (ErrorException | PDOException $e) {
} catch (Foo | Bar | Buz | Fuga $e) {
} catch (Throwable $e) {
}
34 changes: 34 additions & 0 deletions tests/lang/try-cactch/multiple.php.faces
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
;; -*- mode: emacs-lisp -*-
(("<?php" . php-php-tag)
("\n\n")
("try" . php-keyword)
(" {\n} ")
("catch" . php-keyword)
(" (")
("ErrorException" . font-lock-type-face)
(" | ")
("PDOException" . font-lock-type-face)
(" ")
("$" . php-variable-sigil)
("e" . php-variable-name)
(") {\n} ")
("catch" . php-keyword)
(" (")
("Foo" . font-lock-type-face)
(" | ")
("Bar" . font-lock-type-face)
(" | ")
("Buz" . font-lock-type-face)
(" | ")
("Fuga" . font-lock-type-face)
(" ")
("$" . php-variable-sigil)
("e" . php-variable-name)
(") {\n} ")
("catch" . php-keyword)
(" (")
("Throwable" . font-lock-type-face)
(" ")
("$" . php-variable-sigil)
("e" . php-variable-name)
(") {\n}\n"))
1 change: 1 addition & 0 deletions tests/php-mode-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,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/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))
(with-php-mode-test ("lang/types/keywords.php" :faces t))
Expand Down