Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ In chronological order:
72. tangxifan
73. [Serghei Iakovlev](https://github.com/sergeyklay)
74. [Christian Albrecht](https://github.com/calbrecht)
75. [Sebastian Fieber](https://github.com/fallchildren)



Expand Down
54 changes: 25 additions & 29 deletions php-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,14 @@ SYMBOL
(c-lang-defconst c-vsemi-status-unknown-p-fn
php 'php-c-vsemi-status-unknown-p)

(c-lang-defconst c-get-state-before-change-functions
php nil)

(c-lang-defconst c-before-font-lock-functions
php (if (fboundp #'c-depropertize-new-text)
'(c-depropertize-new-text)
nil))

;; Make php-mode recognize opening tags as preprocessor macro's.
;;
;; This is a workaround, the tags must be recognized as something
Expand Down Expand Up @@ -951,9 +959,10 @@ this ^ lineup"
(beginning-of-line)
(if (looking-at-p "\\s-*;\\s-*$") 0 '+)))

(defconst php-heredoc-start-re
"<<<\\(?:\\w+\\|'\\w+'\\)$"
"Regular expression for the start of a PHP heredoc.")
(eval-and-compile
(defconst php-heredoc-start-re
"<<<\\(?:\\w+\\|'\\w+'\\)$"
"Regular expression for the start of a PHP heredoc."))

(defun php-heredoc-end-re (heredoc-start)
"Build a regular expression for the end of a heredoc started by the string HEREDOC-START."
Expand All @@ -963,9 +972,6 @@ this ^ lineup"

(defun php-syntax-propertize-function (start end)
"Apply propertize rules from START to END."
;; (defconst php-syntax-propertize-function
;; (syntax-propertize-rules
;; (php-heredoc-start-re (0 (ignore (php-heredoc-syntax))))))
(goto-char start)
(while (and (< (point) end)
(re-search-forward php-heredoc-start-re end t))
Expand All @@ -974,7 +980,12 @@ 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 "_")))))
'syntax-table (string-to-syntax "_"))))
(funcall
(syntax-propertize-rules
("\\(\"\\)\\(\\\\.\\|[^\"\n\\]\\)*\\(\"\\)" (1 "\"") (3 "\""))
("\\('\\)\\(\\\\.\\|[^'\n\\]\\)*\\('\\)" (1 "\"") (3 "\"")))
start end))

(defun php-heredoc-syntax ()
"Mark the boundaries of searched heredoc."
Expand Down Expand Up @@ -1162,14 +1173,9 @@ After setting the stylevars run hooks according to STYLENAME
(modify-syntax-entry ?\n "> b" php-mode-syntax-table)
(modify-syntax-entry ?$ "'" php-mode-syntax-table)

(set (make-local-variable 'syntax-propertize-via-font-lock)
'(("\\(\"\\)\\(\\\\.\\|[^\"\n\\]\\)*\\(\"\\)" (1 "\"") (3 "\""))
("\\(\'\\)\\(\\\\.\\|[^\'\n\\]\\)*\\(\'\\)" (1 "\"") (3 "\""))))

(setq-local syntax-propertize-function #'php-syntax-propertize-function)
(add-to-list (make-local-variable 'syntax-propertize-extend-region-functions)
#'php-syntax-propertize-extend-region)
(set (make-local-variable 'syntax-propertize-function)
#'php-syntax-propertize-function)

(setq imenu-generic-expression php-imenu-generic-expression)

Expand Down Expand Up @@ -1516,8 +1522,8 @@ a completion list."

(defvar php-phpdoc-font-lock-keywords
`((,(lambda (limit)
(c-font-lock-doc-comments "/\\*\\*" limit
php-phpdoc-font-lock-doc-comments)))))
(c-font-lock-doc-comments "/\\*\\*" limit
php-phpdoc-font-lock-doc-comments)))))

(defconst php-font-lock-keywords-1 (c-lang-const c-matchers-1 php)
"Basic highlighting for PHP Mode.")
Expand Down Expand Up @@ -1558,6 +1564,10 @@ a completion list."
("\\b\\(array\\)\\s-+&?\\$" 1 font-lock-type-face)
(")\\s-*:\\s-*\\??\\(array\\)\\b" 1 font-lock-type-face)

;; namespaces
("\\(\\([a-zA-Z0-9]+\\\\\\)+[a-zA-Z0-9]+\\|\\(\\\\[a-zA-Z0-9]+\\)+\\)[^:a-zA-Z0-9\\\\]" 1 'font-lock-type-face)
("\\(\\([a-zA-Z0-9]+\\\\\\)+[a-zA-Z0-9]+\\|\\(\\\\[a-zA-Z0-9]+\\)+\\)::" 1 'php-constant)

;; Support the ::class constant in PHP5.6
("\\sw+\\(::\\)\\(class\\)\\b" (1 'php-paamayim-nekudotayim) (2 'php-constant)))

Expand Down Expand Up @@ -1698,20 +1708,6 @@ The output will appear in the buffer *PHP*."
(delete-char 1))))

(ad-activate 'fixup-whitespace)

;; Advice `font-lock-fontify-keywords-region' to support namespace
;; separators in class names. Use word syntax for backslashes when
;; doing keyword fontification, but not when doing syntactic
;; fontification because that breaks \ as escape character in strings.
;;
;; Special care is taken to restore the original syntax, because we
;; want \ not to be word for functions like forward-word.
(defadvice font-lock-fontify-keywords-region (around backslash-as-word activate)
"Fontify keywords with backslash as word character."
(let ((old-syntax (string (char-syntax ?\\))))
(modify-syntax-entry ?\\ "w")
ad-do-it
(modify-syntax-entry ?\\ old-syntax)))


(defcustom php-class-suffix-when-insert "::"
Expand Down