FluentReplaceRector: simplify inner return call

This commit is contained in:
TomasVotruba 2018-01-17 09:30:21 +01:00
parent c58d0c1414
commit b84bc6d120

View File

@ -41,6 +41,7 @@ final class FluentReplaceRector extends AbstractRector
public function isCandidate(Node $node): bool public function isCandidate(Node $node): bool
{ {
// @todo this run has to be first, dual run?
if ($node instanceof Return_) { if ($node instanceof Return_) {
if (! $node->expr instanceof Variable) { if (! $node->expr instanceof Variable) {
return false; return false;
@ -76,17 +77,8 @@ final class FluentReplaceRector extends AbstractRector
// method call to prepend // method call to prepend
$this->decoupleMethodCall($node); $this->decoupleMethodCall($node);
/** @var MethodCall $previousMethodNodeCall */ /** @var MethodCall $node->var */
$previousMethodNodeCall = $node->var; return $node->var;
// move method call one up
$node->name = $previousMethodNodeCall->name;
$node->var = $previousMethodNodeCall->var;
// to clear indent
$node->setAttribute(Attribute::ORIGINAL_NODE, null);
return $node;
} }
return $node; return $node;