mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-30 04:29:15 +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);
|
||||
|
||||
/** @var Node $delayedAddNode */
|
||||
foreach ($delayedAdd as list($delayedAddNode, $delayedAddInsertStr)) {
|
||||
if ($delayedAddInsertStr === "\n") {
|
||||
foreach ($delayedAdd as $delayedAddNode) {
|
||||
if ($insertStr === "\n") {
|
||||
$delayedAddComments = $delayedAddNode->getComments();
|
||||
if ($delayedAddComments) {
|
||||
$result .= $this->pComments($delayedAddComments) . $this->nl;
|
||||
@ -778,10 +778,10 @@ abstract class PrettyPrinterAbstract
|
||||
|
||||
$this->safeAppend($result, $this->p($delayedAddNode, true));
|
||||
|
||||
if ($delayedAddInsertStr === "\n") {
|
||||
if ($insertStr === "\n") {
|
||||
$result .= $this->nl;
|
||||
} else {
|
||||
$result .= $delayedAddInsertStr;
|
||||
$result .= $insertStr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -805,8 +805,8 @@ abstract class PrettyPrinterAbstract
|
||||
}
|
||||
|
||||
if ($beforeFirstKeepOrReplace) {
|
||||
// These will be inserted at the next "replace" or "keep" element
|
||||
$delayedAdd[] = [$arrItem, $insertStr];
|
||||
// Will be inserted at the next "replace" or "keep" element
|
||||
$delayedAdd[] = $arrItem;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user