@@ -1442,7 +1442,9 @@ for \\[find-tag] (which see)."
1442
1442
1443
1443
; ; Logical operators (and, or, &&, ...)
1444
1444
; ; Not operator (!) is defined in "before cc-mode" section above.
1445
- (" \\ (&&\\ |||\\ )" 1 'php-logical-op )))
1445
+ (" \\ (&&\\ |||\\ )" 1 'php-logical-op )
1446
+ ; ; string interpolation ("$var, ${var}, {$var}")
1447
+ (php-mode--string-interpolated-variable-font-lock-find 0 nil )))
1446
1448
" Detailed highlighting for PHP Mode." )
1447
1449
1448
1450
(defvar php-font-lock-keywords php-font-lock-keywords-3
@@ -1474,22 +1476,15 @@ The output will appear in the buffer *PHP*."
1474
1476
(defconst php-string-interpolated-variable-regexp
1475
1477
" {\\ $[^}\n \\\\ ]*\\ (?:\\\\ .[^}\n \\\\ ]*\\ )*}\\ |\\ ${\\ sw+}\\ |\\ $\\ sw+" )
1476
1478
1477
- (defun php-string-intepolated-variable-font-lock-find (limit )
1478
- (while (re-search-forward php-string-interpolated-variable-regexp limit t )
1479
- (let ((quoted-stuff (nth 3 (syntax-ppss ))))
1479
+ (defun php-mode--string-interpolated-variable-font-lock-find (limit )
1480
+ " Apply text-property to LIMIT for string interpolation by font-lock."
1481
+ (let (quoted-stuff)
1482
+ (while (re-search-forward php-string-interpolated-variable-regexp limit t )
1483
+ (setq quoted-stuff (php-in-string-p))
1480
1484
(when (or (eq ?\" quoted-stuff) (eq ?` quoted-stuff))
1481
- (put-text-property (match-beginning 0 ) (match-end 0 )
1482
- 'face 'php-variable-name ))))
1485
+ (put-text-property (match-beginning 0 ) (match-end 0 ) 'face 'php-variable-name ))))
1483
1486
nil )
1484
-
1485
- (eval-after-load 'php-mode
1486
- '(progn
1487
- (font-lock-add-keywords
1488
- 'php-mode
1489
- `((php-string-intepolated-variable-font-lock-find))
1490
- 'append )))
1491
1487
1492
-
1493
1488
; ;; Correct the behavior of `delete-indentation' by modifying the
1494
1489
; ;; logic of `fixup-whitespace' .
1495
1490
(defun php-mode--fixup-whitespace-after ()
0 commit comments