Skip to content

Commit 27cb806

Browse files
committed
Fix heredoc pattern and support 7.3 heredoc
This change has support for 7.3 form of heredoc. 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 27cb806

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

php-mode.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ this ^ lineup"
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.
986986
(string-match "\\_<.+?\\_>" heredoc-start)
987-
(concat "^\\(" (match-string 0 heredoc-start) "\\)\\W"))
987+
(concat "^\\s-*\\(" (match-string 0 heredoc-start) "\\)\\W"))
988988

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

tests/issue-439.php

Lines changed: 10 additions & 0 deletions
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+
}

tests/issue-439.php.faces

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,11 @@
3939
("g" . php-variable-name)
4040
(" = ")
4141
("<<<\"いろは\"\nLet'go Justin\nいろは" . php-string)
42-
(";\n"))
42+
(";\n\nvar_dump(")
43+
("<<<\"ABC\"\nLet'go Justin\nABC" . php-string)
44+
(");\n\n")
45+
("if" . php-keyword)
46+
(" (1 === 1) {\n var_dump(")
47+
("<<<\"ABC\"\n Let'go Justin\n ABC" . php-string)
48+
(");\n}\n")
49+
)

0 commit comments

Comments
 (0)