mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-01 08:50:50 +00:00
[DogFood] Skip call(configure) on UpgradeRectorConfigRector (#2119)
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
parent
0c649b2e38
commit
465b3f61d6
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Rector\Tests\DogFood\Rector\Closure\UpgradeRectorConfigRector\Fixture;
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\Renaming\Rector\Name\RenameClassRector;
|
||||
|
||||
return static function (RectorConfig $rectorConfig): void {
|
||||
$services = $rectorConfig->services();
|
||||
$services->set(RenameClassRector::class)
|
||||
->call('configure', [[
|
||||
'old_2' => 'new_2',
|
||||
]])
|
||||
->call('configure', [[
|
||||
'old_4' => 'new_4',
|
||||
]]);
|
||||
|
||||
$rectorConfig->import(__DIR__ . '/first_config.php');
|
||||
$rectorConfig->import(__DIR__ . '/second_config.php');
|
||||
};
|
|
@ -6,7 +6,6 @@ namespace Rector\DogFood\Rector\Closure;
|
|||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\Closure;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
|
@ -143,16 +142,13 @@ CODE_SAMPLE
|
|||
$nodeVarType = $this->nodeTypeResolver->getType($node->var);
|
||||
|
||||
if ($nodeVarType instanceof FullyQualifiedObjectType && $nodeVarType->getClassName() === self::SERVICE_CONFIGURATOR_CLASS) {
|
||||
if ($this->isFoundFluentServiceCall($node)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$isPossiblyServiceDefinition = (bool) $this->betterNodeFinder->findFirstPreviousOfNode(
|
||||
$node,
|
||||
function (Node $node): bool {
|
||||
if (! $node instanceof MethodCall) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$methodCall = $this->fluentChainMethodCallNodeAnalyzer->resolveRootMethodCall($node);
|
||||
return $methodCall instanceof Expr;
|
||||
}
|
||||
fn (Node $node): bool => $this->isFoundFluentServiceCall($node)
|
||||
);
|
||||
|
||||
if ($isPossiblyServiceDefinition) {
|
||||
|
@ -222,6 +218,16 @@ CODE_SAMPLE
|
|||
return $this->isNames($paramType, [self::CONTAINER_CONFIGURATOR_CLASS, self::RECTOR_CONFIG_CLASS]);
|
||||
}
|
||||
|
||||
private function isFoundFluentServiceCall(Node $node): bool
|
||||
{
|
||||
if (! $node instanceof MethodCall) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$chains = $this->fluentChainMethodCallNodeAnalyzer->collectMethodCallNamesInChain($node);
|
||||
return count($chains) > 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Arg[] $args
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user