mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 21:38:22 +01:00
Updated Rector to commit de31e6f73765bef8a7285a00114037c07712add7
de31e6f737
[Naming] Allow rename variable in multiple statements on RenameVariableToMatchMethodCallReturnTypeRector (#5963)
This commit is contained in:
parent
5b56f97fec
commit
97b31838f3
@ -60,8 +60,8 @@ CODE_SAMPLE
|
||||
if (!$firstAssign->expr instanceof Assign) {
|
||||
return null;
|
||||
}
|
||||
$lastAssignValue = $this->resolveLastAssignExpr($firstAssign);
|
||||
$collectExpressions = $this->collectExpressions($firstAssign, $lastAssignValue);
|
||||
$expr = $this->resolveLastAssignExpr($firstAssign);
|
||||
$collectExpressions = $this->collectExpressions($firstAssign, $expr);
|
||||
if ($collectExpressions === []) {
|
||||
return null;
|
||||
}
|
||||
|
@ -136,6 +136,7 @@ CODE_SAMPLE
|
||||
if ($node->stmts === null) {
|
||||
return null;
|
||||
}
|
||||
$hasChanged = \false;
|
||||
foreach ($node->stmts as $stmt) {
|
||||
if (!$stmt instanceof Expression) {
|
||||
continue;
|
||||
@ -146,7 +147,7 @@ CODE_SAMPLE
|
||||
$assign = $stmt->expr;
|
||||
$variableAndCallAssign = $this->variableAndCallAssignMatcher->match($assign, $node);
|
||||
if (!$variableAndCallAssign instanceof VariableAndCallAssign) {
|
||||
return null;
|
||||
continue;
|
||||
}
|
||||
$call = $variableAndCallAssign->getCall();
|
||||
$expectedName = $this->expectedNameResolver->resolveForCall($call);
|
||||
@ -160,6 +161,9 @@ CODE_SAMPLE
|
||||
continue;
|
||||
}
|
||||
$this->renameVariable($variableAndCallAssign, $expectedName, $stmt);
|
||||
$hasChanged = \true;
|
||||
}
|
||||
if ($hasChanged) {
|
||||
return $node;
|
||||
}
|
||||
return null;
|
||||
|
@ -108,8 +108,8 @@ final class SubstrMatchAndRefactor implements StrStartWithMatchAndRefactorInterf
|
||||
if (!$this->valueResolver->isValue($secondArg->value, 0)) {
|
||||
return \false;
|
||||
}
|
||||
$hardcodedStringNeedle = $strStartsWith->getNeedleExpr();
|
||||
if (!$hardcodedStringNeedle instanceof String_) {
|
||||
$expr = $strStartsWith->getNeedleExpr();
|
||||
if (!$expr instanceof String_) {
|
||||
return \false;
|
||||
}
|
||||
if (\count($substrFuncCall->getArgs()) < 3) {
|
||||
@ -119,6 +119,6 @@ final class SubstrMatchAndRefactor implements StrStartWithMatchAndRefactorInterf
|
||||
if (!$lNumberLength instanceof LNumber) {
|
||||
return \false;
|
||||
}
|
||||
return $lNumberLength->value === \strlen($hardcodedStringNeedle->value);
|
||||
return $lNumberLength->value === \strlen($expr->value);
|
||||
}
|
||||
}
|
||||
|
@ -132,8 +132,8 @@ CODE_SAMPLE
|
||||
if ($this->shouldOmitEnumCase($enumCaseName)) {
|
||||
return null;
|
||||
}
|
||||
$enumConstFetch = $this->nodeFactory->createClassConstFetch($className, $enumCaseName);
|
||||
return new PropertyFetch($enumConstFetch, 'value');
|
||||
$classConstFetch = $this->nodeFactory->createClassConstFetch($className, $enumCaseName);
|
||||
return new PropertyFetch($classConstFetch, 'value');
|
||||
}
|
||||
private function refactorEqualsMethodCall(MethodCall $methodCall) : ?Identical
|
||||
{
|
||||
|
@ -103,8 +103,8 @@ CODE_SAMPLE
|
||||
return null;
|
||||
}
|
||||
$upperCaseName = \strtoupper($enumCaseName);
|
||||
$enumConstFetch = $this->nodeFactory->createClassConstFetch($className, $upperCaseName);
|
||||
return new PropertyFetch($enumConstFetch, $property);
|
||||
$classConstFetch = $this->nodeFactory->createClassConstFetch($className, $upperCaseName);
|
||||
return new PropertyFetch($classConstFetch, $property);
|
||||
}
|
||||
private function refactorMethodCall(MethodCall $methodCall, string $methodName) : ?\PhpParser\Node\Expr\PropertyFetch
|
||||
{
|
||||
|
@ -132,11 +132,11 @@ CODE_SAMPLE
|
||||
if ($constName === null) {
|
||||
return \false;
|
||||
}
|
||||
$newValue = $this->nodeFactory->createClassConstFetch($attributeKeyToClassConstFetch->getConstantClass(), $constName);
|
||||
if ($arg->value instanceof ClassConstFetch && $this->getName($arg->value) === $this->getName($newValue)) {
|
||||
$classConstFetch = $this->nodeFactory->createClassConstFetch($attributeKeyToClassConstFetch->getConstantClass(), $constName);
|
||||
if ($arg->value instanceof ClassConstFetch && $this->getName($arg->value) === $this->getName($classConstFetch)) {
|
||||
return \false;
|
||||
}
|
||||
$arg->value = $newValue;
|
||||
$arg->value = $classConstFetch;
|
||||
return \true;
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '459843b1617a401d02e8cf5e6a1054f43f069f0d';
|
||||
public const PACKAGE_VERSION = 'de31e6f73765bef8a7285a00114037c07712add7';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2024-06-12 05:07:48';
|
||||
public const RELEASE_DATE = '2024-06-12 06:08:06';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
@ -29,11 +29,11 @@ final class RectorContainerFactory
|
||||
private function createFromConfigs(array $configFiles) : Container
|
||||
{
|
||||
$lazyContainerFactory = new \Rector\DependencyInjection\LazyContainerFactory();
|
||||
$container = $lazyContainerFactory->create();
|
||||
$rectorConfig = $lazyContainerFactory->create();
|
||||
foreach ($configFiles as $configFile) {
|
||||
$container->import($configFile);
|
||||
$rectorConfig->import($configFile);
|
||||
}
|
||||
$container->boot();
|
||||
return $container;
|
||||
$rectorConfig->boot();
|
||||
return $rectorConfig;
|
||||
}
|
||||
}
|
||||
|
@ -289,8 +289,8 @@ final class ValueResolver
|
||||
// fallback to constant reference itself, to avoid fatal error
|
||||
return $classConstantReference;
|
||||
}
|
||||
$constantReflection = $classReflection->getConstant($constant);
|
||||
$valueExpr = $constantReflection->getValueExpr();
|
||||
$classConstantReflection = $classReflection->getConstant($constant);
|
||||
$valueExpr = $classConstantReflection->getValueExpr();
|
||||
if ($valueExpr instanceof ConstFetch) {
|
||||
return $this->resolveExprValueForConst($valueExpr);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user