@@ -50,40 +50,42 @@ var_dump($result);
50
50
** Expected Output:**
51
51
52
52
``` php
53
- TypeLang\PHPDoc\DocBlock {
54
- -description: TypeLang\PHPDoc\DocBlock\Description\Description {
55
- -template: "Example description %1$s and blah-blah-blah."
56
- -tags: array:1 [
57
- 0 => TypeLang\PHPDoc\DocBlock\Tag {
58
- #description: TypeLang\PHPDoc\Tag\Description\Description {
59
- -template: "some"
60
- -tags: []
53
+ TypeLang\PHPDoc\DocBlock\DocBlock {
54
+ +description: TypeLang\PHPDoc\DocBlock\Description\TaggedDescription {
55
+ +components: array:3 [
56
+ 0 => TypeLang\PHPDoc\DocBlock\Description\Description {
57
+ #value: "Example description "
58
+ }
59
+ 1 => TypeLang\PHPDoc\DocBlock\Tag\Tag {
60
+ +description: TypeLang\PHPDoc\DocBlock\Description\Description {
61
+ #value: "some"
61
62
}
62
- #name: "see"
63
+ +name: "see"
64
+ }
65
+ 2 => TypeLang\PHPDoc\DocBlock\Description\Description {
66
+ #value: " and blah-blah-blah.\n"
63
67
}
64
68
]
69
+ +tags: array:1 [
70
+ 0 => TypeLang\PHPDoc\DocBlock\Tag\Tag {}
71
+ ]
65
72
}
66
- -tags: array:3 [
67
- 0 => TypeLang\PHPDoc\DocBlock\Tag {
68
- #description: TypeLang\PHPDoc\Tag\Description\Description {
69
- -template: "("foo")"
70
- -tags: []
73
+ +tags: array:3 [
74
+ 0 => TypeLang\PHPDoc\DocBlock\Tag\Tag {
75
+ +description: TypeLang\PHPDoc\DocBlock\Description\Description {
76
+ #value: "("foo")\n"
71
77
}
72
- # name: "Example\Annotation"
78
+ + name: "Example\Annotation"
73
79
}
74
- 1 => TypeLang\PHPDoc\DocBlock\Tag {
75
- #description: TypeLang\PHPDoc\Tag\Description\Description {
76
- -template: "array<non-empty-string , TypeStatement >"
77
- -tags: []
78
- }
79
- #name: "return"
80
+ 1 => TypeLang\PHPDoc\DocBlock\Tag\ReturnTag\ReturnTag {
81
+ +description: null
82
+ +name: "return"
83
+ +type: TypeLang\Parser\Node\Stmt\NamedTypeNode { ... }
80
84
}
81
- 2 => TypeLang\PHPDoc\DocBlock\Tag {
82
- #description: TypeLang\PHPDoc\Tag\Description\Description {
83
- -template: "\Throwable"
84
- -tags: []
85
- }
86
- #name: "throws"
85
+ 2 => TypeLang\PHPDoc\DocBlock\Tag\ThrowsTag\ThrowsTag {
86
+ +description: null
87
+ +name: "throws"
88
+ +type: TypeLang\Parser\Node\Stmt\NamedTypeNode { ... }
87
89
}
88
90
]
89
91
}
@@ -104,17 +106,21 @@ DocBlock is a representation of the comment object.
104
106
*/ |
105
107
```
106
108
107
- - ` getDescription() ` ― Provides a ` Description ` object.
108
- - ` getTags() ` ― Provides a list of ` Tag ` objects.
109
+ - ` $description ` ― Provides a ` Description ` object.
110
+ - ` $tags ` ― Provides a list of ` Tag ` objects.
109
111
110
112
``` php
111
- /** @template-implements \Traversable<array-key , Tag > */
112
- class DocBlock implements \Traversable
113
+ /**
114
+ * DocBlock structure pseudocode (real impl may differ)
115
+ *
116
+ * @template-implements \Traversable<array-key , Tag >
117
+ * @template-implements \ArrayAccess<array-key , Tag >
118
+ */
119
+ class DocBlock
113
120
{
114
- public function getDescription(): Description;
115
-
116
- /** @return list<Tag > */
117
- public function getTags(): array;
121
+ public ?Description $description { get; }
122
+
123
+ public iterable<array-key , Tag > $tags { get; }
118
124
}
119
125
```
120
126
@@ -131,17 +137,29 @@ other tags.
131
137
*/
132
138
```
133
139
134
- - ` getTemplate() ` ― Provides a sprintf-formatted template string of the description .
135
- - ` getTags() ` ― Provides a list of ` Tag ` objects.
140
+ - ` $tags ` ― Provides a list of ` Tag ` objects .
141
+ - ` $components ` ― Provides a list of ` Tag|Description ` objects.
136
142
137
143
``` php
138
- /** @template-implements \Traversable< array-key , Tag > */
139
- class Description implements \Traversable, \Stringable
140
- {
141
- public function getTemplate(): string;
144
+ /**
145
+ * Simple description structure pseudocode (real impl may differ)
146
+ */
147
+ class Description implements \Stringable {}
142
148
143
- /** @return list<Tag > */
144
- public function getTags(): array;
149
+ /**
150
+ * Tagged (composite) description structure pseudocode (real impl may differ)
151
+ *
152
+ * @template-implements \Traversable<array-key , Tag >
153
+ * @template-implements \ArrayAccess<array-key , Tag >
154
+ */
155
+ class TaggedDescription extends Description implements
156
+ \Traversable,
157
+ \ArrayAccess,
158
+ \Countable
159
+ {
160
+ public iterable<array-key , Tag > $tags { get; }
161
+
162
+ public iterable<array-key , Tag|Description > $components { get; }
145
163
}
146
164
```
147
165
@@ -157,14 +175,25 @@ A Tag represents a name (ID) and its contents.
157
175
*/
158
176
```
159
177
160
- - ` getName() ` ― Provides a tag's name (ID).
161
- - ` getDescription() ` ― Provides an optional description of the tag.
178
+ - ` $name ` ― Provides a tag's name (ID).
179
+ - ` $description ` ― Provides an optional description of the tag.
162
180
163
181
``` php
182
+ /**
183
+ * Common tag structure pseudocode (real impl may differ)
184
+ */
164
185
class Tag implements \Stringable
165
186
{
166
- public function getName(): string;
187
+ public non-empty-string $name { get; }
167
188
168
- public function getDescription(): ?Description;
189
+ public ?Description $description { get; }
190
+ }
191
+
192
+ /**
193
+ * Throws tag structure pseudocode (real impl may differ)
194
+ */
195
+ class ThrowsTag extends Tag
196
+ {
197
+ public TypeStatement $type;
169
198
}
170
199
```
0 commit comments