From 66e062a158d0913178bca24f6cd8adffccf37c96 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sat, 10 Mar 2018 01:10:07 +0900 Subject: [PATCH 1/2] Add test for #439 GitHub-Issue: #439 --- php-mode-test.el | 4 ++++ tests/issue-439.php | 33 ++++++++++++++++++++++++++++++ tests/issue-439.php.faces | 42 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 tests/issue-439.php create mode 100644 tests/issue-439.php.faces diff --git a/php-mode-test.el b/php-mode-test.el index 32753fce..9f9a343a 100644 --- a/php-mode-test.el +++ b/php-mode-test.el @@ -914,6 +914,10 @@ style from Drupal." (set-auto-mode) (should (not (eq 'php-mode major-mode)))))) +(ert-deftest php-mode-test-issue-439 () + "Various heredoc/nowdoc formats are highlighted appropriately." + (with-php-mode-test ("issue-439.php" :faces t))) + (ert-deftest php-mode-test-type-hints () "Test highlighting of type hints and return types." (with-php-mode-test ("type-hints.php" :faces t))) diff --git a/tests/issue-439.php b/tests/issue-439.php new file mode 100644 index 00000000..8ca36676 --- /dev/null +++ b/tests/issue-439.php @@ -0,0 +1,33 @@ + Date: Sat, 10 Mar 2018 01:11:31 +0900 Subject: [PATCH 2/2] Fix #439 heredoc syntax probrem Syntax of heredoc/nowdoc is here. http://php.net/manual/language.types.string.php#language.types.string.syntax.heredoc --- php-mode.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/php-mode.el b/php-mode.el index 2e23642e..70e7efc1 100644 --- a/php-mode.el +++ b/php-mode.el @@ -934,13 +934,13 @@ this ^ lineup" (eval-and-compile (defconst php-heredoc-start-re - "<<<\\(?:\\w+\\|'\\w+'\\)$" + "<<<\\(?:\\_<.+?\\_>\\|'\\_<.+?\\_>'\\|\"\\_<.+?\\_>\"\\)$" "Regular expression for the start of a PHP heredoc.")) (defun php-heredoc-end-re (heredoc-start) "Build a regular expression for the end of a heredoc started by the string HEREDOC-START." ;; Extract just the identifier without <<< and quotes. - (string-match "\\w+" heredoc-start) + (string-match "\\_<.+?\\_>" heredoc-start) (concat "^\\(" (match-string 0 heredoc-start) "\\)\\W")) (defun php-syntax-propertize-function (start end)