File tree Expand file tree Collapse file tree 2 files changed +48
-1
lines changed Expand file tree Collapse file tree 2 files changed +48
-1
lines changed Original file line number Diff line number Diff line change @@ -209,7 +209,11 @@ public function enterNode(Node $node)
209
209
}
210
210
};
211
211
212
- if ($ this ->statements ) {
212
+ if (
213
+ $ this ->statements
214
+ && !$ this ->statements [0 ] instanceof Node \Stmt \ClassLike
215
+ && !$ this ->statements [0 ] instanceof Node \Stmt \Function_
216
+ ) {
213
217
$ this ->addCommentAndAttributes ($ phpFile , $ this ->statements [0 ]);
214
218
}
215
219
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ use Nette \PhpGenerator \Extractor ;
6
+ use Tester \Assert ;
7
+ require __DIR__ . '/../bootstrap.php ' ;
8
+
9
+
10
+ $ file = (new Extractor (<<<'XX'
11
+ <?php
12
+
13
+ /** doc comment */
14
+ class Class1
15
+ {
16
+ }
17
+
18
+ XX))->extractAll ();
19
+
20
+ Assert::null ($ file ->getComment ());
21
+ Assert::same ('doc comment ' , $ file ->getClasses ()['Class1 ' ]->getComment ());
22
+
23
+
24
+ $ file = (new Extractor (<<<'XX'
25
+ <?php
26
+
27
+ /** doc comment */
28
+
29
+ namespace Abc;
30
+ XX))->extractAll ();
31
+
32
+ Assert::same ('doc comment ' , $ file ->getComment ());
33
+
34
+
35
+ $ file = (new Extractor (<<<'XX'
36
+ <?php
37
+
38
+ #[ExampleAttribute]
39
+
40
+ function () {};
41
+ XX))->extractAll ();
42
+
43
+ Assert::null ($ file ->getComment ());
You can’t perform that action at this time.
0 commit comments