@@ -481,6 +481,14 @@ SYMBOL
481481(c-lang-defconst c-vsemi-status-unknown-p-fn
482482 php 'php-c-vsemi-status-unknown-p )
483483
484+ (c-lang-defconst c-get-state-before-change-functions
485+ php nil )
486+
487+ (c-lang-defconst c-before-font-lock-functions
488+ php (if (fboundp #'c-depropertize-new-text )
489+ '(c-depropertize-new-text)
490+ nil ))
491+
484492; ; Make php-mode recognize opening tags as preprocessor macro's.
485493; ;
486494; ; This is a workaround, the tags must be recognized as something
@@ -951,9 +959,10 @@ this ^ lineup"
951959 (beginning-of-line )
952960 (if (looking-at-p " \\ s-*;\\ s-*$" ) 0 '+ )))
953961
954- (defconst php-heredoc-start-re
955- " <<<\\ (?:\\ w+\\ |'\\ w+'\\ )$"
956- " Regular expression for the start of a PHP heredoc." )
962+ (eval-and-compile
963+ (defconst php-heredoc-start-re
964+ " <<<\\ (?:\\ w+\\ |'\\ w+'\\ )$"
965+ " Regular expression for the start of a PHP heredoc." ))
957966
958967(defun php-heredoc-end-re (heredoc-start )
959968 " Build a regular expression for the end of a heredoc started by the string HEREDOC-START."
@@ -963,9 +972,6 @@ this ^ lineup"
963972
964973(defun php-syntax-propertize-function (start end )
965974 " Apply propertize rules from START to END."
966- ; ; (defconst php-syntax-propertize-function
967- ; ; (syntax-propertize-rules
968- ; ; (php-heredoc-start-re (0 (ignore (php-heredoc-syntax))))))
969975 (goto-char start)
970976 (while (and (< (point ) end)
971977 (re-search-forward php-heredoc-start-re end t ))
@@ -974,7 +980,12 @@ this ^ lineup"
974980 (while (re-search-forward " ['\" ]" end t )
975981 (when (php-in-comment-p)
976982 (c-put-char-property (match-beginning 0 )
977- 'syntax-table (string-to-syntax " _" )))))
983+ 'syntax-table (string-to-syntax " _" ))))
984+ (funcall
985+ (syntax-propertize-rules
986+ (" \\ (\" \\ )\\ (\\\\ .\\ |[^\"\n \\ ]\\ )*\\ (\" \\ )" (1 " \" " ) (3 " \" " ))
987+ (" \\ ('\\ )\\ (\\\\ .\\ |[^'\n \\ ]\\ )*\\ ('\\ )" (1 " \" " ) (3 " \" " )))
988+ start end))
978989
979990(defun php-heredoc-syntax ()
980991 " Mark the boundaries of searched heredoc."
@@ -1162,14 +1173,9 @@ After setting the stylevars run hooks according to STYLENAME
11621173 (modify-syntax-entry ?\n " > b" php-mode-syntax-table)
11631174 (modify-syntax-entry ?$ " '" php-mode-syntax-table)
11641175
1165- (set (make-local-variable 'syntax-propertize-via-font-lock )
1166- '((" \\ (\" \\ )\\ (\\\\ .\\ |[^\"\n \\ ]\\ )*\\ (\" \\ )" (1 " \" " ) (3 " \" " ))
1167- (" \\ (\' \\ )\\ (\\\\ .\\ |[^\'\n \\ ]\\ )*\\ (\' \\ )" (1 " \" " ) (3 " \" " ))))
1168-
1176+ (setq-local syntax-propertize-function #'php-syntax-propertize-function )
11691177 (add-to-list (make-local-variable 'syntax-propertize-extend-region-functions )
11701178 #'php-syntax-propertize-extend-region )
1171- (set (make-local-variable 'syntax-propertize-function )
1172- #'php-syntax-propertize-function )
11731179
11741180 (setq imenu-generic-expression php-imenu-generic-expression)
11751181
@@ -1516,8 +1522,8 @@ a completion list."
15161522
15171523(defvar php-phpdoc-font-lock-keywords
15181524 `((,(lambda (limit )
1519- (c-font-lock-doc-comments " /\\ *\\ *" limit
1520- php-phpdoc-font-lock-doc-comments)))))
1525+ (c-font-lock-doc-comments " /\\ *\\ *" limit
1526+ php-phpdoc-font-lock-doc-comments)))))
15211527
15221528(defconst php-font-lock-keywords-1 (c-lang-const c-matchers-1 php)
15231529 " Basic highlighting for PHP Mode." )
@@ -1558,6 +1564,10 @@ a completion list."
15581564 (" \\ b\\ (array\\ )\\ s-+&?\\ $" 1 font-lock-type-face )
15591565 (" )\\ s-*:\\ s-*\\ ??\\ (array\\ )\\ b" 1 font-lock-type-face )
15601566
1567+ ; ; namespaces
1568+ (" \\ (\\ ([a-zA-Z0-9]+\\\\\\ )+[a-zA-Z0-9]+\\ |\\ (\\\\ [a-zA-Z0-9]+\\ )+\\ )[^:a-zA-Z0-9\\\\ ]" 1 'font-lock-type-face )
1569+ (" \\ (\\ ([a-zA-Z0-9]+\\\\\\ )+[a-zA-Z0-9]+\\ |\\ (\\\\ [a-zA-Z0-9]+\\ )+\\ )::" 1 'php-constant )
1570+
15611571 ; ; Support the ::class constant in PHP5.6
15621572 (" \\ sw+\\ (::\\ )\\ (class\\ )\\ b" (1 'php-paamayim-nekudotayim ) (2 'php-constant )))
15631573
@@ -1698,20 +1708,6 @@ The output will appear in the buffer *PHP*."
16981708 (delete-char 1 ))))
16991709
17001710(ad-activate 'fixup-whitespace )
1701-
1702- ; ; Advice `font-lock-fontify-keywords-region' to support namespace
1703- ; ; separators in class names. Use word syntax for backslashes when
1704- ; ; doing keyword fontification, but not when doing syntactic
1705- ; ; fontification because that breaks \ as escape character in strings.
1706- ; ;
1707- ; ; Special care is taken to restore the original syntax, because we
1708- ; ; want \ not to be word for functions like forward-word.
1709- (defadvice font-lock-fontify-keywords-region (around backslash-as-word activate)
1710- " Fontify keywords with backslash as word character."
1711- (let ((old-syntax (string (char-syntax ?\\ ))))
1712- (modify-syntax-entry ?\\ " w" )
1713- ad-do-it
1714- (modify-syntax-entry ?\\ old-syntax)))
17151711
17161712
17171713(defcustom php-class-suffix-when-insert " ::"
0 commit comments