Skip to content

Commit

Permalink
Updated Rector to commit b491f42c2acd125671c7908a3dacd86316048809
Browse files Browse the repository at this point in the history
rectorphp/rector-src@b491f42 [Php80] Remove unnecessary re-create default value param from ConstFetch on AddParamBasedOnParentClassMethodRector, set origNode = null instead (#5112)
  • Loading branch information
TomasVotruba committed Oct 4, 2023
1 parent dfbbc51 commit 489d95e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,10 @@
use PhpParser\Node;
use PhpParser\Node\ComplexType;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\ConstFetch;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
use PhpParser\Node\Param;
use PhpParser\Node\Scalar\DNumber;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\ClassMethod;
use PHPStan\Reflection\MethodReflection;
use Rector\Core\PhpParser\AstResolver;
Expand Down Expand Up @@ -204,21 +199,13 @@ private function processReplaceClassMethodParams(ClassMethod $node, ClassMethod
}
private function resolveParamDefault(Expr $expr) : Expr
{
// re-create to avoid TokenStream error
if ($expr instanceof String_) {
return new String_($expr->value, [AttributeKey::KIND => $expr->getAttribute(AttributeKey::KIND)]);
}
if ($expr instanceof LNumber) {
return new LNumber($expr->value);
}
if ($expr instanceof DNumber) {
return new DNumber($expr->value);
}
if ($expr instanceof Array_ && $expr->items === []) {
return new Array_($expr->items, [AttributeKey::KIND => $expr->getAttribute(AttributeKey::KIND)]);
}
$printParamDefault = $this->betterStandardPrinter->print($expr);
return new ConstFetch(new Name($printParamDefault));
// reset original node, to allow the printer to re-use the expr
$expr->setAttribute(AttributeKey::ORIGINAL_NODE, null);
$this->traverseNodesWithCallable($expr, static function (Node $node) : Node {
$node->setAttribute(AttributeKey::ORIGINAL_NODE, null);
return $node;
});
return $expr;
}
/**
* @return null|\PhpParser\Node\Identifier|\PhpParser\Node\Name|\PhpParser\Node\ComplexType
Expand Down
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '4e56b7c4a9fa9747cb12025c94e07b85a30155bc';
public const PACKAGE_VERSION = 'b491f42c2acd125671c7908a3dacd86316048809';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-10-04 15:42:44';
public const RELEASE_DATE = '2023-10-04 18:13:54';
/**
* @var int
*/
Expand Down

0 comments on commit 489d95e

Please sign in to comment.