mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-27 04:24:43 +01:00
Simplify delayed add code
$insertStr always stays the same, so no reason to store it separately.
This commit is contained in:
parent
63abf9cb3f
commit
fb8175567e
@ -768,8 +768,8 @@ abstract class PrettyPrinterAbstract
|
|||||||
$pos, $commentStartPos, $indentAdjustment);
|
$pos, $commentStartPos, $indentAdjustment);
|
||||||
|
|
||||||
/** @var Node $delayedAddNode */
|
/** @var Node $delayedAddNode */
|
||||||
foreach ($delayedAdd as list($delayedAddNode, $delayedAddInsertStr)) {
|
foreach ($delayedAdd as $delayedAddNode) {
|
||||||
if ($delayedAddInsertStr === "\n") {
|
if ($insertStr === "\n") {
|
||||||
$delayedAddComments = $delayedAddNode->getComments();
|
$delayedAddComments = $delayedAddNode->getComments();
|
||||||
if ($delayedAddComments) {
|
if ($delayedAddComments) {
|
||||||
$result .= $this->pComments($delayedAddComments) . $this->nl;
|
$result .= $this->pComments($delayedAddComments) . $this->nl;
|
||||||
@ -778,10 +778,10 @@ abstract class PrettyPrinterAbstract
|
|||||||
|
|
||||||
$this->safeAppend($result, $this->p($delayedAddNode, true));
|
$this->safeAppend($result, $this->p($delayedAddNode, true));
|
||||||
|
|
||||||
if ($delayedAddInsertStr === "\n") {
|
if ($insertStr === "\n") {
|
||||||
$result .= $this->nl;
|
$result .= $this->nl;
|
||||||
} else {
|
} else {
|
||||||
$result .= $delayedAddInsertStr;
|
$result .= $insertStr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -805,8 +805,8 @@ abstract class PrettyPrinterAbstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($beforeFirstKeepOrReplace) {
|
if ($beforeFirstKeepOrReplace) {
|
||||||
// These will be inserted at the next "replace" or "keep" element
|
// Will be inserted at the next "replace" or "keep" element
|
||||||
$delayedAdd[] = [$arrItem, $insertStr];
|
$delayedAdd[] = $arrItem;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user