Skip to content

Commit 865bc84

Browse files
authored
Merge pull request #717 from emacs-php/refactor/phpdoc-type-variables
Add PHPDoc types and rename variable name
2 parents fe8ab09 + 7853345 commit 865bc84

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,20 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this
88

99
* **New feature: `php-complete`**
1010
* Add `php-complete-complete-function` to autocomplete function names ([#708])
11-
* Supports PHPDoc tags and types for static analysis tools ([#710])
11+
* Supports PHPDoc tags and types for static analysis tools ([#710], [#715], [#716], [#717], thanks to [@takeokunn])
12+
* Please refer to the article below
13+
* PHPStan: [PHPDoc Types](https://phpstan.org/writing-php-code/phpdoc-types)
14+
* PHPStan: [PHPDocs Basics](https://phpstan.org/writing-php-code/phpdocs-basics)
15+
* Psalm: [Atomic Type Reference](https://psalm.dev/docs/annotating_code/type_syntax/atomic_types/)
16+
* Psalm: [Supported Annotations](https://psalm.dev/docs/annotating_code/supported_annotations/)
17+
* Psalm: [Template Annotations](https://psalm.dev/docs/annotating_code/templated_annotations/)
1218

1319
### Changed
1420

1521
* Make continued expressions inside lists (arguments and arrays, etc.) have the same indent width as outside the list ([#703])
1622
* (internal) Improved readability of test failures about indentation ([#707])
1723
* `php-doc-annotation-tag` inherits `font-lock-doc-markup-face` if defined in Emacs 28 ([#711])
24+
* Change `php-phpdoc-type-keywords` to `php-phpdoc-type-names` to avoid confusion ([#717])
1825

1926
### Fixed
2027

@@ -26,6 +33,9 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this
2633
[#708]: https://github.com/emacs-php/php-mode/pull/708
2734
[#710]: https://github.com/emacs-php/php-mode/pull/710
2835
[#711]: https://github.com/emacs-php/php-mode/pull/711
36+
[#715]: https://github.com/emacs-php/php-mode/pull/715
37+
[#716]: https://github.com/emacs-php/php-mode/pull/716
38+
[#717]: https://github.com/emacs-php/php-mode/pull/717
2939

3040
## [1.24.1] - 2022-10-08
3141

lisp/php-mode.el

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@ for \\[find-tag] (which see)."
12751275
(message "Unknown function: %s" tagname))))
12761276

12771277
;; Font Lock
1278-
(defconst php-phpdoc-type-keywords
1278+
(defconst php-phpdoc-type-names
12791279
(list "string" "integer" "int" "boolean" "bool" "float"
12801280
"double" "object" "mixed" "array" "resource"
12811281
"void" "null" "false" "true" "self" "static"
@@ -1287,11 +1287,18 @@ for \\[find-tag] (which see)."
12871287
"never" "never-return" "never-returns" "no-return" "non-empty-array"
12881288
"non-empty-list" "non-empty-string" "non-falsy-string"
12891289
"numeric" "numeric-string" "positive-int" "scalar"
1290-
"trait-string" "truthy-string" "key-of" "value-of"))
1290+
"trait-string" "truthy-string" "key-of" "value-of")
1291+
"A list of type and pseudotype names that can be used in PHPDoc.")
1292+
1293+
(make-obsolete-variable 'php-phpdoc-type-keywords 'php-phpdoc-type-names "1.24.2")
12911294

12921295
(defconst php-phpdoc-type-tags
12931296
(list "package" "param" "property" "property-read" "property-write"
1294-
"return" "throws" "var" "self-out" "this-out" "param-out"))
1297+
"return" "throws" "var" "self-out" "this-out" "param-out"
1298+
"type" "extends" "require-extends" "implemtents" "require-implements"
1299+
"template" "template-covariant" "template-extends" "template-implements"
1300+
"assert" "assert-if-true" "assert-if-false" "if-this-is")
1301+
"A list of tags specifying type names.")
12951302

12961303
(defconst php-phpdoc-font-lock-doc-comments
12971304
`(("{@[-[:alpha:]]+\\s-*\\([^}]*\\)}" ; "{@foo ...}" markup.
@@ -1301,11 +1308,11 @@ for \\[find-tag] (which see)."
13011308
(1 'php-doc-variable-sigil prepend nil)
13021309
(2 'php-variable-name prepend nil))
13031310
("\\(\\$\\)\\(this\\)\\>" (1 'php-doc-$this-sigil prepend nil) (2 'php-doc-$this prepend nil))
1304-
(,(concat "\\s-@" (rx (? (or "phpstan" "psalm") "-")) (regexp-opt php-phpdoc-type-tags) "\\s-+"
1311+
(,(concat "\\s-@" (rx (? (or "phan" "phpstan" "psalm") "-")) (regexp-opt php-phpdoc-type-tags) "\\s-+"
13051312
"\\(" (rx (+ (? "?") (? "\\") (+ (in "0-9A-Z_a-z")) (? "[]") (? "|"))) "\\)+")
13061313
1 'php-string prepend nil)
13071314
(,(concat "\\(?:|\\|\\?\\|\\s-\\)\\("
1308-
(regexp-opt php-phpdoc-type-keywords 'words)
1315+
(regexp-opt php-phpdoc-type-names 'words)
13091316
"\\)")
13101317
1 font-lock-type-face prepend nil)
13111318
("https?://[^\n\t ]+"

0 commit comments

Comments
 (0)