From 27f280f5d90de6a6372697edacfd925e4fa39c60 Mon Sep 17 00:00:00 2001 From: USAMI Kenta <tadsan@zonu.me> Date: Wed, 13 Feb 2019 02:02:42 +0900 Subject: [PATCH 1/4] Remove file local variables for firestarter --- php-mode-test.el | 4 ---- 1 file changed, 4 deletions(-) diff --git a/php-mode-test.el b/php-mode-test.el index adf7d42b..5d37d8c5 100644 --- a/php-mode-test.el +++ b/php-mode-test.el @@ -945,7 +945,3 @@ style from Drupal." (php-project-get-root-dir)))) ;;; php-mode-test.el ends here - -;; Local Variables: -;; firestarter: ert-run-tests-interactively -;; End: From 27cb8066535a0d203e7ce4ba18e20a04b0494668 Mon Sep 17 00:00:00 2001 From: USAMI Kenta <tadsan@zonu.me> Date: Wed, 13 Feb 2019 03:15:14 +0900 Subject: [PATCH 2/4] 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 --- php-mode.el | 2 +- tests/issue-439.php | 10 ++++++++++ tests/issue-439.php.faces | 9 ++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/php-mode.el b/php-mode.el index 364937f0..9df5ba74 100644 --- a/php-mode.el +++ b/php-mode.el @@ -984,7 +984,7 @@ this ^ lineup" "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")) + (concat "^\\s-*\\(" (match-string 0 heredoc-start) "\\)\\W")) (defun php-syntax-propertize-function (start end) "Apply propertize rules from START to END." diff --git a/tests/issue-439.php b/tests/issue-439.php index 6d5a92d8..2280d7ac 100644 --- a/tests/issue-439.php +++ b/tests/issue-439.php @@ -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); +} diff --git a/tests/issue-439.php.faces b/tests/issue-439.php.faces index 91377cef..cc06b621 100644 --- a/tests/issue-439.php.faces +++ b/tests/issue-439.php.faces @@ -39,4 +39,11 @@ ("g" . php-variable-name) (" = ") ("<<<\"いろは\"\nLet'go Justin\nいろは" . php-string) - (";\n")) + (";\n\nvar_dump(") + ("<<<\"ABC\"\nLet'go Justin\nABC" . php-string) + (");\n\n") + ("if" . php-keyword) + (" (1 === 1) {\n var_dump(") + ("<<<\"ABC\"\n Let'go Justin\n ABC" . php-string) + (");\n}\n") + ) From 72f4ae0c01eb0732a8acb458485ee7290393f939 Mon Sep 17 00:00:00 2001 From: USAMI Kenta <tadsan@zonu.me> Date: Wed, 13 Feb 2019 03:52:16 +0900 Subject: [PATCH 3/4] Remove redundant matcher --- php-mode.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/php-mode.el b/php-mode.el index 9df5ba74..78e1151d 100644 --- a/php-mode.el +++ b/php-mode.el @@ -675,6 +675,10 @@ might be to handle switch and goto labels differently." (c-lang-const c-constant-kwds)) :test 'string-equal)))) +(c-lang-defconst c-basic-matchers-before + php (cl-remove-if (lambda (elm) (and (listp elm) (equal (car elm) "\\s|"))) + (c-lang-const c-basic-matchers-before php))) + (defun php-lineup-cascaded-calls (langelem) "Line up chained methods using `c-lineup-cascaded-calls', but only if the setting is enabled" From 51f30f4e727f870e77cfa0281ce345e90d53be96 Mon Sep 17 00:00:00 2001 From: USAMI Kenta <tadsan@zonu.me> Date: Wed, 13 Feb 2019 14:02:40 +0900 Subject: [PATCH 4/4] Remove unnecessary syntax-propertize-rules --- php-mode.el | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/php-mode.el b/php-mode.el index 78e1151d..64ea2aca 100644 --- a/php-mode.el +++ b/php-mode.el @@ -1000,12 +1000,7 @@ this ^ lineup" (while (re-search-forward "['\"]" end t) (when (php-in-comment-p) (c-put-char-property (match-beginning 0) - 'syntax-table (string-to-syntax "_")))) - (funcall - (syntax-propertize-rules - ("\\(\"\\)\\(\\\\.\\|[^\"\n\\]\\)*\\(\"\\)" (1 "\"") (3 "\"")) - ("\\('\\)\\(\\\\.\\|[^'\n\\]\\)*\\('\\)" (1 "\"") (3 "\""))) - start end)) + 'syntax-table (string-to-syntax "_"))))) (defun php-heredoc-syntax () "Mark the boundaries of searched heredoc."