Skip to content

Commit ce95b90

Browse files
committed
Added tags specialization
since the introduction of static analysis tools in php we see that those tools (phpstan, psalm) both support prefixed tags in their parsing. By explicit mention the already supported syntax for those tags, we make sure to include those tool specs in the standard.
1 parent 397d1a9 commit ce95b90

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

proposed/phpdoc.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ PSR-5: PHPDoc
1212
- [5.2. Description](#52-description)
1313
- [5.2.1 Inline tags](#521-inline-tags)
1414
- [5.3. Tags](#53-tags)
15-
- [5.3.1. Tag Name](#531-tag-name)
15+
- [5.3.1. Tag Specialization](#531-tag-specialization)
16+
- [5.3.2. Tag Name](#532-tag-name)
1617
- [5.4. Examples](#54-examples)
1718
- [Appendix A. Types](#appendix-a-types)
1819
- [ABNF](#abnf)
@@ -198,9 +199,9 @@ The PHPDoc format has the following [ABNF][RFC5234] definition:
198199
; with inline tags inside
199200
tags = *(tag 1*eol)
200201
inline-tag = "{" tag "}"
201-
tag = "@" tag-name [":" tag-specialization] [tag-details]
202+
tag = "@"[tag-specialization "-"] tag-name [tag-details]
202203
tag-name = (ALPHA / "\") *(ALPHA / DIGIT / "\" / "-" / "_")
203-
tag-specialization = 1*(ALPHA / DIGIT / "-")
204+
tag-specialization = 1*(ALPHA / DIGIT)
204205
tag-details = (1*SP tag-description)
205206
tag-description = (CHAR / inline-tag) *(CHAR / inline-tag / eol)
206207
tag-argument = *SP 1*CHAR [","] *SP
@@ -297,7 +298,21 @@ tags are semantically identical:
297298

298299
This definition does NOT apply to _Annotation_ tags, which are not in scope.
299300

300-
#### 5.3.1. Tag Name
301+
#### 5.3.1 Tag Specialization
302+
303+
Tag specialization give a scope to the tag. It is RECOMMENDED to follow the
304+
list of tags in the tag [Tag Catalog PSR][TAG_PSR]. But the metadata of specialized
305+
tags MAY differ from the list.
306+
307+
```php
308+
/**
309+
* @vendor-tag This is a description
310+
*/
311+
```
312+
313+
Parsers MAY ignore specialized tags when they are in a supported format.
314+
315+
#### 5.3.2. Tag Name
301316

302317
Tag names indicate what type of information is represented by this tag.
303318

0 commit comments

Comments
 (0)