From 08776c1b50dc58622ff8da732bbbd6c1d99d78f3 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Fri, 4 Nov 2022 00:18:30 +0900 Subject: [PATCH 1/5] Changed variable name to php-phpdoc-type-names to avoid confusion --- lisp/php-mode.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lisp/php-mode.el b/lisp/php-mode.el index 37f2ba60..0336e8ef 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -1275,7 +1275,7 @@ for \\[find-tag] (which see)." (message "Unknown function: %s" tagname)))) ;; Font Lock -(defconst php-phpdoc-type-keywords +(defconst php-phpdoc-type-names (list "string" "integer" "int" "boolean" "bool" "float" "double" "object" "mixed" "array" "resource" "void" "null" "false" "true" "self" "static" @@ -1287,7 +1287,10 @@ for \\[find-tag] (which see)." "never" "never-return" "never-returns" "no-return" "non-empty-array" "non-empty-list" "non-empty-string" "non-falsy-string" "numeric" "numeric-string" "positive-int" "scalar" - "trait-string" "truthy-string" "key-of" "value-of")) + "trait-string" "truthy-string" "key-of" "value-of") + "A list of type and pseudotype names that can be used in PHPDoc.") + +(make-obsolete-variable 'php-phpdoc-type-keywords 'php-phpdoc-type-names "1.24.2") (defconst php-phpdoc-type-tags (list "package" "param" "property" "property-read" "property-write" @@ -1305,7 +1308,7 @@ for \\[find-tag] (which see)." "\\(" (rx (+ (? "?") (? "\\") (+ (in "0-9A-Z_a-z")) (? "[]") (? "|"))) "\\)+") 1 'php-string prepend nil) (,(concat "\\(?:|\\|\\?\\|\\s-\\)\\(" - (regexp-opt php-phpdoc-type-keywords 'words) + (regexp-opt php-phpdoc-type-names 'words) "\\)") 1 font-lock-type-face prepend nil) ("https?://[^\n\t ]+" From 44601ab2dfe329e52c2e186b3ba59c2a8ce3969c Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Fri, 4 Nov 2022 00:19:05 +0900 Subject: [PATCH 2/5] Add "phan" to type tag vendor prefix --- lisp/php-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/php-mode.el b/lisp/php-mode.el index 0336e8ef..ee747b05 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -1304,7 +1304,7 @@ for \\[find-tag] (which see)." (1 'php-doc-variable-sigil prepend nil) (2 'php-variable-name prepend nil)) ("\\(\\$\\)\\(this\\)\\>" (1 'php-doc-$this-sigil prepend nil) (2 'php-doc-$this prepend nil)) - (,(concat "\\s-@" (rx (? (or "phpstan" "psalm") "-")) (regexp-opt php-phpdoc-type-tags) "\\s-+" + (,(concat "\\s-@" (rx (? (or "phan" "phpstan" "psalm") "-")) (regexp-opt php-phpdoc-type-tags) "\\s-+" "\\(" (rx (+ (? "?") (? "\\") (+ (in "0-9A-Z_a-z")) (? "[]") (? "|"))) "\\)+") 1 'php-string prepend nil) (,(concat "\\(?:|\\|\\?\\|\\s-\\)\\(" From 0bbdc46e01abb9243421e9cf1af2675ba5a11519 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Fri, 4 Nov 2022 00:19:58 +0900 Subject: [PATCH 3/5] Add "type" to php-phpdoc-type-tags as "phpstan-type" --- lisp/php-mode.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/php-mode.el b/lisp/php-mode.el index ee747b05..effe99e6 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -1294,7 +1294,9 @@ for \\[find-tag] (which see)." (defconst php-phpdoc-type-tags (list "package" "param" "property" "property-read" "property-write" - "return" "throws" "var" "self-out" "this-out" "param-out")) + "return" "throws" "var" "self-out" "this-out" "param-out" + "type") + "A list of tags specifying type names.") (defconst php-phpdoc-font-lock-doc-comments `(("{@[-[:alpha:]]+\\s-*\\([^}]*\\)}" ; "{@foo ...}" markup. From 258d6c5460bcb8b484a53ac8f628488fe5518908 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Fri, 4 Nov 2022 01:06:00 +0900 Subject: [PATCH 4/5] Add Psalm template annotations to php-phpdoc-type-tags --- lisp/php-mode.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/php-mode.el b/lisp/php-mode.el index effe99e6..5e5b66e7 100644 --- a/lisp/php-mode.el +++ b/lisp/php-mode.el @@ -1295,7 +1295,9 @@ for \\[find-tag] (which see)." (defconst php-phpdoc-type-tags (list "package" "param" "property" "property-read" "property-write" "return" "throws" "var" "self-out" "this-out" "param-out" - "type") + "type" "extends" "require-extends" "implemtents" "require-implements" + "template" "template-covariant" "template-extends" "template-implements" + "assert" "assert-if-true" "assert-if-false" "if-this-is") "A list of tags specifying type names.") (defconst php-phpdoc-font-lock-doc-comments From 7853345918b8dd96992e6af97676ffb3aad16cb7 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Fri, 4 Nov 2022 01:15:03 +0900 Subject: [PATCH 5/5] Update CHANGELOG --- CHANGELOG.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd522ba1..1cccfd13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,13 +8,20 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this * **New feature: `php-complete`** * Add `php-complete-complete-function` to autocomplete function names ([#708]) - * Supports PHPDoc tags and types for static analysis tools ([#710]) + * Supports PHPDoc tags and types for static analysis tools ([#710], [#715], [#716], [#717], thanks to [@takeokunn]) + * Please refer to the article below + * PHPStan: [PHPDoc Types](https://phpstan.org/writing-php-code/phpdoc-types) + * PHPStan: [PHPDocs Basics](https://phpstan.org/writing-php-code/phpdocs-basics) + * Psalm: [Atomic Type Reference](https://psalm.dev/docs/annotating_code/type_syntax/atomic_types/) + * Psalm: [Supported Annotations](https://psalm.dev/docs/annotating_code/supported_annotations/) + * Psalm: [Template Annotations](https://psalm.dev/docs/annotating_code/templated_annotations/) ### Changed * Make continued expressions inside lists (arguments and arrays, etc.) have the same indent width as outside the list ([#703]) * (internal) Improved readability of test failures about indentation ([#707]) * `php-doc-annotation-tag` inherits `font-lock-doc-markup-face` if defined in Emacs 28 ([#711]) + * Change `php-phpdoc-type-keywords` to `php-phpdoc-type-names` to avoid confusion ([#717]) ### Fixed @@ -26,6 +33,9 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this [#708]: https://github.com/emacs-php/php-mode/pull/708 [#710]: https://github.com/emacs-php/php-mode/pull/710 [#711]: https://github.com/emacs-php/php-mode/pull/711 +[#715]: https://github.com/emacs-php/php-mode/pull/715 +[#716]: https://github.com/emacs-php/php-mode/pull/716 +[#717]: https://github.com/emacs-php/php-mode/pull/717 ## [1.24.1] - 2022-10-08