Function: web-mode-set-php-controls

web-mode-set-php-controls is a natively compiled function defined in web-mode.el.

Signature

(web-mode-set-php-controls REG-BEG REG-END)

Source Code

;; Defined in /nix/store/2qgnz1rp30nzfz6w0apx4kdm14if1bbs-emacs-packages-deps/share/emacs/site-lisp/elpa/web-mode-20260831.219/web-mode.el
(defun web-mode-set-php-controls (reg-beg reg-end)
  (goto-char reg-beg)
  (let (match controls
              (continue t)
              (regexp "endif\\|endforeach\\|endfor\\|endwhile\\|elseif\\|else\\|if\\|foreach\\|for\\|while"))
    (while continue
      (if (not (web-mode-block-rsf regexp reg-end))
          (setq continue nil)
          (setq match (match-string-no-properties 0))
          ;;        (message "%S %S" match (point))
          (cond
            ((and (member match '("else" "elseif"))
                  (looking-at-p "[ ]*[:(]"))
             (setq controls (append controls (list (cons 'inside "if"))))
             )
            ((and (>= (length match) 3)
                  (string= (substring match 0 3) "end"))
             (setq controls (append controls (list (cons 'close (substring match 3)))))
             )
            ((and (progn (skip-chars-forward "[ ]") t)
                  (eq (char-after) ?\()
                  (web-mode-closing-paren reg-end)
                  ;;(progn (message "ixi%S" (point)))
                  (looking-at-p ")[ ]*:"))
             (setq controls (append controls (list (cons 'open match))))
             )
            ) ;cond
          ) ;if
      ) ;while
    ;;(message "%S-%S %S" reg-beg reg-end controls)
    (when (and controls (> (length controls) 1))
      (setq controls (web-mode-block-controls-reduce controls)))
    controls))