Skip to content

Commit d139461

Browse files
committed
Support PHPStan and Psalm tags
1 parent 7ed83bc commit d139461

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

lisp/php-mode.el

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,10 +1325,17 @@ for \\[find-tag] (which see)."
13251325
"return" "throws" "var" "self-out" "this-out" "param-out"
13261326
"type" "extends" "require-extends" "implemtents" "require-implements"
13271327
"template" "template-covariant" "template-extends" "template-implements"
1328-
"require-extends" "require-implements"
1329-
"assert" "assert-if-true" "assert-if-false" "if-this-is")
1328+
"assert" "assert-if-true" "assert-if-false")
13301329
"A list of tags specifying type names.")
13311330

1331+
(defconst php-phpdoc-no-prefixed-tags
1332+
(list "phpstan-require-extends" "phpstan-require-implements" "phpstan-sealed"
1333+
"phpstan-self-out" "phpstan-this-out" "phpstan-type" "psalm-if-this-is"
1334+
"psalm-import-type" "psalm-inheritors" "psalm-require-extends"
1335+
"psalm-require-implements" "psalm-self-out" "psalm-this-out"
1336+
"phan-type" "psalm-type")
1337+
"A list of tags specifying type with no-prefixed names.")
1338+
13321339
(defconst php-phpdoc-font-lock-doc-comments
13331340
`(("{@[-[:alpha:]]+\\s-*\\([^}]*\\)}" ; "{@foo ...}" markup.
13341341
(0 'php-doc-annotation-tag prepend nil)
@@ -1337,7 +1344,13 @@ for \\[find-tag] (which see)."
13371344
(1 'php-doc-variable-sigil prepend nil)
13381345
(2 'php-variable-name prepend nil))
13391346
("\\(\\$\\)\\(this\\)\\>" (1 'php-doc-$this-sigil prepend nil) (2 'php-doc-$this prepend nil))
1340-
(,(concat "\\s-@" (rx (? (or "phan" "phpstan" "psalm") "-")) (regexp-opt php-phpdoc-type-tags) "\\s-+"
1347+
(,(concat "\\s-@"
1348+
(rx-to-string `(or (: (? (or "phan" "phpstan" "psalm") "-")
1349+
(or ,@php-phpdoc-type-tags))
1350+
;(or ,@php-phpdoc-no-prefixed-tags)
1351+
)
1352+
t)
1353+
"\\s-+"
13411354
"\\(" (rx (+ (? "?") (? "\\") (+ (in "0-9A-Z_a-z")) (? "[]") (? "|"))) "\\)+")
13421355
1 'php-string prepend nil)
13431356
(,(concat "\\(?:|\\|\\?\\|\\s-\\)\\("

0 commit comments

Comments
 (0)