11
11
12
12
class FileVisitor extends NodeVisitorAbstract
13
13
{
14
- /** @var ClassDescriptionBuilder */
15
- private $ classDescriptionBuilder ;
14
+ private ClassDescriptionBuilder $ classDescriptionBuilder ;
16
15
17
- /** @var array */
18
- private $ classDescriptions = [];
16
+ /** @var array<ClassDescription> */
17
+ private array $ classDescriptions = [];
19
18
20
19
public function __construct (ClassDescriptionBuilder $ classDescriptionBuilder )
21
20
{
@@ -50,13 +49,6 @@ public function enterNode(Node $node): void
50
49
if ($ node ->isAbstract ()) {
51
50
$ this ->classDescriptionBuilder ->setAbstract (true );
52
51
}
53
-
54
- foreach ($ node ->attrGroups as $ attributeGroup ) {
55
- foreach ($ attributeGroup ->attrs as $ attribute ) {
56
- $ this ->classDescriptionBuilder
57
- ->addAttribute ($ attribute ->name ->toString (), $ attribute ->getLine ());
58
- }
59
- }
60
52
}
61
53
62
54
if ($ node instanceof Node \Stmt \Enum_ && null !== $ node ->namespacedName ) {
@@ -67,13 +59,6 @@ public function enterNode(Node $node): void
67
59
$ this ->classDescriptionBuilder
68
60
->addInterface ($ interface ->toString (), $ interface ->getLine ());
69
61
}
70
-
71
- foreach ($ node ->attrGroups as $ attributeGroup ) {
72
- foreach ($ attributeGroup ->attrs as $ attribute ) {
73
- $ this ->classDescriptionBuilder
74
- ->addAttribute ($ attribute ->name ->toString (), $ attribute ->getLine ());
75
- }
76
- }
77
62
}
78
63
79
64
/**
@@ -197,13 +182,6 @@ public function enterNode(Node $node): void
197
182
198
183
$ this ->classDescriptionBuilder ->setClassName ($ node ->namespacedName ->toCodeString ());
199
184
$ this ->classDescriptionBuilder ->setInterface (true );
200
-
201
- foreach ($ node ->attrGroups as $ attributeGroup ) {
202
- foreach ($ attributeGroup ->attrs as $ attribute ) {
203
- $ this ->classDescriptionBuilder
204
- ->addAttribute ($ attribute ->name ->toString (), $ attribute ->getLine ());
205
- }
206
- }
207
185
}
208
186
209
187
if ($ node instanceof Node \Stmt \Trait_) {
@@ -213,13 +191,6 @@ public function enterNode(Node $node): void
213
191
214
192
$ this ->classDescriptionBuilder ->setClassName ($ node ->namespacedName ->toCodeString ());
215
193
$ this ->classDescriptionBuilder ->setTrait (true );
216
-
217
- foreach ($ node ->attrGroups as $ attributeGroup ) {
218
- foreach ($ attributeGroup ->attrs as $ attribute ) {
219
- $ this ->classDescriptionBuilder
220
- ->addAttribute ($ attribute ->name ->toString (), $ attribute ->getLine ());
221
- }
222
- }
223
194
}
224
195
225
196
if ($ node instanceof Node \Stmt \ClassMethod) {
@@ -229,6 +200,15 @@ public function enterNode(Node $node): void
229
200
->addDependency (new ClassDependency ($ returnType ->toString (), $ returnType ->getLine ()));
230
201
}
231
202
}
203
+
204
+ if ($ node instanceof Node \Attribute) {
205
+ $ nodeName = $ node ->name ;
206
+
207
+ if ($ nodeName instanceof Node \Name \FullyQualified) {
208
+ $ this ->classDescriptionBuilder
209
+ ->addAttribute ($ node ->name ->toString (), $ node ->getLine ());
210
+ }
211
+ }
232
212
}
233
213
234
214
public function getClassDescriptions (): array
0 commit comments