diff options
| author | 2026-05-21 09:44:57 -0700 | |
|---|---|---|
| committer | 2026-05-21 09:44:57 -0700 | |
| commit | 57c4bf1e4e271eb8be8716c5e543f07fed6856db (patch) | |
| tree | 791750ca1b6d4bd8c6449c7f55f6457392d6e544 | |
| parent | 59e0a0b53a166d4b1e8d01361a6adf55ad53fa6f (diff) | |
| download | emacs-config-57c4bf1e4e271eb8be8716c5e543f07fed6856db.tar.gz emacs-config-57c4bf1e4e271eb8be8716c5e543f07fed6856db.zip | |
oni-php: Add BelongsTo type comment for return types
| -rw-r--r-- | oni-php/oni-php.el | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/oni-php/oni-php.el b/oni-php/oni-php.el index 753d03c..01c9388 100644 --- a/oni-php/oni-php.el +++ b/oni-php/oni-php.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse <tom@ryuslash.org> ;; Keywords: local -;; Version: 2026.0515.155805 +;; Version: 2026.0521.094427 ;; Package-Requires: (oni-yasnippet oni-flycheck oni-hydra oni-corfu fic-mode rainbow-delimiters rainbow-identifiers) ;; This program is free software; you can redistribute it and/or modify @@ -159,6 +159,15 @@ Do the insert N times." (indent-region start (point)) (goto-char insert-marker)))) +(defun oni-php-return-belongs-to-comment () + "Insert a PHP documentation comment for a BelongsTo return type." + (interactive) + (let ((start (point))) + (insert "/**\n * @return BelongsTo<") + (save-excursion + (insert ", $this>\n */") + (indent-region start (point))))) + (defun oni-php-comment-dwim (func &rest args) "See if a PHP documentation comment should be added and add it. Otherwise call FUNC with ARGS. This is meant as advice around @@ -166,6 +175,9 @@ Otherwise call FUNC with ARGS. This is meant as advice around (cond ((looking-at (rx (minimal-match (zero-or-more (any whitespace "\n"))) "use ")) (oni-php-doc-use-comment)) + ((looking-at (rx (minimal-match (zero-or-more (any whitespace "\n"))) + (one-or-more nonl) ": BelongsTo" eol)) + (oni-php-return-belongs-to-comment)) ((and (derived-mode-p 'php-mode) (not (region-active-p)) (looking-back (rx (minimal-match (zero-or-more blank))) (line-beginning-position)) |
