@@ -633,6 +633,34 @@ might be to handle switch and goto labels differently."
633633(c-lang-defconst c-opt-<>-sexp-key
634634 php nil )
635635
636+ (defconst php-mode--re-return-typed-closure
637+ (eval-when-compile
638+ (rx symbol-start " function" symbol-end
639+ (* (syntax whitespace))
640+ " (" (* (not (any " (" ))) " )"
641+ (* (syntax whitespace))
642+ (? symbol-start " use" symbol-end
643+ (* (syntax whitespace))
644+ " (" (* (not (any " (" ))) " )"
645+ (* (syntax whitespace)))
646+ " :" (+ (not (any " {}" )))
647+ (group " {" ))))
648+
649+ (defun php-c-lineup-arglist (langelem )
650+ " Line up the current argument line under the first argument using `c-lineup-arglist' LANGELEM."
651+ (let (in-return-typed-closure)
652+ (when (and (consp langelem)
653+ (eq 'arglist-cont-nonempty (car langelem)))
654+ (save-excursion
655+ (save-match-data
656+ (when (and (re-search-backward php-mode--re-return-typed-closure (cdr langelem) t )
657+ (progn
658+ (goto-char (match-data 1 ))
659+ (not (php-in-string-or-comment-p))))
660+ (setq in-return-typed-closure t )))))
661+ (unless in-return-typed-closure
662+ (c-lineup-arglist langelem))))
663+
636664(defun php-lineup-cascaded-calls (langelem )
637665 " Line up chained methods using `c-lineup-cascaded-calls' ,
638666but only if the setting is enabled"
@@ -644,7 +672,7 @@ but only if the setting is enabled"
644672 `((c-basic-offset . 4 )
645673 (c-offsets-alist . ((arglist-close . php-lineup-arglist-close)
646674 (arglist-cont . (first php-lineup-cascaded-calls 0 ))
647- (arglist-cont-nonempty . (first php-lineup-cascaded-calls c-lineup-arglist))
675+ (arglist-cont-nonempty . (first php-lineup-cascaded-calls php- c-lineup-arglist))
648676 (arglist-intro . php-lineup-arglist-intro)
649677 (case-label . + )
650678 (class-open . 0 )
0 commit comments