File tree Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -208,6 +208,10 @@ public function enterNode(Node $node)
208
208
}
209
209
};
210
210
211
+ if ($ this ->statements ) {
212
+ $ this ->addCommentAndAttributes ($ phpFile , $ this ->statements [0 ]);
213
+ }
214
+
211
215
$ traverser = new PhpParser \NodeTraverser ;
212
216
$ traverser ->addVisitor ($ visitor );
213
217
$ traverser ->traverse ($ this ->statements );
@@ -367,6 +371,7 @@ private function addCommentAndAttributes($element, Node $node): void
367
371
$ comment = $ node ->getDocComment ()->getReformattedText ();
368
372
$ comment = Helpers::unformatDocComment ($ comment );
369
373
$ element ->setComment ($ comment );
374
+ $ node ->setDocComment (new PhpParser \Comment \Doc ('' ));
370
375
}
371
376
372
377
foreach ($ node ->attrGroups ?? [] as $ group ) {
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
+ /**
4
+ * First comment
5
+ */
6
+
3
7
declare(strict_types=1);
4
8
5
9
namespace Abc;
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
+ /**
4
+ * First comment
5
+ */
6
+
3
7
declare (strict_types=1 );
4
8
9
+ /**
10
+ * Second comment
11
+ */
12
+
5
13
namespace Abc ;
6
14
7
15
/**
You can’t perform that action at this time.
0 commit comments