Skip to content

Commit b6d0601

Browse files
committed
fix order
1 parent fb9e061 commit b6d0601

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/Ast/NodeAttributes.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ public function hasAttribute(string $key): bool
2323
return array_key_exists($key, $this->attributes);
2424
}
2525

26+
/**
27+
* @return list<Comment>
28+
*/
29+
public function getComments(): array {
30+
return $this->getAttribute(Attribute::COMMENTS) ?? [];
31+
}
32+
2633
/**
2734
* @return mixed
2835
*/

src/Parser/TypeParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function enrichWithAttributes(TokenIterator $tokens, Ast\Node $type, int
112112
public function appendComments(Ast\Node $type, array $comments = []): Ast\Node
113113
{
114114
if ($this->useCommentsAttributes) {
115-
$type->setAttribute(Ast\Attribute::COMMENTS, array_merge($comments, $type->getAttribute(Ast\Attribute::COMMENTS) ?? []));
115+
$type->setAttribute(Ast\Attribute::COMMENTS, array_merge($type->getAttribute(Ast\Attribute::COMMENTS) ?? [], $comments));
116116
}
117117

118118
return $type;

src/Printer/Printer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,11 @@ private function printArrayFormatPreserving(array $nodes, array $originalNodes,
536536

537537
$result .= $originalTokens->getContentBetween($tokenIndex, $itemStartPos);
538538

539+
$comments = $newNode->getComments();
540+
if($comments) {
541+
xdebug_break();
542+
}
543+
539544
if (count($delayedAdd) > 0) {
540545
foreach ($delayedAdd as $delayedAddNode) {
541546
$parenthesesNeeded = isset($this->parenthesesListMap[$mapKey])

0 commit comments

Comments
 (0)