Skip to content
Merged
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
24 changes: 24 additions & 0 deletions php-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,9 @@ PHP does not have an \"enum\"-like keyword."
(c-lang-defconst c-lambda-kwds
php '("function" "use"))

(c-lang-defconst c-inexpr-block-kwds
php '("match"))

(c-lang-defconst c-other-block-decl-kwds
php '("namespace"))

Expand Down Expand Up @@ -643,6 +646,23 @@ but only if the setting is enabled"
(beginning-of-line)
(if (looking-at-p "\\s-*->") '+ nil))))

(defun php-c-looking-at-or-maybe-in-bracelist (&optional containing-sexp lim)
"Replace `c-looking-at-or-maybe-in-bracelist'.

CONTAINING-SEXP is the position of the brace/paren/bracket enclosing
POINT, or nil if there is no such position, or we do not know it. LIM is
a backward search limit."
(cond
((looking-at-p "{")
(save-excursion
(c-backward-token-2 2 t lim)
;; PHP 8.0 match expression
;; echo match ($var) |{
;; ↑ matches ↑ initial position
(when (looking-at-p (eval-when-compile (rx symbol-start "match" symbol-end)))
(cons (point) t))))
(t nil)))

(c-add-style
"php"
`((c-basic-offset . 4)
Expand Down Expand Up @@ -1186,6 +1206,10 @@ After setting the stylevars run hooks according to STYLENAME
(setq-local add-log-current-defun-function nil)
(setq-local add-log-current-defun-header-regexp php-beginning-of-defun-regexp)

(when (fboundp #'c-looking-at-or-maybe-in-bracelist)
(advice-add #'c-looking-at-or-maybe-in-bracelist
:override 'php-c-looking-at-or-maybe-in-bracelist))

(when (>= emacs-major-version 25)
(with-silent-modifications
(save-excursion
Expand Down