Skip to content

Commit e322dc9

Browse files
committed
Updated Rector to commit d98976ca59bbe6b5e5252bb90994dfaa05ec3b08
rectorphp/rector-src@d98976c tidy up just changed arrow function comments, move above full arrow function, as standard (#7739)
1 parent e8620a3 commit e322dc9

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

src/Application/VersionResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class VersionResolver
1919
* @api
2020
* @var string
2121
*/
22-
public const PACKAGE_VERSION = '88d58c1141c1a75b7b73816f68e5c9c17a485998';
22+
public const PACKAGE_VERSION = 'd98976ca59bbe6b5e5252bb90994dfaa05ec3b08';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2025-12-08 21:38:21';
27+
public const RELEASE_DATE = '2025-12-08 22:19:13';
2828
/**
2929
* @var int
3030
*/

src/PhpParser/Printer/BetterStandardPrinter.php

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use PhpParser\Node\Expr\MethodCall;
2121
use PhpParser\Node\Expr\Ternary;
2222
use PhpParser\Node\Expr\Yield_;
23-
use PhpParser\Node\InterpolatedStringPart;
2423
use PhpParser\Node\Scalar\InterpolatedString;
2524
use PhpParser\Node\Scalar\String_;
2625
use PhpParser\Node\Stmt\Declare_;
@@ -107,22 +106,14 @@ public function pFileWithoutNamespace(FileWithoutNamespace $fileWithoutNamespace
107106
{
108107
return $this->pStmts($fileWithoutNamespace->stmts);
109108
}
110-
/**
111-
* @api magic method in parent
112-
*/
113-
public function pInterpolatedStringPart(InterpolatedStringPart $interpolatedStringPart): string
114-
{
115-
return $interpolatedStringPart->value;
116-
}
117109
protected function p(Node $node, int $precedence = self::MAX_PRECEDENCE, int $lhsPrecedence = self::MAX_PRECEDENCE, bool $parentFormatPreserved = \false): string
118110
{
119111
// handle already AlwaysRememberedExpr
120112
// @see https://github.com/rectorphp/rector/issues/8815#issuecomment-2503453191
121-
while ($node instanceof AlwaysRememberedExpr) {
122-
$node = $node->getExpr();
113+
if ($node instanceof AlwaysRememberedExpr) {
114+
return $this->p($node->getExpr(), $precedence, $lhsPrecedence, $parentFormatPreserved);
123115
}
124-
// handle overlapped origNode is Match_
125-
// and its subnodes still have AlwaysRememberedExpr
116+
// handle overlapped origNode is Match_ and its subnodes still have AlwaysRememberedExpr
126117
$originalNode = $node->getAttribute(AttributeKey::ORIGINAL_NODE);
127118
if ($originalNode instanceof Match_) {
128119
$subNodeNames = $node->getSubNodeNames();
@@ -132,12 +123,16 @@ protected function p(Node $node, int $precedence = self::MAX_PRECEDENCE, int $lh
132123
}
133124
}
134125
}
135-
$this->wrapBinaryOp($node);
126+
$this->wrapBinaryOpWithBrackets($node);
136127
$content = parent::p($node, $precedence, $lhsPrecedence, $parentFormatPreserved);
128+
// remove once its fixed in php-parser, https://github.com/nikic/PHP-Parser/pull/1126
137129
if ($node instanceof CallLike) {
138130
$this->cleanVariadicPlaceHolderTrailingComma($node);
139131
}
140-
return $node->getAttribute(AttributeKey::WRAPPED_IN_PARENTHESES) === \true ? '(' . $content . ')' : $content;
132+
if ($node->getAttribute(AttributeKey::WRAPPED_IN_PARENTHESES)) {
133+
return '(' . $content . ')';
134+
}
135+
return $content;
141136
}
142137
protected function pExpr_ArrowFunction(ArrowFunction $arrowFunction, int $precedence, int $lhsPrecedence): string
143138
{
@@ -156,7 +151,7 @@ protected function pExpr_ArrowFunction(ArrowFunction $arrowFunction, int $preced
156151
$commentText = $key > 0 ? $indent . $comment->getText() : $comment->getText();
157152
$text .= $commentText . "\n";
158153
}
159-
return $this->pPrefixOp(ArrowFunction::class, $this->pAttrGroups($arrowFunction->attrGroups, \true) . $this->pStatic($arrowFunction->static) . 'fn' . ($arrowFunction->byRef ? '&' : '') . '(' . $this->pMaybeMultiline($arrowFunction->params, $this->phpVersion->supportsTrailingCommaInParamList()) . ')' . ($arrowFunction->returnType instanceof Node ? ': ' . $this->p($arrowFunction->returnType) : '') . ' =>' . $text . $indent, $arrowFunction->expr, $precedence, $lhsPrecedence);
154+
return $text . "\n" . $indent . parent::pExpr_ArrowFunction($arrowFunction, $precedence, $lhsPrecedence);
160155
}
161156
/**
162157
* This allows to use both spaces and tabs vs. original space-only
@@ -347,7 +342,7 @@ private function cleanVariadicPlaceHolderTrailingComma(CallLike $callLike): void
347342
break;
348343
}
349344
}
350-
private function wrapBinaryOp(Node $node): void
345+
private function wrapBinaryOpWithBrackets(Node $node): void
351346
{
352347
if ($this->exprAnalyzer->isExprWithExprPropertyWrappable($node)) {
353348
$node->expr->setAttribute(AttributeKey::ORIGINAL_NODE, null);

0 commit comments

Comments
 (0)