@@ -310,12 +310,6 @@ In that case set to `NIL'."
310310  :tag  " PHP Mode Enable Project Local Variable" 
311311  :type  'boolean )
312312
313- (defcustom  php-mode-use-php7-syntax-table  nil 
314-   " When set to `T' , use a syntax table compatible with PHP 7." 
315-   :group  'php-mode 
316-   :tag  " PHP Mode Enable Project Local Variable" 
317-   :type  'boolean )
318- 
319313(defconst  php-mode-cc-vertion 
320314  (eval-when-compile  c-version))
321315
@@ -915,9 +909,9 @@ This is was done due to the problem reported here:
915909    (unless  (php-in-string-or-comment-p)
916910      (or 
917911       ; ; Detect PHP8 attribute: <<Attribute()>>
918-        (when  (and  (<  2  pos) (<  2  (-  pos (c-point  'bol ))))
919-          (backward-char  2 )
920-          (looking-at-p  " >> \\ s-* \\ (?:<< \\ |$ \\ ) " 
912+        (when  (and  (<  1  pos) (<  1  (-  pos (c-point  'bol ))))
913+          (backward-char  1 )
914+          (looking-at-p  ( eval-when-compile  ( rx   " ] "  ( *  (syntax whitespace)) ( or   " #[ "  line-end))) ))
921915       ; ; Detect HTML/XML tag and PHP tag (<?php, <?=, ?>)
922916       (when  php-mode-template-compatibility
923917         (beginning-of-line )
@@ -968,7 +962,12 @@ this ^ lineup"
968962
969963(eval-and-compile 
970964  (defconst  php-heredoc-start-re 
971-     " <<<[ \t ]*\\ (?:\\ _<.+?\\ _>\\ |'\\ _<.+?\\ _>'\\ |\" \\ _<.+?\\ _>\" \\ )$" 
965+     (rx  " <<<" 
966+         (*  (syntax whitespace))
967+         (or  (group (+  (or  (syntax word) (syntax symbol))))
968+             (: " \" " +  (or  (syntax word) (syntax symbol)))) " \" " 
969+             (: " '" +  (or  (syntax word) (syntax symbol)))) " '" 
970+         line-end)
972971    " Regular expression for the start of a PHP heredoc." 
973972
974973(defun  php-heredoc-end-re  (heredoc-start )
@@ -977,54 +976,40 @@ this ^ lineup"
977976  (string-match  " \\ _<.+?\\ _>" 
978977  (concat  " ^\\ s-*\\ (" match-string  0  heredoc-start) " \\ )\\ W" 
979978
980- (defvar  php-syntax-propertize-functions 
981-   '(php-syntax-propertize-heredoc
982-     php-syntax-propertize-hash-line-comment
983-     php-syntax-propertize-quotes-in-comment)
984-   " Syntax propertize functions for PHP script." 
985- 
986- (defun  php-syntax-propertize-function  (start  end )
987-   " Apply propertize rules from START to END." 
988-   (dolist  (propertizer php-syntax-propertize-functions)
989-     (goto-char  start)
990-     (funcall  propertizer start end)))
991- 
992- (defun  php-syntax-propertize-heredoc  (_start  end )
993-   " Apply propertize Heredoc and Nowdoc from START to END." 
994-   (while  (and  (<  (point ) end)
995-               (re-search-forward  php-heredoc-start-re end t ))
996-     (php-heredoc-syntax)))
997- 
998- (defun  php-syntax-propertize-quotes-in-comment  (_start  end )
999-   " Apply propertize quotes (' and \" ) from START to END." 
1000-   (while  (re-search-forward  " ['\" ]" t )
1001-     (when  (php-in-comment-p)
1002-       (c-put-char-property  (match-beginning  0 )
1003-                            'syntax-table  (string-to-syntax  " _" 
1004- 
1005- (defun  php-syntax-propertize-hash-line-comment  (_start  end )
1006-   " Apply propertize # comment (without PHP8 Attributes) from START to END." 
1007-   (unless  php-mode-use-php7-syntax-table
1008-     (let  (line-end in-last-line)
1009-       (while  (and  (<  (point ) (min  end (point-max )))
1010-                   (not  in-last-line))
1011-         (setq  line-end (line-end-position ))
1012-         (when  (and  (search-forward  " #" t )
1013-                    (not  (php-in-string-or-comment-p))
1014-                    (not  (looking-at  " [[]" 
1015-           (c-put-char-property  (1-  (point )) 'syntax-table  (string-to-syntax  " < b" 
1016-         (move-beginning-of-line  2 )
1017-         (setq  in-last-line (>=  line-end (point )))))))
1018- 
1019- (defun  php-heredoc-syntax  ()
1020-   " Mark the boundaries of searched heredoc." 
1021-   (goto-char  (match-beginning  0 ))
1022-   (c-put-char-property  (point ) 'syntax-table  (string-to-syntax  " |" 
1023-   (if  (re-search-forward  (php-heredoc-end-re (match-string  0 )) nil  t )
1024-       (goto-char  (match-end  1 ))
1025-     ; ; Did not find the delimiter so go to the end of the buffer.
1026-     (goto-char  (point-max )))
1027-   (c-put-char-property  (1-  (point )) 'syntax-table  (string-to-syntax  " |" 
979+ (eval-and-compile 
980+   (defconst  php-syntax-propertize-rules 
981+     `((php-heredoc-start-re
982+        (0  (ignore  (php--syntax-propertize-heredoc
983+                    (match-beginning  0 )
984+                    (or  (match-string  1 ) (match-string  2 ) (match-string  3 ))
985+                    (null  (match-string  3 ))))))
986+       (,(rx  " #[" 
987+        (0  (ignore  (php--syntax-propertize-attributes (match-beginning  0 )))))
988+       (,(rx  (or  " '" " \" " 
989+        (0  (ignore  (php--syntax-propertize-quotes-in-comment (match-beginning  0 )))))))
990+ 
991+   (defmacro  php-build-propertize-function  ()
992+     `(syntax-propertize-rules  ,@php-syntax-propertize-rules ))
993+ 
994+   (defalias  'php-syntax-propertize-function  (php-build-propertize-function)))
995+ 
996+ (defun  php--syntax-propertize-heredoc  (start  id  is-heredoc )
997+   " Apply propertize Heredoc and Nowdoc from START, with ID and IS-HEREDOC." 
998+   (let  ((terminator (rx-to-string  `(: line-start (*  (syntax whitespace)) , id
999+     (put-text-property  start (1+  start) 'syntax-table  (string-to-syntax  " |" 
1000+     (re-search-forward  terminator nil  t )
1001+     (when  (match-string  0 )
1002+       (put-text-property  (1-  (point )) (point ) 'syntax-table  (string-to-syntax  " |" 
1003+ 
1004+ (defun  php--syntax-propertize-quotes-in-comment  (pos )
1005+   " Apply propertize quotes (' and \" ) from POS." 
1006+   (when  (php-in-comment-p)
1007+     (put-text-property  pos (1+  pos) 'syntax-table  (string-to-syntax  " _" 
1008+ 
1009+ (defun  php--syntax-propertize-attributes  (start )
1010+   " Apply propertize PHP8 #[Attributes] (without # comment) from START." 
1011+   (unless  (php-in-string-p)
1012+     (put-text-property  start (1+  start) 'syntax-table  (string-to-syntax  " ." 
10281013
10291014(defvar-local  php-mode--propertize-extend-region-current nil 
10301015  " Prevent undesirable recursion in PHP-SYNTAX-PROPERTIZE-EXTEND-REGION" 
@@ -1146,6 +1131,7 @@ After setting the stylevars run hooks according to STYLENAME
11461131    (modify-syntax-entry  ?_   " _" 
11471132    (modify-syntax-entry  ?`   " \" " 
11481133    (modify-syntax-entry  ?\"  " \" " 
1134+     (modify-syntax-entry  ?#   " < b" 
11491135    (modify-syntax-entry  ?\n  " > b" 
11501136    (modify-syntax-entry  ?$   " _" 
11511137    table))
@@ -1201,9 +1187,6 @@ After setting the stylevars run hooks according to STYLENAME
12011187  ; ; PHP vars are case-sensitive
12021188  (setq  case-fold-search t )
12031189
1204-   (when  php-mode-use-php7-syntax-table
1205-     (modify-syntax-entry  ?#   " < b" 
1206- 
12071190  (when  php-mode-enable-project-local-variable
12081191    (add-hook  'hack-local-variables-hook  #'php-mode-set-local-variable-delay   t  t ))
12091192
0 commit comments