emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/php-mode 0526c4310a 4/4: Merge pull request #710 from emac


From: ELPA Syncer
Subject: [nongnu] elpa/php-mode 0526c4310a 4/4: Merge pull request #710 from emacs-php/feature/phpdoc-type-names
Date: Thu, 27 Oct 2022 11:59:34 -0400 (EDT)

branch: elpa/php-mode
commit 0526c4310ae9c6be8e70553b8d894f5e4e7f117e
Merge: 29bbf49cd5 9424e19eb5
Author: USAMI Kenta <tadsan@pixiv.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #710 from emacs-php/feature/phpdoc-type-names
    
    Supports PHPDoc tags and types for static analysis tools
---
 CHANGELOG.md                                 |  2 ++
 lisp/php-mode.el                             | 12 ++++++++++--
 tests/lang/doc-comment/return-type.php.faces | 20 +++++++++++++++-----
 3 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 426174e365..27b4cbde58 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@ 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])
 
 ### Changed
 
@@ -22,6 +23,7 @@ All notable changes of the PHP Mode 1.19.1 release series are 
documented in this
 [#704]: https://github.com/emacs-php/php-mode/pull/704
 [#707]: https://github.com/emacs-php/php-mode/pull/707
 [#708]: https://github.com/emacs-php/php-mode/pull/708
+[#710]: https://github.com/emacs-php/php-mode/pull/710
 
 ## [1.24.1] - 2022-10-08
 
diff --git a/lisp/php-mode.el b/lisp/php-mode.el
index 241e2c9697..e1ee50d8b9 100644
--- a/lisp/php-mode.el
+++ b/lisp/php-mode.el
@@ -1279,7 +1279,15 @@ for \\[find-tag] (which see)."
   (list "string" "integer" "int" "boolean" "bool" "float"
         "double" "object" "mixed" "array" "resource"
         "void" "null" "false" "true" "self" "static"
-        "callable" "iterable" "number"))
+        "callable" "iterable" "number"
+        ;; PHPStan and Psalm types
+        "array-key" "associative-array" "callable-array" "callable-object"
+        "callable-string" "class-string" "empty" "enum-string" "list"
+        "literal-string" "negative-int" "non-positive-int" "non-negative-int"
+        "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"))
 
 (defconst php-phpdoc-type-tags
   (list "package" "param" "property" "property-read" "property-write"
@@ -1293,7 +1301,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-@" (regexp-opt php-phpdoc-type-tags) "\\s-+"
+    (,(concat "\\s-@" (rx (? (or "phpstan" "psalm") "-")) (regexp-opt 
php-phpdoc-type-tags) "\\s-+"
               "\\(" (rx (+ (? "?") (? "\\") (+ (in "0-9A-Z_a-z")) (? "[]") (? 
"|"))) "\\)+")
      1 'php-string prepend nil)
     (,(concat "\\(?:|\\|\\?\\|\\s-\\)\\("
diff --git a/tests/lang/doc-comment/return-type.php.faces 
b/tests/lang/doc-comment/return-type.php.faces
index 13d08f2fc8..7bc8a8ec17 100644
--- a/tests/lang/doc-comment/return-type.php.faces
+++ b/tests/lang/doc-comment/return-type.php.faces
@@ -32,7 +32,9 @@
  (" " . font-lock-doc-face)
  ("int" font-lock-type-face php-string font-lock-doc-face)
  ("[]" php-string font-lock-doc-face)
- (" A list of " . font-lock-doc-face)
+ (" A " . font-lock-doc-face)
+ ("list" font-lock-type-face font-lock-doc-face)
+ (" of " . font-lock-doc-face)
  ("integer" font-lock-type-face font-lock-doc-face)
  (" values */" . font-lock-doc-face)
  ("\n\n\n")
@@ -59,7 +61,9 @@
  ("@return" php-doc-annotation-tag font-lock-doc-face)
  (" " . font-lock-doc-face)
  ("DateTime[]" php-string font-lock-doc-face)
- (" A list of DateTime " . font-lock-doc-face)
+ (" A " . font-lock-doc-face)
+ ("list" font-lock-type-face font-lock-doc-face)
+ (" of DateTime " . font-lock-doc-face)
  ("object" font-lock-type-face font-lock-doc-face)
  (" values */" . font-lock-doc-face)
  ("\n\n\n")
@@ -86,7 +90,9 @@
  ("@return" php-doc-annotation-tag font-lock-doc-face)
  (" " . font-lock-doc-face)
  ("stdClass[]" php-string font-lock-doc-face)
- (" A list of stdClass " . font-lock-doc-face)
+ (" A " . font-lock-doc-face)
+ ("list" font-lock-type-face font-lock-doc-face)
+ (" of stdClass " . font-lock-doc-face)
  ("object" font-lock-type-face font-lock-doc-face)
  (" values */" . font-lock-doc-face)
  ("\n\n")
@@ -113,7 +119,9 @@
  ("@return" php-doc-annotation-tag font-lock-doc-face)
  (" " . font-lock-doc-face)
  ("\\App\\User[]" php-string font-lock-doc-face)
- (" A list of \\App\\User " . font-lock-doc-face)
+ (" A " . font-lock-doc-face)
+ ("list" font-lock-type-face font-lock-doc-face)
+ (" of \\App\\User " . font-lock-doc-face)
  ("object" font-lock-type-face font-lock-doc-face)
  (" values */" . font-lock-doc-face)
  ("\n\n")
@@ -138,7 +146,9 @@
  ("int" font-lock-type-face php-string font-lock-doc-face)
  ("[]|" php-string font-lock-doc-face)
  ("string" font-lock-type-face php-string font-lock-doc-face)
- ("  Multiple types by list of " . font-lock-doc-face)
+ ("  Multiple types by " . font-lock-doc-face)
+ ("list" font-lock-type-face font-lock-doc-face)
+ (" of " . font-lock-doc-face)
  ("int" font-lock-type-face font-lock-doc-face)
  (" and " . font-lock-doc-face)
  ("string" font-lock-type-face font-lock-doc-face)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]