mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-25 04:03:55 +01:00
cleanup
This commit is contained in:
parent
2443d6b1cb
commit
58a826bc6e
@ -24,24 +24,24 @@ final class BetterStandardPrinter extends Standard
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not add () on Expressions
|
||||
* Do not add "()" on Expressions
|
||||
* @see https://github.com/rectorphp/rector/pull/401#discussion_r181487199
|
||||
*/
|
||||
protected function pExpr_Yield(Yield_ $yieldNode)
|
||||
protected function pExpr_Yield(Yield_ $yieldNode): string
|
||||
{
|
||||
if ($yieldNode->value === null) {
|
||||
return 'yield';
|
||||
} else {
|
||||
$parentNode = $yieldNode->getAttribute(Attribute::PARENT_NODE);
|
||||
$yieldContent = 'yield '
|
||||
. ($yieldNode->key !== null ? $this->p($yieldNode->key) . ' => ' : '')
|
||||
. $this->p($yieldNode->value);
|
||||
|
||||
if (! $parentNode instanceof Expression) {
|
||||
return $yieldContent;
|
||||
}
|
||||
|
||||
return '(' . $yieldContent . ')';
|
||||
}
|
||||
|
||||
$parentNode = $yieldNode->getAttribute(Attribute::PARENT_NODE);
|
||||
$shouldAddBrackets = $parentNode instanceof Expression;
|
||||
|
||||
return sprintf(
|
||||
'%syield %s%s%s',
|
||||
$shouldAddBrackets ? '(' : '',
|
||||
$yieldNode->key !== null ? $this->p($yieldNode->key) . ' => ' : '',
|
||||
$this->p($yieldNode->value),
|
||||
$shouldAddBrackets ? ')' : ''
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user