Skip to content

Commit 44f36e7

Browse files
committed
remove addComments
1 parent 0459d2e commit 44f36e7

File tree

3 files changed

+2
-15
lines changed

3 files changed

+2
-15
lines changed

src/Ast/Node.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,4 @@ public function hasAttribute(string $key): bool;
1919
*/
2020
public function getAttribute(string $key);
2121

22-
/**
23-
* @return array<Comment>
24-
*/
25-
public function getComments(): array;
26-
2722
}

src/Ast/NodeAttributes.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,4 @@ public function getAttribute(string $key)
3535
return null;
3636
}
3737

38-
/**
39-
* @return array<Comment>
40-
*/
41-
public function getComments(): array
42-
{
43-
return $this->attributes[Attribute::COMMENTS] ?? [];
44-
}
45-
4638
}

src/Printer/Printer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ private function printArrayFormatPreserving(array $nodes, array $originalNodes,
584584
return null;
585585
}
586586

587-
if ($insertStr === ', ' && $isMultiline || count($arrItem->getComments()) > 0) {
587+
if ($insertStr === ', ' && $isMultiline || count($arrItem->getAttribute(Attribute::COMMENTS) ?? []) > 0) {
588588
$insertStr = ',';
589589
$insertNewline = true;
590590
}
@@ -597,7 +597,7 @@ private function printArrayFormatPreserving(array $nodes, array $originalNodes,
597597

598598
$itemEndPos = $tokenIndex - 1;
599599
if ($insertNewline) {
600-
$comments = $arrItem->getComments();
600+
$comments = $arrItem->getAttribute(Attribute::COMMENTS) ?? [];
601601
$result .= $insertStr;
602602
if (count($comments) > 0) {
603603
$result .= sprintf('%s%s*%s', $originalTokens->getDetectedNewline() ?? "\n", $beforeAsteriskIndent, $afterAsteriskIndent);

0 commit comments

Comments
 (0)