Skip to content

Commit

Permalink
[Printer] Reduce call on BetterStandardPrinter (#6713)
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik authored Feb 2, 2025
1 parent 49e323a commit 8f5ac73
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/PhpParser/Printer/BetterStandardPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,26 +402,26 @@ protected function pScalar_Int(Int_ $int): string

protected function pExpr_MethodCall(MethodCall $methodCall): string
{
if (SimpleParameterProvider::provideBoolParameter(Option::NEW_LINE_ON_FLUENT_CALL) === false) {
if (! $methodCall->var instanceof CallLike) {
return parent::pExpr_MethodCall($methodCall);
}

if ($methodCall->var instanceof CallLike) {
foreach ($methodCall->args as $arg) {
if (! $arg instanceof Arg) {
continue;
}
if (SimpleParameterProvider::provideBoolParameter(Option::NEW_LINE_ON_FLUENT_CALL) === false) {
return parent::pExpr_MethodCall($methodCall);
}

$arg->value->setAttribute(AttributeKey::ORIGINAL_NODE, null);
foreach ($methodCall->args as $arg) {
if (! $arg instanceof Arg) {
continue;
}

return $this->pDereferenceLhs(
$methodCall->var
) . "\n" . $this->resolveIndentSpaces() . '->' . $this->pObjectProperty($methodCall->name)
. '(' . $this->pMaybeMultiline($methodCall->args) . ')';
$arg->value->setAttribute(AttributeKey::ORIGINAL_NODE, null);
}

return parent::pExpr_MethodCall($methodCall);
return $this->pDereferenceLhs($methodCall->var) . "\n"
. $this->resolveIndentSpaces() . '->'
. $this->pObjectProperty($methodCall->name)
. '(' . $this->pMaybeMultiline($methodCall->args) . ')';
}

/**
Expand Down

0 comments on commit 8f5ac73

Please sign in to comment.