Skip to content

Commit 0df631b

Browse files
authored
Merge pull request #1249 from ezimuel/psr-19/generated
[PSR-19] Proposal for adding generated tag
2 parents 4103c9b + 2b79442 commit 0df631b

File tree

1 file changed

+87
-35
lines changed

1 file changed

+87
-35
lines changed

proposed/phpdoc-tags.md

Lines changed: 87 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,21 @@ PSR-19: PHPDoc tags
1818
- [5.2. @author](#52-author)
1919
- [5.3. @copyright](#53-copyright)
2020
- [5.4. @deprecated](#54-deprecated)
21-
- [5.5. @internal](#55-internal)
22-
- [5.6. @link](#56-link)
23-
- [5.7. @method](#57-method)
24-
- [5.8. @package](#58-package)
25-
- [5.9. @param](#59-param)
26-
- [5.10. @property](#510-property)
27-
- [5.11. @return](#511-return)
28-
- [5.12. @see](#512-see)
29-
- [5.13. @since](#513-since)
30-
- [5.14. @throws](#514-throws)
31-
- [5.15. @todo](#515-todo)
32-
- [5.16. @uses](#516-uses)
33-
- [5.17. @var](#517-var)
34-
- [5.18. @version](#518-version)
21+
- [5.5. @generated](#55-generated)
22+
- [5.6. @internal](#56-internal)
23+
- [5.7. @link](#57-link)
24+
- [5.8. @method](#58-method)
25+
- [5.9. @package](#59-package)
26+
- [5.10. @param](#510-param)
27+
- [5.11. @property](#511-property)
28+
- [5.12. @return](#512-return)
29+
- [5.13. @see](#513-see)
30+
- [5.14. @since](#514-since)
31+
- [5.15. @throws](#515-throws)
32+
- [5.16. @todo](#516-todo)
33+
- [5.17. @uses](#517-uses)
34+
- [5.18. @var](#518-var)
35+
- [5.19. @version](#519-version)
3536

3637
## 1. Introduction
3738

@@ -71,7 +72,7 @@ parts if that part is absent:
7172
* A specific subset of [Tags]([PHPDOC_PSR]#53-tags):
7273
* [@author](#52-author)
7374
* [@copyright](#53-copyright)
74-
* [@version](#518-version)
75+
* [@version](#519-version)
7576

7677
The PHPDoc for each type of "Structural Element" MUST also inherit a
7778
specialized subset of tags depending on which "Structural Element" is
@@ -170,23 +171,23 @@ combination of the Description of the super-element, indicated by the
170171
In addition to the inherited descriptions and tags as defined in this chapter's
171172
root, a class or interface MUST inherit the following tags:
172173

173-
* [@package](#58-package)
174+
* [@package](#59-package)
174175

175176
### 4.3.2. Function Or Method
176177

177178
In addition to the inherited descriptions and tags as defined in this chapter's
178179
root, a function or method in a class or interface MUST inherit the following tags:
179180

180-
* [@param](#59-param)
181-
* [@return](#511-return)
182-
* [@throws](#514-throws)
181+
* [@param](#510-param)
182+
* [@return](#512-return)
183+
* [@throws](#515-throws)
183184

184185
### 4.3.3. Constant Or Property
185186

186187
In addition to the inherited descriptions and tags as defined in this chapter's
187188
root, a constant or property in a class MUST inherit the following tags:
188189

189-
* [@var](#517-type)
190+
* [@var](#518-type)
190191

191192
## 5. Tags
192193

@@ -211,7 +212,7 @@ API components of a library or framework.
211212
Other "Structural Elements" with a public visibility MAY be listed less
212213
prominently in generated documentation.
213214

214-
See also the [`@internal`](#55-internal), which MAY be used to hide internal
215+
See also the [`@internal`](#56-internal), which MAY be used to hide internal
215216
"Structural Elements" from generated documentation.
216217

217218
#### Examples
@@ -326,7 +327,58 @@ If the associated element is superseded by another it is RECOMMENDED to add a
326327
*/
327328
```
328329

329-
### 5.5. @internal
330+
### 5.5. @generated
331+
332+
The @generated tag indicates that the code has been generated using an
333+
automation script.
334+
335+
#### Syntax
336+
337+
@generated [description]
338+
339+
#### Description
340+
341+
The `@generated` is used to denote a class or a function that has been
342+
generated using an automation script. This tag should be used to warn
343+
to not change the code, since the change will be overwritten by the
344+
automation script.
345+
346+
#### Examples
347+
348+
Mark a class that has been generated using a PHP script.
349+
350+
```php
351+
/**
352+
* Index a document in Elasticsearch
353+
*
354+
* @generated class generated using bin/script.php, please DO NOT EDIT!
355+
*
356+
* @version 7.14.0 Elasticsearch
357+
*/
358+
class Index
359+
{
360+
<...>
361+
}
362+
```
363+
364+
Mark a function that has been generated using a PHP script.
365+
366+
```php
367+
368+
/**
369+
* @generated function generated using bin/script.php, please DO NOT EDIT!
370+
*
371+
* @params array $params parameters for the index API endpoint
372+
*
373+
* @return array response from Elasticsearch
374+
*/
375+
function index(array $params): array
376+
{
377+
<...>
378+
}
379+
```
380+
381+
### 5.6. @internal
330382

331383
The @internal tag is used to denote that the associated "Structural Element" is
332384
a structure internal to this application or library. It may also be used inside
@@ -399,7 +451,7 @@ function count()
399451
}
400452
```
401453

402-
### 5.6. @link
454+
### 5.7. @link
403455

404456
The @link tag indicates a custom relation between the associated
405457
"Structural Element" and a website, which is identified by an absolute URI.
@@ -449,7 +501,7 @@ function count()
449501
}
450502
```
451503

452-
### 5.7. @method
504+
### 5.8. @method
453505

454506
The @method allows a class to know which 'magic' methods are callable.
455507

@@ -499,7 +551,7 @@ class Child extends Parent
499551
}
500552
```
501553

502-
### 5.8. @package
554+
### 5.9. @package
503555

504556
The @package tag is used to categorize "Structural Elements" into logical
505557
subdivisions.
@@ -536,7 +588,7 @@ This tag MUST NOT occur more than once in a "DocBlock".
536588
*/
537589
```
538590

539-
### 5.9. @param
591+
### 5.10. @param
540592

541593
The @param tag is used to document a single parameter of a function or method.
542594

@@ -577,7 +629,7 @@ function count(array $items)
577629
}
578630
```
579631

580-
### 5.10. @property
632+
### 5.11. @property
581633

582634
The `@property` tag is used to declare which "magic" properties are supported.
583635

@@ -626,7 +678,7 @@ class User
626678
}
627679
```
628680

629-
### 5.11. @return
681+
### 5.12. @return
630682

631683
The @return tag is used to document the return value of functions or methods.
632684

@@ -675,7 +727,7 @@ function getLabel()
675727
}
676728
```
677729

678-
### 5.12. @see
730+
### 5.13. @see
679731

680732
The @see tag indicates a reference from the associated "Structural Elements" to
681733
a website or other "Structural Elements".
@@ -717,7 +769,7 @@ function count()
717769
}
718770
```
719771

720-
### 5.13. @since
772+
### 5.14. @since
721773

722774
The @since tag is used to denote _when_ an element was introduced or modified,
723775
using some description of "versioning" to that element.
@@ -767,7 +819,7 @@ class Foo
767819
}
768820
```
769821

770-
### 5.14. @throws
822+
### 5.15. @throws
771823

772824
The @throws tag is used to indicate whether "Structural Elements" throw a
773825
specific type of Throwable (exception or error).
@@ -810,7 +862,7 @@ function count($items)
810862
}
811863
```
812864

813-
### 5.15. @todo
865+
### 5.16. @todo
814866

815867
The @todo tag is used to indicate whether any development activities should
816868
still be executed on associated "Structural Elements".
@@ -842,7 +894,7 @@ function count()
842894
}
843895
```
844896

845-
### 5.16. @uses
897+
### 5.17. @uses
846898

847899
Indicates whether the current "Structural Element" consumes the
848900
"Structural Element", or project file, that is provided as target.
@@ -895,7 +947,7 @@ function executeMyView()
895947
}
896948
```
897949

898-
### 5.17. @var
950+
### 5.18. @var
899951

900952
You may use the @var tag to document the "Type" of the following
901953
"Structural Elements":
@@ -999,7 +1051,7 @@ class Foo
9991051
}
10001052
```
10011053

1002-
### 5.18. @version
1054+
### 5.19. @version
10031055

10041056
The @version tag is used to denote some description of "versioning" to an
10051057
element.

0 commit comments

Comments
 (0)