@@ -664,17 +664,33 @@ public function enterNode(Node $node)
664664
665665 };
666666
667- $ addItemsToMultilineArrayShape = new class extends AbstractNodeVisitor {
667+ $ addSingleLineCommentsToMultilineArrayShape = new class extends AbstractNodeVisitor {
668668
669669 public function enterNode (Node $ node )
670670 {
671671 if ($ node instanceof ArrayShapeNode) {
672- $ commentedNode = new ArrayShapeItemNode (new IdentifierTypeNode ('c ' ), false , new IdentifierTypeNode ('int ' ));
672+ $ commentedNode = new ArrayShapeItemNode (new IdentifierTypeNode ('b ' ), false , new IdentifierTypeNode ('int ' ));
673673 $ commentedNode ->setAttribute (Attribute::COMMENTS , [new Comment ('// bar ' )]);
674674 array_splice ($ node ->items , 1 , 0 , [
675675 $ commentedNode ,
676676 ]);
677- $ node ->items [] = new ArrayShapeItemNode (new IdentifierTypeNode ('d ' ), false , new IdentifierTypeNode ('string ' ));
677+ $ commentedNode = new ArrayShapeItemNode (new IdentifierTypeNode ('d ' ), false , new IdentifierTypeNode ('string ' ));
678+ $ commentedNode ->setAttribute (Attribute::COMMENTS , [new Comment (
679+ '/* This is a
680+ multiline
681+ comment
682+ */ '
683+ )]);
684+ $ node ->items [] = $ commentedNode ;
685+
686+ $ commentedNode = new ArrayShapeItemNode (new IdentifierTypeNode ('e ' ), false , new IdentifierTypeNode ('string ' ));
687+ $ commentedNode ->setAttribute (Attribute::COMMENTS , [new Comment (
688+ '/* Another
689+ * multiline
690+ * comment with leading asterisks
691+ */ '
692+ )]);
693+ $ node ->items [] = $ commentedNode ;
678694 }
679695
680696 return $ node ;
@@ -687,22 +703,32 @@ public function enterNode(Node $node)
687703 * @return array{
688704 * // foo
689705 * a: int,
690- * b : string
706+ * c : string
691707 * }
692708 */ ' ,
693709 '/**
694710 * @return array{
695711 * // foo
696712 * a: int,
697713 * // bar
698- * c: int,
699- * b: string,
700- * d: string
714+ * b: int,
715+ * c: string,
716+ * /* This is a
717+ * multiline
718+ * comment
719+ * */
720+ * d: string,
721+ * /* Another
722+ * * multiline
723+ * * comment with leading asterisks
724+ * */
725+ * e: string
701726 * }
702727 */ ' ,
703- $ addItemsToMultilineArrayShape ,
728+ $ addSingleLineCommentsToMultilineArrayShape ,
704729 ];
705730
731+
706732 yield [
707733 '/**
708734 * @return array{float}
0 commit comments