aboutsummaryrefslogtreecommitdiffstats
path: root/oni-php/oni-php.el
diff options
context:
space:
mode:
Diffstat (limited to 'oni-php/oni-php.el')
-rw-r--r--oni-php/oni-php.el14
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))