Skip to content

Commit a31e780

Browse files
committed
Fix heredoc pattern and support 7.3 heredoc
This change has support for 7.3 form of heredoc and suppression of errors occurring in that code. In this new syntax, arbitrary space is allowed before the termination ID of heredoc. https://wiki.php.net/rfc/flexible_heredoc_nowdoc_indentation http://php.net/manual/en/migration73.new-features.php
1 parent 27f280f commit a31e780

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Diff for: php-mode.el

+3-2
Original file line numberDiff line numberDiff line change
@@ -983,8 +983,9 @@ this ^ lineup"
983983
(defun php-heredoc-end-re (heredoc-start)
984984
"Build a regular expression for the end of a heredoc started by the string HEREDOC-START."
985985
;; Extract just the identifier without <<< and quotes.
986-
(string-match "\\_<.+?\\_>" heredoc-start)
987-
(concat "^\\(" (match-string 0 heredoc-start) "\\)\\W"))
986+
(save-excursion
987+
(string-match "\\_<.+?\\_>" heredoc-start)
988+
(concat "^\\s-*\\(" (match-string 0 heredoc-start) "\\)\\W")))
988989

989990
(defun php-syntax-propertize-function (start end)
990991
"Apply propertize rules from START to END."

Diff for: tests/issue-439.php

+10
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,13 @@
3131
$g = <<<"いろは"
3232
Let'go Justin
3333
いろは;
34+
35+
var_dump(<<<"ABC"
36+
Let'go Justin
37+
ABC);
38+
39+
if (1 === 1) {
40+
var_dump(<<<"ABC"
41+
Let'go Justin
42+
ABC);
43+
}

0 commit comments

Comments
 (0)