Skip to content

Commit

Permalink
Fix heredoc pattern and support 7.3 heredoc
Browse files Browse the repository at this point in the history
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
  • Loading branch information
zonuexe committed Feb 12, 2019
1 parent 27f280f commit a31e780
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions php-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -983,8 +983,9 @@ this ^ lineup"
(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 "\\_<.+?\\_>" heredoc-start)
(concat "^\\(" (match-string 0 heredoc-start) "\\)\\W"))
(save-excursion
(string-match "\\_<.+?\\_>" heredoc-start)
(concat "^\\s-*\\(" (match-string 0 heredoc-start) "\\)\\W")))

(defun php-syntax-propertize-function (start end)
"Apply propertize rules from START to END."
Expand Down
10 changes: 10 additions & 0 deletions tests/issue-439.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,13 @@
$g = <<<"いろは"
Let'go Justin
いろは;

var_dump(<<<"ABC"
Let'go Justin
ABC);

if (1 === 1) {
var_dump(<<<"ABC"
Let'go Justin
ABC);
}

0 comments on commit a31e780

Please sign in to comment.