Skip to content

Commit 1756d81

Browse files
authored
Merge pull request #496 from emacs-php/fix/heredoc-error
Fix heredoc pattern and support 7.3 heredoc
2 parents 37191d8 + 51f30f4 commit 1756d81

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

php-mode.el

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ this ^ lineup"
988988
"Build a regular expression for the end of a heredoc started by the string HEREDOC-START."
989989
;; Extract just the identifier without <<< and quotes.
990990
(string-match "\\_<.+?\\_>" heredoc-start)
991-
(concat "^\\(" (match-string 0 heredoc-start) "\\)\\W"))
991+
(concat "^\\s-*\\(" (match-string 0 heredoc-start) "\\)\\W"))
992992

993993
(defun php-syntax-propertize-function (start end)
994994
"Apply propertize rules from START to END."
@@ -1000,12 +1000,7 @@ this ^ lineup"
10001000
(while (re-search-forward "['\"]" end t)
10011001
(when (php-in-comment-p)
10021002
(c-put-char-property (match-beginning 0)
1003-
'syntax-table (string-to-syntax "_"))))
1004-
(funcall
1005-
(syntax-propertize-rules
1006-
("\\(\"\\)\\(\\\\.\\|[^\"\n\\]\\)*\\(\"\\)" (1 "\"") (3 "\""))
1007-
("\\('\\)\\(\\\\.\\|[^'\n\\]\\)*\\('\\)" (1 "\"") (3 "\"")))
1008-
start end))
1003+
'syntax-table (string-to-syntax "_")))))
10091004

10101005
(defun php-heredoc-syntax ()
10111006
"Mark the boundaries of searched heredoc."

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)