@@ -50,40 +50,42 @@ var_dump($result);
5050** Expected Output:**
5151
5252``` 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"
6162 }
62- #name: "see"
63+ +name: "see"
64+ }
65+ 2 => TypeLang\PHPDoc\DocBlock\Description\Description {
66+ #value: " and blah-blah-blah.\n"
6367 }
6468 ]
69+ +tags: array:1 [
70+ 0 => TypeLang\PHPDoc\DocBlock\Tag\Tag {}
71+ ]
6572 }
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"
7177 }
72- # name: "Example\Annotation"
78+ + name: "Example\Annotation"
7379 }
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 { ... }
8084 }
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 { ... }
8789 }
8890 ]
8991}
@@ -104,17 +106,21 @@ DocBlock is a representation of the comment object.
104106 */ |
105107```
106108
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.
109111
110112``` 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
113120{
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; }
118124}
119125```
120126
@@ -131,17 +137,29 @@ other tags.
131137 */
132138```
133139
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.
136142
137143``` 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 {}
142148
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; }
145163}
146164```
147165
@@ -157,14 +175,25 @@ A Tag represents a name (ID) and its contents.
157175 */
158176```
159177
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.
162180
163181``` php
182+ /**
183+ * Common tag structure pseudocode (real impl may differ)
184+ */
164185class Tag implements \Stringable
165186{
166- public function getName(): string;
187+ public non-empty-string $name { get; }
167188
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;
169198}
170199```
0 commit comments