From 04dea6870d2e26f59a636db48a06bd8b434027cc Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Tue, 9 Feb 2021 03:00:18 +0100 Subject: [PATCH 01/12] [DeadCode] Add RemoveUnusedConstructorParamRector --- config/set/dead-code.php | 45 +-------- packages/node-removal/src/NodeRemover.php | 12 ++- .../RemoveUnusedConstructorParamRector.php | 94 +++++++++++++++++++ .../Fixture/some_class.php.inc | 31 ++++++ ...RemoveUnusedConstructorParamRectorTest.php | 29 ++++++ ...isteningClassMethodArgumentManipulator.php | 25 ++--- .../src/NodeManipulator/ParamAnalyzer.php | 44 +++++++++ .../OnLogoutClassMethodFactory.php | 15 ++- 8 files changed, 230 insertions(+), 65 deletions(-) create mode 100644 rules/dead-code/src/Rector/ClassMethod/RemoveUnusedConstructorParamRector.php create mode 100644 rules/dead-code/tests/Rector/ClassMethod/RemoveUnusedConstructorParamRector/Fixture/some_class.php.inc create mode 100644 rules/dead-code/tests/Rector/ClassMethod/RemoveUnusedConstructorParamRector/RemoveUnusedConstructorParamRectorTest.php create mode 100644 rules/nette-kdyby/src/NodeManipulator/ParamAnalyzer.php diff --git a/config/set/dead-code.php b/config/set/dead-code.php index e4e99a224575..686ecabd3f3d 100644 --- a/config/set/dead-code.php +++ b/config/set/dead-code.php @@ -17,6 +17,7 @@ use Rector\DeadCode\Rector\ClassMethod\RemoveDeadRecursiveClassMethodRector; use Rector\DeadCode\Rector\ClassMethod\RemoveDelegatingParentCallRector; use Rector\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector; +use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector; use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedParameterRector; use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector; use Rector\DeadCode\Rector\Concat\RemoveConcatAutocastRector; @@ -49,90 +50,48 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); - $services->set(UnwrapFutureCompatibleIfFunctionExistsRector::class); - $services->set(UnwrapFutureCompatibleIfPhpVersionRector::class); - $services->set(RecastingRemovalRector::class); - $services->set(RemoveDeadStmtRector::class); - $services->set(RemoveDuplicatedArrayKeyRector::class); - $services->set(RemoveUnusedForeachKeyRector::class); - $services->set(RemoveParentCallWithoutParentRector::class); - $services->set(RemoveEmptyClassMethodRector::class); - $services->set(RemoveUnusedPrivatePropertyRector::class); - $services->set(RemoveDoubleAssignRector::class); - $services->set(RemoveUnusedParameterRector::class); - $services->set(SimplifyMirrorAssignRector::class); - $services->set(RemoveOverriddenValuesRector::class); - $services->set(RemoveUnusedPrivateConstantRector::class); - $services->set(RemoveUnusedPrivateMethodRector::class); - $services->set(RemoveCodeAfterReturnRector::class); - $services->set(RemoveDeadConstructorRector::class); - $services->set(RemoveDeadReturnRector::class); - $services->set(RemoveDeadIfForeachForRector::class); - $services->set(RemoveAndTrueRector::class); - $services->set(RemoveDefaultArgumentValueRector::class); - $services->set(RemoveConcatAutocastRector::class); - $services->set(SimplifyUselessVariableRector::class); - $services->set(RemoveDelegatingParentCallRector::class); - $services->set(RemoveDuplicatedInstanceOfRector::class); - $services->set(RemoveDuplicatedCaseInSwitchRector::class); - $services->set(RemoveUnusedDoctrineEntityMethodAndPropertyRector::class); - $services->set(RemoveSetterOnlyPropertyAndMethodCallRector::class); - $services->set(RemoveNullPropertyInitializationRector::class); - $services->set(RemoveUnreachableStatementRector::class); - $services->set(SimplifyIfElseWithSameContentRector::class); - $services->set(TernaryToBooleanOrFalseToBooleanAndRector::class); - $services->set(RemoveEmptyTestMethodRector::class); - $services->set(RemoveDeadTryCatchRector::class); - $services->set(RemoveUnusedClassConstantRector::class); - $services->set(RemoveUnusedVariableAssignRector::class); - $services->set(RemoveDuplicatedIfReturnRector::class); - $services->set(RemoveUnusedFunctionRector::class); - $services->set(RemoveUnusedNonEmptyArrayBeforeForeachRector::class); - $services->set(RemoveAssignOfVoidReturnFunctionRector::class); - $services->set(RemoveDeadRecursiveClassMethodRector::class); - $services->set(RemoveEmptyMethodCallRector::class); - $services->set(RemoveDeadConditionAboveReturnRector::class); + $services->set(RemoveUnusedConstructorParamRector::class); }; diff --git a/packages/node-removal/src/NodeRemover.php b/packages/node-removal/src/NodeRemover.php index 499b2dcc29b7..536b45616f22 100644 --- a/packages/node-removal/src/NodeRemover.php +++ b/packages/node-removal/src/NodeRemover.php @@ -8,6 +8,7 @@ use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\StaticCall; +use PhpParser\Node\Param; use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\Function_; @@ -89,8 +90,17 @@ public function removeStmt(Node $node, int $key): void unset($node->stmts[$key]); } - public function removeParam(ClassMethod $classMethod, int $key): void + /** + * @param int|Param $keyOrParam + */ + public function removeParam(ClassMethod $classMethod, $keyOrParam): void { + if ($keyOrParam instanceof Param) { + $key = $keyOrParam->getAttribute(AttributeKey::PARAMETER_POSITION); + } else { + $key = $keyOrParam; + } + if ($classMethod->params === null) { throw new ShouldNotHappenException(); } diff --git a/rules/dead-code/src/Rector/ClassMethod/RemoveUnusedConstructorParamRector.php b/rules/dead-code/src/Rector/ClassMethod/RemoveUnusedConstructorParamRector.php new file mode 100644 index 000000000000..238770c323a3 --- /dev/null +++ b/rules/dead-code/src/Rector/ClassMethod/RemoveUnusedConstructorParamRector.php @@ -0,0 +1,94 @@ +paramAnalyzer = $paramAnalyzer; + } + + public function getRuleDefinition(): RuleDefinition + { + return new RuleDefinition('Remove unused parameter in constructor', [ + new CodeSample( + <<<'CODE_SAMPLE' +final class SomeClass +{ + private $hey; + + public function __construct($hey, $man) + { + $this->hey = $hey; + } +} +CODE_SAMPLE + + , + <<<'CODE_SAMPLE' +final class SomeClass +{ + private $hey; + + public function __construct($hey) + { + $this->hey = $hey; + } +} +CODE_SAMPLE + + ), + ]); + } + + /** + * @return string[] + */ + public function getNodeTypes(): array + { + return [ClassMethod::class]; + } + + /** + * @param ClassMethod $node + */ + public function refactor(Node $node): ?Node + { + if (! $this->isName($node, MethodName::CONSTRUCT)) { + return null; + } + + if ($node->params === []) { + return null; + } + + foreach ($node->params as $param) { + if ($this->paramAnalyzer->isParamUsedInClassMethod($node, $param)) { + continue; + } + + $this->nodeRemover->removeParam($node, $param); + } + + return null; + } +} diff --git a/rules/dead-code/tests/Rector/ClassMethod/RemoveUnusedConstructorParamRector/Fixture/some_class.php.inc b/rules/dead-code/tests/Rector/ClassMethod/RemoveUnusedConstructorParamRector/Fixture/some_class.php.inc new file mode 100644 index 000000000000..5802bede3d25 --- /dev/null +++ b/rules/dead-code/tests/Rector/ClassMethod/RemoveUnusedConstructorParamRector/Fixture/some_class.php.inc @@ -0,0 +1,31 @@ +hey = $hey; + } +} + +?> +----- +hey = $hey; + } +} + +?> diff --git a/rules/dead-code/tests/Rector/ClassMethod/RemoveUnusedConstructorParamRector/RemoveUnusedConstructorParamRectorTest.php b/rules/dead-code/tests/Rector/ClassMethod/RemoveUnusedConstructorParamRector/RemoveUnusedConstructorParamRectorTest.php new file mode 100644 index 000000000000..535ff5472a15 --- /dev/null +++ b/rules/dead-code/tests/Rector/ClassMethod/RemoveUnusedConstructorParamRector/RemoveUnusedConstructorParamRectorTest.php @@ -0,0 +1,29 @@ +doTestFileInfo($fileInfo); + } + + public function provideData(): \Iterator + { + return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); + } + + protected function getRectorClass(): string + { + return RemoveUnusedConstructorParamRector::class; + } +} diff --git a/rules/nette-kdyby/src/NodeManipulator/ListeningClassMethodArgumentManipulator.php b/rules/nette-kdyby/src/NodeManipulator/ListeningClassMethodArgumentManipulator.php index ffa8364d1a5f..6ade5400db9e 100644 --- a/rules/nette-kdyby/src/NodeManipulator/ListeningClassMethodArgumentManipulator.php +++ b/rules/nette-kdyby/src/NodeManipulator/ListeningClassMethodArgumentManipulator.php @@ -4,7 +4,6 @@ namespace Rector\NetteKdyby\NodeManipulator; -use PhpParser\Node; use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\Variable; @@ -47,16 +46,23 @@ final class ListeningClassMethodArgumentManipulator */ private $betterStandardPrinter; + /** + * @var ParamAnalyzer + */ + private $paramAnalyzer; + public function __construct( BetterNodeFinder $betterNodeFinder, BetterStandardPrinter $betterStandardPrinter, ClassNaming $classNaming, - ContributeEventClassResolver $contributeEventClassResolver + ContributeEventClassResolver $contributeEventClassResolver, + \Rector\NetteKdyby\NodeManipulator\ParamAnalyzer $paramAnalyzer ) { $this->classNaming = $classNaming; $this->contributeEventClassResolver = $contributeEventClassResolver; $this->betterNodeFinder = $betterNodeFinder; $this->betterStandardPrinter = $betterStandardPrinter; + $this->paramAnalyzer = $paramAnalyzer; } public function changeFromEventAndListenerTreeAndCurrentClassName( @@ -97,7 +103,7 @@ public function change(array $classMethodsByEventClass, ?EventAndListenerTree $e // move params to getter on event foreach ($oldParams as $oldParam) { - if (! $this->isParamUsedInClassMethodBody($classMethod, $oldParam)) { + if (! $this->paramAnalyzer->isParamUsedInClassMethod($classMethod, $oldParam)) { continue; } @@ -116,19 +122,6 @@ public function change(array $classMethodsByEventClass, ?EventAndListenerTree $e } } - public function isParamUsedInClassMethodBody(ClassMethod $classMethod, Param $param): bool - { - return (bool) $this->betterNodeFinder->findFirst((array) $classMethod->stmts, function (Node $node) use ( - $param - ): bool { - if (! $node instanceof Variable) { - return false; - } - - return $this->betterStandardPrinter->areNodesEqual($node, $param->var); - }); - } - private function changeClassParamToEventClass(string $eventClass, ClassMethod $classMethod): void { $paramName = $this->classNaming->getVariableName($eventClass); diff --git a/rules/nette-kdyby/src/NodeManipulator/ParamAnalyzer.php b/rules/nette-kdyby/src/NodeManipulator/ParamAnalyzer.php new file mode 100644 index 000000000000..c3c7c5e2ad49 --- /dev/null +++ b/rules/nette-kdyby/src/NodeManipulator/ParamAnalyzer.php @@ -0,0 +1,44 @@ +betterNodeFinder = $betterNodeFinder; + $this->betterStandardPrinter = $betterStandardPrinter; + } + + public function isParamUsedInClassMethod(ClassMethod $classMethod, Param $param): bool + { + return (bool) $this->betterNodeFinder->findFirst((array) $classMethod->stmts, function (Node $node) use ( + $param + ): bool { + if (! $node instanceof Variable) { + return false; + } + + return $this->betterStandardPrinter->areNodesEqual($node, $param->var); + }); + } +} diff --git a/rules/symfony5/src/NodeFactory/OnLogoutClassMethodFactory.php b/rules/symfony5/src/NodeFactory/OnLogoutClassMethodFactory.php index 01b3e547277d..a1aa13bdeb34 100644 --- a/rules/symfony5/src/NodeFactory/OnLogoutClassMethodFactory.php +++ b/rules/symfony5/src/NodeFactory/OnLogoutClassMethodFactory.php @@ -12,6 +12,7 @@ use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\Expression; use Rector\NetteKdyby\NodeManipulator\ListeningClassMethodArgumentManipulator; +use Rector\NetteKdyby\NodeManipulator\ParamAnalyzer; use Rector\NodeNameResolver\NodeNameResolver; final class OnLogoutClassMethodFactory @@ -40,14 +41,21 @@ final class OnLogoutClassMethodFactory */ private $bareLogoutClassMethodFactory; + /** + * @var ParamAnalyzer + */ + private $paramAnalyzer; + public function __construct( ListeningClassMethodArgumentManipulator $listeningClassMethodArgumentManipulator, NodeNameResolver $nodeNameResolver, - BareLogoutClassMethodFactory $bareLogoutClassMethodFactory + BareLogoutClassMethodFactory $bareLogoutClassMethodFactory, + ParamAnalyzer $paramAnalyzer ) { $this->listeningClassMethodArgumentManipulator = $listeningClassMethodArgumentManipulator; $this->nodeNameResolver = $nodeNameResolver; $this->bareLogoutClassMethodFactory = $bareLogoutClassMethodFactory; + $this->paramAnalyzer = $paramAnalyzer; } public function createFromLogoutClassMethod(ClassMethod $logoutClassMethod): ClassMethod @@ -76,10 +84,7 @@ private function resolveUsedParams(ClassMethod $logoutClassMethod): array { $usedParams = []; foreach ($logoutClassMethod->params as $oldParam) { - if (! $this->listeningClassMethodArgumentManipulator->isParamUsedInClassMethodBody( - $logoutClassMethod, - $oldParam - )) { + if (! $this->paramAnalyzer->isParamUsedInClassMethod($logoutClassMethod, $oldParam)) { continue; } From 478b601b5a786d89da4b075929f0aacb3ea558bb Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Tue, 9 Feb 2021 03:03:36 +0100 Subject: [PATCH 02/12] make use of node remover --- .../MethodCall/ArrayToFluentCallRector.php | 3 ++- .../ClassMethod/UnSpreadOperatorRector.php | 3 ++- ...ultiParentingToAbstractDependencyRector.php | 2 +- ...ListeningClassMethodArgumentManipulator.php | 18 +----------------- .../ClassMethod/ArgumentRemoverRector.php | 8 +++++--- .../FuncCall/RemoveFuncCallArgRector.php | 2 +- .../NodeFactory/OnLogoutClassMethodFactory.php | 8 -------- 7 files changed, 12 insertions(+), 32 deletions(-) diff --git a/rules/cakephp/src/Rector/MethodCall/ArrayToFluentCallRector.php b/rules/cakephp/src/Rector/MethodCall/ArrayToFluentCallRector.php index 15f7f47d2b50..1191d0d43deb 100644 --- a/rules/cakephp/src/Rector/MethodCall/ArrayToFluentCallRector.php +++ b/rules/cakephp/src/Rector/MethodCall/ArrayToFluentCallRector.php @@ -166,7 +166,8 @@ private function replaceArrayToFluentMethodCalls( if ($arrayItemsAndFluentClass->getArrayItems() !== []) { $argumentValue->items = $arrayItemsAndFluentClass->getArrayItems(); } else { - unset($methodCall->args[$argumentPosition - 1]); + $positionToRemove = $argumentPosition - 1; + $this->nodeRemover->removeArg($methodCall, $positionToRemove); } if ($arrayItemsAndFluentClass->getFluentCalls() === []) { diff --git a/rules/coding-style/src/Rector/ClassMethod/UnSpreadOperatorRector.php b/rules/coding-style/src/Rector/ClassMethod/UnSpreadOperatorRector.php index becda1935d4d..4686f6485259 100644 --- a/rules/coding-style/src/Rector/ClassMethod/UnSpreadOperatorRector.php +++ b/rules/coding-style/src/Rector/ClassMethod/UnSpreadOperatorRector.php @@ -145,7 +145,8 @@ private function resolveVariadicArgsByVariadicParams(MethodCall $methodCall, int } $variadicArgs[] = $arg; - unset($methodCall->args[$position]); + + $this->nodeRemover->removeArg($methodCall, $position); } return $variadicArgs; diff --git a/rules/dependency-injection/src/Rector/Class_/MultiParentingToAbstractDependencyRector.php b/rules/dependency-injection/src/Rector/Class_/MultiParentingToAbstractDependencyRector.php index 667f719115e7..c86e001fc652 100644 --- a/rules/dependency-injection/src/Rector/Class_/MultiParentingToAbstractDependencyRector.php +++ b/rules/dependency-injection/src/Rector/Class_/MultiParentingToAbstractDependencyRector.php @@ -240,7 +240,7 @@ private function refactorChildConstructorClassMethod( continue; } - unset($classMethod->params[$key]); + $this->nodeRemover->removeParam($classMethod, $key); $this->classMethodNodeRemover->removeParamFromMethodBody($classMethod, $param); $this->objectTypesToInject[] = $paramType; diff --git a/rules/nette-kdyby/src/NodeManipulator/ListeningClassMethodArgumentManipulator.php b/rules/nette-kdyby/src/NodeManipulator/ListeningClassMethodArgumentManipulator.php index 6ade5400db9e..59dad32605ed 100644 --- a/rules/nette-kdyby/src/NodeManipulator/ListeningClassMethodArgumentManipulator.php +++ b/rules/nette-kdyby/src/NodeManipulator/ListeningClassMethodArgumentManipulator.php @@ -12,8 +12,6 @@ use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\Expression; use Rector\CodingStyle\Naming\ClassNaming; -use Rector\Core\PhpParser\Node\BetterNodeFinder; -use Rector\Core\PhpParser\Printer\BetterStandardPrinter; use Rector\NetteKdyby\ContributeEventClassResolver; use Rector\NetteKdyby\ValueObject\EventAndListenerTree; use Rector\NetteKdyby\ValueObject\EventClassAndClassMethod; @@ -36,32 +34,18 @@ final class ListeningClassMethodArgumentManipulator */ private $contributeEventClassResolver; - /** - * @var BetterNodeFinder - */ - private $betterNodeFinder; - - /** - * @var BetterStandardPrinter - */ - private $betterStandardPrinter; - /** * @var ParamAnalyzer */ private $paramAnalyzer; public function __construct( - BetterNodeFinder $betterNodeFinder, - BetterStandardPrinter $betterStandardPrinter, ClassNaming $classNaming, ContributeEventClassResolver $contributeEventClassResolver, - \Rector\NetteKdyby\NodeManipulator\ParamAnalyzer $paramAnalyzer + ParamAnalyzer $paramAnalyzer ) { $this->classNaming = $classNaming; $this->contributeEventClassResolver = $contributeEventClassResolver; - $this->betterNodeFinder = $betterNodeFinder; - $this->betterStandardPrinter = $betterStandardPrinter; $this->paramAnalyzer = $paramAnalyzer; } diff --git a/rules/removing/src/Rector/ClassMethod/ArgumentRemoverRector.php b/rules/removing/src/Rector/ClassMethod/ArgumentRemoverRector.php index f8ad5f6a5f8f..f4e16d2ac2e0 100644 --- a/rules/removing/src/Rector/ClassMethod/ArgumentRemoverRector.php +++ b/rules/removing/src/Rector/ClassMethod/ArgumentRemoverRector.php @@ -100,9 +100,9 @@ private function processPosition(Node $node, ArgumentRemover $argumentRemover): { if ($argumentRemover->getValue() === null) { if ($node instanceof MethodCall || $node instanceof StaticCall) { - unset($node->args[$argumentRemover->getPosition()]); + $this->nodeRemover->removeArg($node, $argumentRemover->getPosition()); } else { - unset($node->params[$argumentRemover->getPosition()]); + $this->nodeRemover->removeParam($node, $argumentRemover->getPosition()); } return; @@ -113,16 +113,18 @@ private function processPosition(Node $node, ArgumentRemover $argumentRemover): $this->removeByName($node, $argumentRemover->getPosition(), $match['name']); return; } + // only argument specific value can be removed if ($node instanceof ClassMethod) { return; } + if (! isset($node->args[$argumentRemover->getPosition()])) { return; } if ($this->isArgumentValueMatch($node->args[$argumentRemover->getPosition()], $match)) { - unset($node->args[$argumentRemover->getPosition()]); + $this->nodeRemover->removeArg($node, $argumentRemover->getPosition()); } } diff --git a/rules/removing/src/Rector/FuncCall/RemoveFuncCallArgRector.php b/rules/removing/src/Rector/FuncCall/RemoveFuncCallArgRector.php index c42353053171..21d37302cccf 100644 --- a/rules/removing/src/Rector/FuncCall/RemoveFuncCallArgRector.php +++ b/rules/removing/src/Rector/FuncCall/RemoveFuncCallArgRector.php @@ -70,7 +70,7 @@ public function refactor(Node $node): ?Node continue; } - unset($node->args[$position]); + $this->nodeRemover->removeArg($node, $position); } } diff --git a/rules/symfony5/src/NodeFactory/OnLogoutClassMethodFactory.php b/rules/symfony5/src/NodeFactory/OnLogoutClassMethodFactory.php index a1aa13bdeb34..944317c4ffba 100644 --- a/rules/symfony5/src/NodeFactory/OnLogoutClassMethodFactory.php +++ b/rules/symfony5/src/NodeFactory/OnLogoutClassMethodFactory.php @@ -11,7 +11,6 @@ use PhpParser\Node\Stmt; use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\Expression; -use Rector\NetteKdyby\NodeManipulator\ListeningClassMethodArgumentManipulator; use Rector\NetteKdyby\NodeManipulator\ParamAnalyzer; use Rector\NodeNameResolver\NodeNameResolver; @@ -26,11 +25,6 @@ final class OnLogoutClassMethodFactory 'token' => 'getToken', ]; - /** - * @var ListeningClassMethodArgumentManipulator - */ - private $listeningClassMethodArgumentManipulator; - /** * @var NodeNameResolver */ @@ -47,12 +41,10 @@ final class OnLogoutClassMethodFactory private $paramAnalyzer; public function __construct( - ListeningClassMethodArgumentManipulator $listeningClassMethodArgumentManipulator, NodeNameResolver $nodeNameResolver, BareLogoutClassMethodFactory $bareLogoutClassMethodFactory, ParamAnalyzer $paramAnalyzer ) { - $this->listeningClassMethodArgumentManipulator = $listeningClassMethodArgumentManipulator; $this->nodeNameResolver = $nodeNameResolver; $this->bareLogoutClassMethodFactory = $bareLogoutClassMethodFactory; $this->paramAnalyzer = $paramAnalyzer; From f001ee7c168599c315545e7353fd69ffdbcc25c0 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Tue, 9 Feb 2021 03:27:39 +0100 Subject: [PATCH 03/12] [Core] Add temporary GetRectorsWithConfigurationToProvideConfigFileInfoRector --- composer.json | 2 +- rector.php | 2 + ...igurationToProvideConfigFileInfoRector.php | 225 ++++++++++++++++++ .../Fixture/some_class.php.inc | 36 +++ ...ationToProvideConfigFileInfoRectorTest.php | 28 +++ .../config/configured_rule.php | 4 + 6 files changed, 296 insertions(+), 1 deletion(-) create mode 100644 rules/core/src/Rector/ClassMethod/GetRectorsWithConfigurationToProvideConfigFileInfoRector.php create mode 100644 rules/core/tests/Rector/ClassMethod/GetRectorsWithConfigurationToProvideConfigFileInfoRector/Fixture/some_class.php.inc create mode 100644 rules/core/tests/Rector/ClassMethod/GetRectorsWithConfigurationToProvideConfigFileInfoRector/GetRectorsWithConfigurationToProvideConfigFileInfoRectorTest.php create mode 100644 rules/transform/tests/Rector/New_/NewArgToMethodCallRector/config/configured_rule.php diff --git a/composer.json b/composer.json index c533771b47da..16cdf1cc4131 100644 --- a/composer.json +++ b/composer.json @@ -96,7 +96,7 @@ "Rector\\CodeQuality\\": "rules/code-quality/src", "Rector\\CodingStyle\\": "rules/coding-style/src", "Rector\\Composer\\": "rules/composer/src", - "Rector\\Core\\": "src", + "Rector\\Core\\": ["src", "rules/core/src"], "Rector\\DeadCode\\": "rules/dead-code/src", "Rector\\DependencyInjection\\": "rules/dependency-injection/src", "Rector\\EarlyReturn\\": "rules/early-return/src", diff --git a/rector.php b/rector.php index e56dcd9dbc6b..78a417d9eb5b 100644 --- a/rector.php +++ b/rector.php @@ -20,6 +20,8 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); + $services->set(\Rector\Core\Rector\ClassMethod\GetRectorsWithConfigurationToProvideConfigFileInfoRector::class); + $configuration = ValueObjectInliner::inline([ new InferParamFromClassMethodReturn(AbstractRector::class, 'refactor', 'getNodeTypes'), ]); diff --git a/rules/core/src/Rector/ClassMethod/GetRectorsWithConfigurationToProvideConfigFileInfoRector.php b/rules/core/src/Rector/ClassMethod/GetRectorsWithConfigurationToProvideConfigFileInfoRector.php new file mode 100644 index 000000000000..048481d54921 --- /dev/null +++ b/rules/core/src/Rector/ClassMethod/GetRectorsWithConfigurationToProvideConfigFileInfoRector.php @@ -0,0 +1,225 @@ +configuratorClosureNodeFactory = $configuratorClosureNodeFactory; + } + + public function getRuleDefinition(): RuleDefinition + { + return new RuleDefinition('Remove unused parameter in constructor', [ + new CodeSample( + <<<'CODE_SAMPLE' +final class SomeClass +{ + /** + * @return mixed[] + */ + protected function getRectorsWithConfiguration(): array + { + return [ + NewArgToMethodCallRector::class => [ + NewArgToMethodCallRector::NEW_ARGS_TO_METHOD_CALLS => [ + new NewArgToMethodCall(SomeDotenv::class, true, 'usePutenv'), + ], + ], + ]; + } +} +CODE_SAMPLE + + , + <<<'CODE_SAMPLE' +final class SomeClass +{ + protected function getRectorsWithConfiguration(): \Symplify\SmartFileSystem\SmartFileInfo + { + return new \Symplify\SmartFileSystem\SmartFileInfo(__DIR__ . '/config/configured_rule.php'); + } +} +CODE_SAMPLE + + ), + ]); + } + + /** + * @return string[] + */ + public function getNodeTypes(): array + { + return [ClassMethod::class]; + } + + /** + * @param ClassMethod $node + */ + public function refactor(Node $node): ?Node + { + if (! $this->isName($node, 'getRectorsWithConfiguration')) { + return null; + } + + $node->name = new Node\Identifier('provideConfigFileInfo'); + + /** @var Return_ $oldReturn */ + $oldReturn = $node->stmts[0]; + + $node->returnType = new Node\NullableType(new FullyQualified(SmartFileInfo::class)); + $this->createReturnTag($node); + + /** @var SmartFileInfo $smartFileInfo */ + $smartFileInfo = $node->getAttribute(SmartFileInfo::class); + $realPath = $smartFileInfo->getRealPath(); + $configFilePath = dirname($realPath) . '/config/configured_rule.php'; + + $services = []; + + $services[] = new Node\Stmt\Expression(new Node\Expr\Assign(new Variable('services'), new MethodCall( + new Variable( + 'containerConfigurator' + ), + 'services' + ))); + + $closure = null; + $serviceVariable = new Variable('services'); + + // get config value + /** @var Array_ $returnedArray */ + $returnedArray = $oldReturn->expr; + foreach ($returnedArray->items as $arrayItem) { + if (! $arrayItem instanceof ArrayItem) { + continue; + } + + if ($arrayItem->key instanceof ClassConstFetch) { + $methodCall = new MethodCall($serviceVariable, 'set', [$arrayItem->key]); + if ($arrayItem->value instanceof Array_) { + if ($arrayItem->value->items === []) { + $services[] = new Node\Stmt\Expression($methodCall); + } else { + foreach ($arrayItem->value->items as $nestedArrayItem) { + if (! $nestedArrayItem instanceof ArrayItem) { + continue; + } + + if ($nestedArrayItem->key instanceof ClassConstFetch) { + $hasValueObjects = $this->hasValueObjects($nestedArrayItem); + + if ($hasValueObjects) { + $configurationArray = new Node\Expr\StaticCall(new FullyQualified( + ValueObjectInliner::class + ), 'inline', [ + $nestedArrayItem->value, + ]); + } else { + $configurationArray = $nestedArrayItem->value; + } + + $arrayConfiguration = new Array_([new ArrayItem( + new Array_([new ArrayItem($configurationArray, $nestedArrayItem->key)])), + ]); + + $methodCall = new MethodCall($methodCall, 'call', [ + new Node\Scalar\String_('configure'), + $arrayConfiguration, + ]); + } + + $services[] = new Node\Stmt\Expression($methodCall); + } + } + } + + $closure = $this->configuratorClosureNodeFactory->createContainerClosureFromStmts($services); + } + } + + if ($closure === null) { + throw new ShouldNotHappenException(); + } + + $return = new Return_($closure); + $fileContent = $this->betterStandardPrinter->prettyPrintFile([$return]); + + dump($fileContent); + + $this->createPhpConfigFileAndDumpToPath($fileContent, $configFilePath); + + $node->stmts = [$this->createReturn()]; + + return $node; + } + + private function createReturn(): Return_ + { + $new = new New_(new FullyQualified(SmartFileInfo::class)); + $new->args[] = new Node\Expr\BinaryOp\Concat(new Node\Scalar\MagicConst\Dir(), new Node\Scalar\String_( + '/config/configured_rule.php' + )); + + return new Return_($new); + } + + private function createReturnTag($node): void + { + $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); + $phpDocInfo->removeByType(ReturnTagValueNode::class); + } + + private function createPhpConfigFileAndDumpToPath(string $fileContent, string $filePath): void + { + $addedFileWithContent = new AddedFileWithContent($filePath, $fileContent); + $this->removedAndAddedFilesCollector->addAddedFile($addedFileWithContent); + } + + private function hasValueObjects(ArrayItem $nestedArrayItem): bool + { + if ($nestedArrayItem->value instanceof Array_) { + foreach ($nestedArrayItem->value->items as $nestedNestedArrayItem) { + if (! $nestedNestedArrayItem instanceof ArrayItem) { + continue; + } + + return $nestedNestedArrayItem->value instanceof New_; + } + } + + return false; + } +} diff --git a/rules/core/tests/Rector/ClassMethod/GetRectorsWithConfigurationToProvideConfigFileInfoRector/Fixture/some_class.php.inc b/rules/core/tests/Rector/ClassMethod/GetRectorsWithConfigurationToProvideConfigFileInfoRector/Fixture/some_class.php.inc new file mode 100644 index 000000000000..03ccc9aa3953 --- /dev/null +++ b/rules/core/tests/Rector/ClassMethod/GetRectorsWithConfigurationToProvideConfigFileInfoRector/Fixture/some_class.php.inc @@ -0,0 +1,36 @@ + [ + NewArgToMethodCallRector::NEW_ARGS_TO_METHOD_CALLS => [ + new NewArgToMethodCall(SomeDotenv::class, true, 'usePutenv'), + ], + ], + ]; + } +} + +?> +----- + diff --git a/rules/core/tests/Rector/ClassMethod/GetRectorsWithConfigurationToProvideConfigFileInfoRector/GetRectorsWithConfigurationToProvideConfigFileInfoRectorTest.php b/rules/core/tests/Rector/ClassMethod/GetRectorsWithConfigurationToProvideConfigFileInfoRector/GetRectorsWithConfigurationToProvideConfigFileInfoRectorTest.php new file mode 100644 index 000000000000..a809f3ac6dbc --- /dev/null +++ b/rules/core/tests/Rector/ClassMethod/GetRectorsWithConfigurationToProvideConfigFileInfoRector/GetRectorsWithConfigurationToProvideConfigFileInfoRectorTest.php @@ -0,0 +1,28 @@ +doTestFileInfo($fileInfo); + } + + public function provideData(): \Iterator + { + return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); + } + + protected function getRectorClass(): string + { + return \Rector\Core\Rector\ClassMethod\GetRectorsWithConfigurationToProvideConfigFileInfoRector::class; + } +} diff --git a/rules/transform/tests/Rector/New_/NewArgToMethodCallRector/config/configured_rule.php b/rules/transform/tests/Rector/New_/NewArgToMethodCallRector/config/configured_rule.php new file mode 100644 index 000000000000..a2e8e0dd88ba --- /dev/null +++ b/rules/transform/tests/Rector/New_/NewArgToMethodCallRector/config/configured_rule.php @@ -0,0 +1,4 @@ +return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void { + $services = $containerConfigurator->services(); + $services->set(\Rector\Transform\Rector\New_\NewArgToMethodCallRector::class)->configure('call', [[\Rector\Transform\Rector\New_\NewArgToMethodCallRector::NEW_ARGS_TO_METHOD_CALLS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Transform\ValueObject\NewArgToMethodCall(\Rector\Transform\Tests\Rector\New_\NewArgToMethodCallRector\Source\SomeDotenv::class, true, 'usePutenv')])]]); +}; \ No newline at end of file From 5c0a574adf691267eb6d02dedd7ecf05fdb17433 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Tue, 9 Feb 2021 05:22:38 +0100 Subject: [PATCH 04/12] switch getRulesWithConfiguration() to config first approach --- "Abc\\FqnizeNamespaced," | 3 + "MyNamespace\\MyNewClass," | 0 "MyNewNamespace\\MyNewClass," | 0 "MyNewNamespace\\MyNewInterface," | 0 "MyNewNamespace\\MyNewTrait," | 0 "Twig\\Extension\\SandboxExtension," | 0 composer.json | 2 +- config/set/downgrade-php71.php | 1 + config/set/downgrade-php72.php | 1 + config/set/downgrade-php73.php | 1 + config/set/downgrade-php74.php | 1 + config/set/downgrade-php80.php | 1 + config/set/guzzle50.php | 6 +- docs/rector_rules_overview.md | 32 +-- .../__Configured__Extra__Name__Test.php.inc | 11 +- .../__Name__/__Configured__Name__Test.php.inc | 10 +- .../WhateverRector/WhateverRectorTest.php.inc | 10 +- .../WhateverRector/WhateverRectorTest.php.inc | 10 +- .../src/PHPUnit/AbstractRectorTestCase.php | 56 +---- phpstan.neon | 5 + rector.php | 2 - ...eServicesBySuffixToDirectoryRectorTest.php | 17 +- .../config/configured_rule.php | 18 ++ ...bjectsToValueObjectDirectoryRectorTest.php | 15 +- .../config/configured_rule.php | 37 +++ .../ArrayToFluentCallRectorTest.php | 24 +- .../config/configured_rule.php | 26 ++ .../ModalToGetSetRectorTest.php | 26 +- .../config/configured_rule.php | 41 ++++ ...meMethodCallBasedOnParameterRectorTest.php | 17 +- .../config/configured_rule.php | 30 +++ ...eturnArrayClassMethodToYieldRectorTest.php | 21 +- .../config/configured_rule.php | 57 +++++ ...lassMethodToArrayClassMethodRectorTest.php | 15 +- .../config/configured_rule.php | 17 ++ .../FunctionCallToConstantRectorTest.php | 15 +- .../config/configured_rule.php | 13 + .../PreferThisOrSelfMethodCallRectorTest.php | 19 +- .../config/configured_rule.php | 14 ++ ...igurationToProvideConfigFileInfoRector.php | 225 ------------------ .../Fixture/some_class.php.inc | 36 --- ...ationToProvideConfigFileInfoRectorTest.php | 28 --- ...RemoveUnusedConstructorParamRectorTest.php | 6 +- .../RemoveAnnotationRectorTest.php | 13 +- .../config/configured_rule.php | 13 + ...arentingToAbstractDependencyRectorTest.php | 13 +- ...arentingToAbstractDependencyRectorTest.php | 13 +- .../config/nette_config.php | 16 ++ .../config/symfony_config.php | 16 ++ .../DoctrineRepositoryAsServiceTest.php | 15 +- .../config/configured_rule.php | 13 + .../AddEntityIdByConditionRectorTest.php | 13 +- .../config/configured_rule.php | 12 + ...liasToClassConstantReferenceRectorTest.php | 14 +- .../config/configured_rule.php | 15 ++ .../AddMethodParentCallRectorTest.php | 15 +- .../config/configured_rule.php | 12 + .../ArgumentAdderRectorTest.php | 49 +--- .../config/configured_rule.php | 54 +++++ ...ArgumentDefaultValueReplacerRectorTest.php | 51 +--- .../config/configured_rule.php | 95 ++++++++ .../NormalToFluentRectorTest.php | 20 +- .../config/configured_rule.php | 33 +++ .../SingleToManyMethodRectorTest.php | 16 +- .../config/configured_rule.php | 59 +++++ .../WrapReturnRector/WrapReturnRectorTest.php | 14 +- .../config/configured_rule.php | 59 +++++ .../AddInterfaceByTraitRectorTest.php | 16 +- .../config/configured_rule.php | 12 + .../AddPropertyByParentRectorTest.php | 16 +- .../config/configured_rule.php | 58 +++++ .../MergeInterfacesRectorTest.php | 16 +- .../config/configured_rule.php | 12 + .../SwapFuncCallArgumentsRectorTest.php | 15 +- .../config/configured_rule.php | 31 +++ .../InjectAnnotationClassRectorTest.php | 14 +- .../config/configured_rule.php | 13 + .../Rector/RectorOrder/RectorOrderTest.php | 15 +- .../RectorOrder/config/configured_rule.php | 10 + .../AddTopIncludeRectorTest.php | 12 +- .../config/configured_rule.php | 10 + .../NetteTesterPHPUnitRectorTest.php | 12 +- .../config/configured_rule.php | 9 + .../PhpSpecToPHPUnitRectorTest.php | 21 +- .../config/configured_rule.php | 16 ++ .../ReservedObjectRectorTest.php | 15 +- .../config/configured_rule.php | 13 + .../ReservedFnFunctionRectorTest.php | 15 +- .../config/configured_rule.php | 13 + .../AddLiteralSeparatorToNumberRectorTest.php | 12 +- .../config/configured_rule.php | 10 + .../ClassLikeTypesOnlyTest.php | 12 +- .../DoctrineTypedPropertyRectorTest.php | 12 +- .../TypedPropertyRectorTest.php | 12 +- .../config/class_types_only.php | 10 + .../config/configured_rule.php | 10 + ... => ArrayArgumentToDataProviderRector.php} | 4 +- ...ArgumentInTestToDataProviderRectorTest.php | 46 ---- .../ArrayArgumentToDataProviderRectorTest.php | 30 +++ .../Fixture/fixture.php.inc | 4 +- .../Fixture/two_arguments.php.inc | 4 +- .../Fixture/various_types.php.inc | 4 +- .../config/configured_rule.php | 22 ++ ...nitStaticToKernelTestCaseGetRectorTest.php | 13 +- .../config/configured_rule.php | 15 ++ .../PassFactoryToEntityRectorTest.php | 19 +- .../config/configured_rule.php | 24 ++ .../StaticTypeToSetterInjectionRectorTest.php | 18 +- .../config/configured_rule.php | 14 ++ .../ArgumentRemoverRectorTest.php | 27 +-- .../config/configured_rule.php | 47 ++++ .../RemoveInterfacesRectorTest.php | 13 +- .../config/configured_rule.php | 12 + .../RemoveParentRectorTest.php | 13 +- .../config/configured_rule.php | 12 + .../RemoveTraitRectorTest.php | 13 +- .../config/configured_rule.php | 12 + .../RemoveFuncCallArgRectorTest.php | 15 +- .../config/configured_rule.php | 55 +++++ .../RemoveFuncCallRectorTest.php | 20 +- .../config/configured_rule.php | 34 +++ .../RenameClassConstFetchRectorTest.php | 26 +- .../config/configured_rule.php | 75 ++++++ .../RenameAnnotationRectorTest.php | 15 +- .../config/configured_rule.php | 59 +++++ .../RenameConstantRectorTest.php | 15 +- .../config/configured_rule.php | 13 + .../PseudoNamespaceToNamespaceRectorTest.php | 19 +- .../config/configured_rule.php | 71 ++++++ .../RenameFunctionRectorTest.php | 15 +- .../config/configured_rule.php | 13 + .../RenameMethodRectorTest.php | 24 +- .../config/configured_rule.php | 30 +++ .../AutoImportNamesParameter74Test.php | 22 +- .../AutoImportNamesParameterTest.php | 22 +- .../FunctionAutoImportNamesParameterTest.php | 16 +- .../RenameClassRectorTest.php | 42 +--- .../RenameClassRector/RenameNonPhpTest.php | 20 +- .../config/auto_import_names.php | 25 ++ .../config/configured_rule.php | 42 ++++ .../config/non_php_config.php | 20 ++ .../RenameNamespaceRectorTest.php | 17 +- .../config/configured_rule.php | 15 ++ .../RenamePropertyRectorTest.php | 17 +- .../config/configured_rule.php | 64 +++++ .../RenameStaticMethodRectorTest.php | 23 +- .../config/configured_rule.php | 66 +++++ .../RenameStringRectorTest.php | 15 +- .../config/configured_rule.php | 12 + ...mpleteImportForPartialAnnotationRector.php | 28 ++- ...=> CompleteImportForPartialAnnotation.php} | 2 +- .../config/configured_rule.php | 12 +- ...teImportForPartialAnnotationRectorTest.php | 15 +- .../config/configured_rule.php | 17 ++ ...mpleteMissingDependencyInNewRectorTest.php | 15 +- .../config/configured_rule.php | 12 + ...leLoaderInExtensionAndKernelRectorTest.php | 13 +- .../config/configured_rule.php | 16 ++ .../GetToConstructorInjectionRectorTest.php | 16 +- .../config/configured_rule.php | 18 ++ ...nerGetToConstructorInjectionRectorTest.php | 21 +- .../config/configured_rule.php | 24 ++ ...r.php => ClassConstFetchToValueRector.php} | 4 +- .../FuncCall/FuncCallToMethodCallRector.php | 8 +- .../UnsetAndIssetToMethodCallRector.php | 10 +- ...dCallName.php => FuncCallToMethodCall.php} | 2 +- ...Call.php => UnsetAndIssetToMethodCall.php} | 2 +- .../DimFetchAssignToMethodCallRectorTest.php | 19 +- .../config/configured_rule.php | 59 +++++ .../GetAndSetToMethodCallRectorTest.php | 22 +- .../config/configured_rule.php | 18 ++ .../PropertyAssignToMethodCallRectorTest.php | 16 +- .../config/configured_rule.php | 59 +++++ .../PropertyFetchToMethodCallRectorTest.php | 23 +- .../config/configured_rule.php | 42 ++++ .../ClassConstFetchToStringRectorTest.php | 43 ---- .../ClassConstFetchToValueRectorTest.php | 30 +++ .../Fixture/fixture.php.inc | 8 +- .../Source/OldClassWithConstants.php | 2 +- .../config/configured_rule.php | 19 ++ .../ParentClassToTraitsRectorTest.php | 20 +- .../config/configured_rule.php | 40 ++++ .../MethodCallToReturnRectorTest.php | 14 +- .../config/configured_rule.php | 58 +++++ ...ArgumentFuncCallToMethodCallRectorTest.php | 27 +-- .../config/configured_rule.php | 27 +++ .../FuncCallToMethodCallRectorTest.php | 22 +- .../config/configured_rule.php | 23 ++ .../FuncCallToNewRectorTest.php | 14 +- .../config/configured_rule.php | 12 + .../FuncCallToStaticCallRectorTest.php | 16 +- .../config/configured_rule.php | 60 +++++ .../UnsetAndIssetToMethodCallRectorTest.php | 16 +- .../config/configured_rule.php | 20 ++ ...llableInMethodCallToVariableRectorTest.php | 16 +- .../config/configured_rule.php | 69 ++++++ ...otherMethodCallWithArgumentsRectorTest.php | 21 +- .../config/configured_rule.php | 45 ++++ .../MethodCallToPropertyFetchRectorTest.php | 14 +- .../config/configured_rule.php | 12 + .../MethodCallToStaticCallRectorTest.php | 16 +- .../config/configured_rule.php | 60 +++++ ...laceParentCallByPropertyCallRectorTest.php | 20 +- .../config/configured_rule.php | 69 ++++++ ...GetterToConstructorInjectionRectorTest.php | 21 +- .../config/configured_rule.php | 69 ++++++ ...iableMethodCallToServiceCallRectorTest.php | 21 +- .../config/configured_rule.php | 71 ++++++ .../NewArgToMethodCallRectorTest.php | 16 +- .../config/configured_rule.php | 18 +- .../NewToConstructorInjectionRectorTest.php | 13 +- .../Php80Test.php | 13 +- .../config/configured_rule.php | 12 + .../NewToMethodCallRectorTest.php | 17 +- .../config/configured_rule.php | 59 +++++ .../NewToStaticCallRectorTest.php | 17 +- .../config/configured_rule.php | 59 +++++ .../StaticCallToFuncCallRectorTest.php | 16 +- .../config/configured_rule.php | 59 +++++ .../InvalidConfigurationTest.php | 47 ---- .../StaticCallToMethodCallRectorTest.php | 26 +- .../config/configured_rule.php | 30 +++ .../StaticCallToNewRectorTest.php | 17 +- .../config/configured_rule.php | 58 +++++ .../StringToClassConstantRectorTest.php | 16 +- .../config/configured_rule.php | 60 +++++ .../ToStringToMethodCallRectorTest.php | 15 +- .../config/configured_rule.php | 12 + .../AddParamTypeDeclarationRectorTest.php | 32 +-- .../config/configured_rule.php | 82 +++++++ .../AddReturnTypeDeclarationRectorTest.php | 46 +--- .../config/configured_rule.php | 49 ++++ .../ChangeConstantVisibilityRector.php | 8 +- ...hange.php => ChangeConstantVisibility.php} | 2 +- .../ChangeConstantVisibilityRectorTest.php | 32 +-- .../config/configured_rule.php | 30 +++ .../ChangeMethodVisibilityRectorTest.php | 20 +- .../config/configured_rule.php | 42 ++++ .../ChangePropertyVisibilityRectorTest.php | 24 +- .../config/configured_rule.php | 20 ++ 240 files changed, 3496 insertions(+), 2216 deletions(-) create mode 100644 "Abc\\FqnizeNamespaced," create mode 100644 "MyNamespace\\MyNewClass," create mode 100644 "MyNewNamespace\\MyNewClass," create mode 100644 "MyNewNamespace\\MyNewInterface," create mode 100644 "MyNewNamespace\\MyNewTrait," create mode 100644 "Twig\\Extension\\SandboxExtension," create mode 100644 rules/autodiscovery/tests/Rector/FileNode/MoveServicesBySuffixToDirectoryRector/config/configured_rule.php create mode 100644 rules/autodiscovery/tests/Rector/FileNode/MoveValueObjectsToValueObjectDirectoryRector/config/configured_rule.php create mode 100644 rules/cakephp/tests/Rector/MethodCall/ArrayToFluentCallRector/config/configured_rule.php create mode 100644 rules/cakephp/tests/Rector/MethodCall/ModalToGetSetRector/config/configured_rule.php create mode 100644 rules/cakephp/tests/Rector/MethodCall/RenameMethodCallBasedOnParameterRector/config/configured_rule.php create mode 100644 rules/coding-style/tests/Rector/ClassMethod/ReturnArrayClassMethodToYieldRector/config/configured_rule.php create mode 100644 rules/coding-style/tests/Rector/ClassMethod/YieldClassMethodToArrayClassMethodRector/config/configured_rule.php create mode 100644 rules/coding-style/tests/Rector/FuncCall/FunctionCallToConstantRector/config/configured_rule.php create mode 100644 rules/coding-style/tests/Rector/MethodCall/PreferThisOrSelfMethodCallRector/config/configured_rule.php delete mode 100644 rules/core/src/Rector/ClassMethod/GetRectorsWithConfigurationToProvideConfigFileInfoRector.php delete mode 100644 rules/core/tests/Rector/ClassMethod/GetRectorsWithConfigurationToProvideConfigFileInfoRector/Fixture/some_class.php.inc delete mode 100644 rules/core/tests/Rector/ClassMethod/GetRectorsWithConfigurationToProvideConfigFileInfoRector/GetRectorsWithConfigurationToProvideConfigFileInfoRectorTest.php create mode 100644 rules/dead-doc-block/tests/Rector/ClassLike/RemoveAnnotationRector/config/configured_rule.php create mode 100644 rules/dependency-injection/tests/Rector/Class_/MultiParentingToAbstractDependencyRector/config/nette_config.php create mode 100644 rules/dependency-injection/tests/Rector/Class_/MultiParentingToAbstractDependencyRector/config/symfony_config.php create mode 100644 rules/doctrine-code-quality/tests/Rector/DoctrineRepositoryAsService/config/configured_rule.php create mode 100644 rules/doctrine/tests/Rector/Class_/AddEntityIdByConditionRector/config/configured_rule.php create mode 100644 rules/doctrine/tests/Rector/MethodCall/EntityAliasToClassConstantReferenceRector/config/configured_rule.php create mode 100644 rules/generic/tests/Rector/ClassMethod/AddMethodParentCallRector/config/configured_rule.php create mode 100644 rules/generic/tests/Rector/ClassMethod/ArgumentAdderRector/config/configured_rule.php create mode 100644 rules/generic/tests/Rector/ClassMethod/ArgumentDefaultValueReplacerRector/config/configured_rule.php create mode 100644 rules/generic/tests/Rector/ClassMethod/NormalToFluentRector/config/configured_rule.php create mode 100644 rules/generic/tests/Rector/ClassMethod/SingleToManyMethodRector/config/configured_rule.php create mode 100644 rules/generic/tests/Rector/ClassMethod/WrapReturnRector/config/configured_rule.php create mode 100644 rules/generic/tests/Rector/Class_/AddInterfaceByTraitRector/config/configured_rule.php create mode 100644 rules/generic/tests/Rector/Class_/AddPropertyByParentRector/config/configured_rule.php create mode 100644 rules/generic/tests/Rector/Class_/MergeInterfacesRector/config/configured_rule.php create mode 100644 rules/generic/tests/Rector/FuncCall/SwapFuncCallArgumentsRector/config/configured_rule.php create mode 100644 rules/generic/tests/Rector/Property/InjectAnnotationClassRector/config/configured_rule.php create mode 100644 rules/generic/tests/Rector/RectorOrder/config/configured_rule.php create mode 100644 rules/legacy/tests/Rector/FileWithoutNamespace/AddTopIncludeRector/config/configured_rule.php create mode 100644 rules/nette-tester-to-phpunit/tests/Rector/Class_/NetteTesterClassToPHPUnitClassRector/config/configured_rule.php create mode 100644 rules/php-spec-to-phpunit/tests/Rector/Variable/PhpSpecToPHPUnitRector/config/configured_rule.php create mode 100644 rules/php71/tests/Rector/Name/ReservedObjectRector/config/configured_rule.php create mode 100644 rules/php74/tests/Rector/Function_/ReservedFnFunctionRector/config/configured_rule.php create mode 100644 rules/php74/tests/Rector/LNumber/AddLiteralSeparatorToNumberRector/config/configured_rule.php create mode 100644 rules/php74/tests/Rector/Property/TypedPropertyRector/config/class_types_only.php create mode 100644 rules/php74/tests/Rector/Property/TypedPropertyRector/config/configured_rule.php rename rules/phpunit/src/Rector/Class_/{ArrayArgumentInTestToDataProviderRector.php => ArrayArgumentToDataProviderRector.php} (97%) delete mode 100644 rules/phpunit/tests/Rector/Class_/ArrayArgumentInTestToDataProviderRector/ArrayArgumentInTestToDataProviderRectorTest.php create mode 100644 rules/phpunit/tests/Rector/Class_/ArrayArgumentToDataProviderRector/ArrayArgumentToDataProviderRectorTest.php rename rules/phpunit/tests/Rector/Class_/{ArrayArgumentInTestToDataProviderRector => ArrayArgumentToDataProviderRector}/Fixture/fixture.php.inc (72%) rename rules/phpunit/tests/Rector/Class_/{ArrayArgumentInTestToDataProviderRector => ArrayArgumentToDataProviderRector}/Fixture/two_arguments.php.inc (73%) rename rules/phpunit/tests/Rector/Class_/{ArrayArgumentInTestToDataProviderRector => ArrayArgumentToDataProviderRector}/Fixture/various_types.php.inc (74%) create mode 100644 rules/phpunit/tests/Rector/Class_/ArrayArgumentToDataProviderRector/config/configured_rule.php create mode 100644 rules/removing-static/tests/Rector/Class_/PHPUnitStaticToKernelTestCaseGetRector/config/configured_rule.php create mode 100644 rules/removing-static/tests/Rector/Class_/PassFactoryToEntityRector/config/configured_rule.php create mode 100644 rules/removing-static/tests/Rector/Class_/StaticTypeToSetterInjectionRector/config/configured_rule.php create mode 100644 rules/removing/tests/Rector/ClassMethod/ArgumentRemoverRector/config/configured_rule.php create mode 100644 rules/removing/tests/Rector/Class_/RemoveInterfacesRector/config/configured_rule.php create mode 100644 rules/removing/tests/Rector/Class_/RemoveParentRector/config/configured_rule.php create mode 100644 rules/removing/tests/Rector/Class_/RemoveTraitRector/config/configured_rule.php create mode 100644 rules/removing/tests/Rector/FuncCall/RemoveFuncCallArgRector/config/configured_rule.php create mode 100644 rules/removing/tests/Rector/FuncCall/RemoveFuncCallRector/config/configured_rule.php create mode 100644 rules/renaming/tests/Rector/ClassConstFetch/RenameClassConstFetchRector/config/configured_rule.php create mode 100644 rules/renaming/tests/Rector/ClassMethod/RenameAnnotationRector/config/configured_rule.php create mode 100644 rules/renaming/tests/Rector/ConstFetch/RenameConstantRector/config/configured_rule.php create mode 100644 rules/renaming/tests/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/config/configured_rule.php create mode 100644 rules/renaming/tests/Rector/FuncCall/RenameFunctionRector/config/configured_rule.php create mode 100644 rules/renaming/tests/Rector/MethodCall/RenameMethodRector/config/configured_rule.php create mode 100644 rules/renaming/tests/Rector/Name/RenameClassRector/config/auto_import_names.php create mode 100644 rules/renaming/tests/Rector/Name/RenameClassRector/config/configured_rule.php create mode 100644 rules/renaming/tests/Rector/Name/RenameClassRector/config/non_php_config.php create mode 100644 rules/renaming/tests/Rector/Namespace_/RenameNamespaceRector/config/configured_rule.php create mode 100644 rules/renaming/tests/Rector/PropertyFetch/RenamePropertyRector/config/configured_rule.php create mode 100644 rules/renaming/tests/Rector/StaticCall/RenameStaticMethodRector/config/configured_rule.php create mode 100644 rules/renaming/tests/Rector/String_/RenameStringRector/config/configured_rule.php rename rules/restoration/src/ValueObject/{UseWithAlias.php => CompleteImportForPartialAnnotation.php} (91%) create mode 100644 rules/restoration/tests/Rector/Namespace_/CompleteImportForPartialAnnotationRector/config/configured_rule.php create mode 100644 rules/restoration/tests/Rector/New_/CompleteMissingDependencyInNewRector/config/configured_rule.php create mode 100644 rules/symfony/tests/Rector/Class_/ChangeFileLoaderInExtensionAndKernelRector/config/configured_rule.php create mode 100644 rules/symfony/tests/Rector/MethodCall/GetToConstructorInjectionRector/config/configured_rule.php create mode 100644 rules/symfony4/tests/Rector/MethodCall/ContainerGetToConstructorInjectionRector/config/configured_rule.php rename rules/transform/src/Rector/ClassConstFetch/{ClassConstFetchToStringRector.php => ClassConstFetchToValueRector.php} (94%) rename rules/transform/src/ValueObject/{FuncNameToMethodCallName.php => FuncCallToMethodCall.php} (95%) rename rules/transform/src/ValueObject/{IssetUnsetToMethodCall.php => UnsetAndIssetToMethodCall.php} (95%) create mode 100644 rules/transform/tests/Rector/Assign/DimFetchAssignToMethodCallRector/config/configured_rule.php create mode 100644 rules/transform/tests/Rector/Assign/GetAndSetToMethodCallRector/config/configured_rule.php create mode 100644 rules/transform/tests/Rector/Assign/PropertyAssignToMethodCallRector/config/configured_rule.php create mode 100644 rules/transform/tests/Rector/Assign/PropertyFetchToMethodCallRector/config/configured_rule.php delete mode 100644 rules/transform/tests/Rector/ClassConstFetch/ClassConstFetchToStringRector/ClassConstFetchToStringRectorTest.php create mode 100644 rules/transform/tests/Rector/ClassConstFetch/ClassConstFetchToValueRector/ClassConstFetchToValueRectorTest.php rename rules/transform/tests/Rector/ClassConstFetch/{ClassConstFetchToStringRector => ClassConstFetchToValueRector}/Fixture/fixture.php.inc (77%) rename rules/transform/tests/Rector/ClassConstFetch/{ClassConstFetchToStringRector => ClassConstFetchToValueRector}/Source/OldClassWithConstants.php (90%) create mode 100644 rules/transform/tests/Rector/ClassConstFetch/ClassConstFetchToValueRector/config/configured_rule.php create mode 100644 rules/transform/tests/Rector/Class_/ParentClassToTraitsRector/config/configured_rule.php create mode 100644 rules/transform/tests/Rector/Expression/MethodCallToReturnRector/config/configured_rule.php create mode 100644 rules/transform/tests/Rector/FuncCall/ArgumentFuncCallToMethodCallRector/config/configured_rule.php create mode 100644 rules/transform/tests/Rector/FuncCall/FuncCallToMethodCallRector/config/configured_rule.php create mode 100644 rules/transform/tests/Rector/FuncCall/FuncCallToNewRector/config/configured_rule.php create mode 100644 rules/transform/tests/Rector/FuncCall/FuncCallToStaticCallRector/config/configured_rule.php create mode 100644 rules/transform/tests/Rector/Isset_/UnsetAndIssetToMethodCallRector/config/configured_rule.php create mode 100644 rules/transform/tests/Rector/MethodCall/CallableInMethodCallToVariableRector/config/configured_rule.php create mode 100644 rules/transform/tests/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector/config/configured_rule.php create mode 100644 rules/transform/tests/Rector/MethodCall/MethodCallToPropertyFetchRector/config/configured_rule.php create mode 100644 rules/transform/tests/Rector/MethodCall/MethodCallToStaticCallRector/config/configured_rule.php create mode 100644 rules/transform/tests/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/config/configured_rule.php create mode 100644 rules/transform/tests/Rector/MethodCall/ServiceGetterToConstructorInjectionRector/config/configured_rule.php create mode 100644 rules/transform/tests/Rector/MethodCall/VariableMethodCallToServiceCallRector/config/configured_rule.php create mode 100644 rules/transform/tests/Rector/New_/NewToConstructorInjectionRector/config/configured_rule.php create mode 100644 rules/transform/tests/Rector/New_/NewToMethodCallRector/config/configured_rule.php create mode 100644 rules/transform/tests/Rector/New_/NewToStaticCallRector/config/configured_rule.php create mode 100644 rules/transform/tests/Rector/StaticCall/StaticCallToFuncCallRector/config/configured_rule.php delete mode 100644 rules/transform/tests/Rector/StaticCall/StaticCallToMethodCallRector/InvalidConfigurationTest.php create mode 100644 rules/transform/tests/Rector/StaticCall/StaticCallToMethodCallRector/config/configured_rule.php create mode 100644 rules/transform/tests/Rector/StaticCall/StaticCallToNewRector/config/configured_rule.php create mode 100644 rules/transform/tests/Rector/String_/StringToClassConstantRector/config/configured_rule.php create mode 100644 rules/transform/tests/Rector/String_/ToStringToMethodCallRector/config/configured_rule.php create mode 100644 rules/type-declaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/config/configured_rule.php create mode 100644 rules/type-declaration/tests/Rector/ClassMethod/AddReturnTypeDeclarationRector/config/configured_rule.php rename rules/visibility/src/ValueObject/{ClassConstantVisibilityChange.php => ChangeConstantVisibility.php} (94%) create mode 100644 rules/visibility/tests/Rector/ClassConst/ChangeConstantVisibilityRector/config/configured_rule.php create mode 100644 rules/visibility/tests/Rector/ClassMethod/ChangeMethodVisibilityRector/config/configured_rule.php create mode 100644 rules/visibility/tests/Rector/Property/ChangePropertyVisibilityRector/config/configured_rule.php diff --git "a/Abc\\FqnizeNamespaced," "b/Abc\\FqnizeNamespaced," new file mode 100644 index 000000000000..4089590f3d48 --- /dev/null +++ "b/Abc\\FqnizeNamespaced," @@ -0,0 +1,3 @@ +PHPUnit 9.5.2 by Sebastian Bergmann and contributors. + +Cannot open file "FqnizeNamespaced". diff --git "a/MyNamespace\\MyNewClass," "b/MyNamespace\\MyNewClass," new file mode 100644 index 000000000000..e69de29bb2d1 diff --git "a/MyNewNamespace\\MyNewClass," "b/MyNewNamespace\\MyNewClass," new file mode 100644 index 000000000000..e69de29bb2d1 diff --git "a/MyNewNamespace\\MyNewInterface," "b/MyNewNamespace\\MyNewInterface," new file mode 100644 index 000000000000..e69de29bb2d1 diff --git "a/MyNewNamespace\\MyNewTrait," "b/MyNewNamespace\\MyNewTrait," new file mode 100644 index 000000000000..e69de29bb2d1 diff --git "a/Twig\\Extension\\SandboxExtension," "b/Twig\\Extension\\SandboxExtension," new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/composer.json b/composer.json index 16cdf1cc4131..c533771b47da 100644 --- a/composer.json +++ b/composer.json @@ -96,7 +96,7 @@ "Rector\\CodeQuality\\": "rules/code-quality/src", "Rector\\CodingStyle\\": "rules/coding-style/src", "Rector\\Composer\\": "rules/composer/src", - "Rector\\Core\\": ["src", "rules/core/src"], + "Rector\\Core\\": "src", "Rector\\DeadCode\\": "rules/dead-code/src", "Rector\\DependencyInjection\\": "rules/dependency-injection/src", "Rector\\EarlyReturn\\": "rules/early-return/src", diff --git a/config/set/downgrade-php71.php b/config/set/downgrade-php71.php index 8a89b2f022f5..c3137f8af3c2 100644 --- a/config/set/downgrade-php71.php +++ b/config/set/downgrade-php71.php @@ -27,6 +27,7 @@ // skip classes used in PHP DocBlocks, like in /** @var \Some\Class */ [default: true] $parameters->set(Option::IMPORT_DOC_BLOCKS, false); + $services->set(DowngradeClassConstantVisibilityRector::class); $services->set(DowngradePipeToMultiCatchExceptionRector::class); $services->set(SymmetricArrayDestructuringToListRector::class); diff --git a/config/set/downgrade-php72.php b/config/set/downgrade-php72.php index 3477251f18e1..194aadc52404 100644 --- a/config/set/downgrade-php72.php +++ b/config/set/downgrade-php72.php @@ -22,5 +22,6 @@ // skip classes used in PHP DocBlocks, like in /** @var \Some\Class */ [default: true] $parameters->set(Option::IMPORT_DOC_BLOCKS, false); + $services->set(DowngradeParameterTypeWideningRector::class); }; diff --git a/config/set/downgrade-php73.php b/config/set/downgrade-php73.php index c5214c4cca19..992d09381e81 100644 --- a/config/set/downgrade-php73.php +++ b/config/set/downgrade-php73.php @@ -23,6 +23,7 @@ // skip classes used in PHP DocBlocks, like in /** @var \Some\Class */ [default: true] $parameters->set(Option::IMPORT_DOC_BLOCKS, false); + $services->set(DowngradeTrailingCommasInFunctionCallsRector::class); $services->set(SetCookieOptionsArrayToArgumentsRector::class); }; diff --git a/config/set/downgrade-php74.php b/config/set/downgrade-php74.php index 3ea15adde479..e31849dd06cc 100644 --- a/config/set/downgrade-php74.php +++ b/config/set/downgrade-php74.php @@ -37,6 +37,7 @@ // skip classes used in PHP DocBlocks, like in /** @var \Some\Class */ [default: true] $parameters->set(Option::IMPORT_DOC_BLOCKS, false); + $services->set(DowngradeFreadFwriteFalsyToNegationRector::class); $services->set(DowngradeReturnSelfTypeDeclarationRector::class); }; diff --git a/config/set/downgrade-php80.php b/config/set/downgrade-php80.php index 496181c7f97d..a85759b4e464 100644 --- a/config/set/downgrade-php80.php +++ b/config/set/downgrade-php80.php @@ -35,6 +35,7 @@ // skip classes used in PHP DocBlocks, like in /** @var \Some\Class */ [default: true] $parameters->set(Option::IMPORT_DOC_BLOCKS, false); + $services->set(DowngradePropertyPromotionRector::class); $services->set(DowngradeNonCapturingCatchesRector::class); $services->set(DowngradeMatchToSwitchRector::class); diff --git a/config/set/guzzle50.php b/config/set/guzzle50.php index 92846b6eeadc..938d87aaf452 100644 --- a/config/set/guzzle50.php +++ b/config/set/guzzle50.php @@ -7,7 +7,7 @@ use Rector\Renaming\ValueObject\MethodCallRename; use Rector\Transform\Rector\FuncCall\FuncCallToMethodCallRector; use Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector; -use Rector\Transform\ValueObject\FuncNameToMethodCallName; +use Rector\Transform\ValueObject\FuncCallToMethodCall; use Rector\Transform\ValueObject\StaticCallToFuncCall; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symplify\SymfonyPhpConfig\ValueObjectInliner; @@ -19,8 +19,8 @@ $services->set(FluentChainMethodCallToNormalMethodCallRector::class); $configuration = [ - new FuncNameToMethodCallName('GuzzleHttp\json_decode', 'GuzzleHttp\Utils', 'jsonDecode'), - new FuncNameToMethodCallName('GuzzleHttp\get_path', 'GuzzleHttp\Utils', 'getPath'), + new FuncCallToMethodCall('GuzzleHttp\json_decode', 'GuzzleHttp\Utils', 'jsonDecode'), + new FuncCallToMethodCall('GuzzleHttp\get_path', 'GuzzleHttp\Utils', 'getPath'), ]; $services->set(FuncCallToMethodCallRector::class) diff --git a/docs/rector_rules_overview.md b/docs/rector_rules_overview.md index 4516a4834308..63abea1ce6a9 100644 --- a/docs/rector_rules_overview.md +++ b/docs/rector_rules_overview.md @@ -9544,7 +9544,7 @@ Move array argument from tests into data provider [configurable] - class: `Rector\PHPUnit\Rector\Class_\ArrayArgumentInTestToDataProviderRector` ```php -use Rector\PHPUnit\Rector\Class_\ArrayArgumentInTestToDataProviderRector; +use Rector\PHPUnit\Rector\Class_\ArrayArgumentToDataProviderRector; use Rector\PHPUnit\ValueObject\ArrayArgumentToDataProvider; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symplify\SymfonyPhpConfig\ValueObjectInliner; @@ -9552,9 +9552,9 @@ use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); - $services->set(ArrayArgumentInTestToDataProviderRector::class) + $services->set(ArrayArgumentToDataProviderRector::class) ->call('configure', [[ - ArrayArgumentInTestToDataProviderRector::ARRAY_ARGUMENTS_TO_DATA_PROVIDERS => ValueObjectInliner::inline([ + ArrayArgumentToDataProviderRector::ARRAY_ARGUMENTS_TO_DATA_PROVIDERS => ValueObjectInliner::inline([ new ArrayArgumentToDataProvider('PHPUnit\Framework\TestCase', 'doTestMultiple', 'doTestSingle', 'number'), ]), ]]); @@ -13868,7 +13868,7 @@ In case you have accidentally removed use imports but code still contains partia ```php use Rector\Restoration\Rector\Namespace_\CompleteImportForPartialAnnotationRector; -use Rector\Restoration\ValueObject\UseWithAlias; +use Rector\Restoration\ValueObject\CompleteImportForPartialAnnotation; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symplify\SymfonyPhpConfig\ValueObjectInliner; @@ -13878,7 +13878,7 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services->set(CompleteImportForPartialAnnotationRector::class) ->call('configure', [[ CompleteImportForPartialAnnotationRector::USE_IMPORTS_TO_RESTORE => ValueObjectInliner::inline([ - new UseWithAlias('Doctrine\ORM\Mapping', 'ORM'), + new CompleteImportForPartialAnnotation('Doctrine\ORM\Mapping', 'ORM'), ]), ]]); }; @@ -15411,7 +15411,7 @@ Replaces constant by value - class: `Rector\Transform\Rector\ClassConstFetch\ClassConstFetchToStringRector` ```php -use Rector\Transform\Rector\ClassConstFetch\ClassConstFetchToStringRector; +use Rector\Transform\Rector\ClassConstFetch\ClassConstFetchToValueRector; use Rector\Transform\ValueObject\ClassConstFetchToValue; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symplify\SymfonyPhpConfig\ValueObjectInliner; @@ -15419,9 +15419,9 @@ use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); - $services->set(ClassConstFetchToStringRector::class) + $services->set(ClassConstFetchToValueRector::class) ->call('configure', [[ - ClassConstFetchToStringRector::CLASS_CONST_FETCHES_TO_VALUES => ValueObjectInliner::inline([ + ClassConstFetchToValueRector::CLASS_CONST_FETCHES_TO_VALUES => ValueObjectInliner::inline([ new ClassConstFetchToValue('Nette\Configurator', 'DEVELOPMENT', 'development'), new ClassConstFetchToValue('Nette\Configurator', 'PRODUCTION', 'production'), ]), @@ -15493,7 +15493,7 @@ Turns defined function calls to local method calls. ```php use Rector\Transform\Rector\FuncCall\FuncCallToMethodCallRector; -use Rector\Transform\ValueObject\FuncNameToMethodCallName; +use Rector\Transform\ValueObject\FuncCallToMethodCall; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symplify\SymfonyPhpConfig\ValueObjectInliner; @@ -15503,7 +15503,7 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services->set(FuncCallToMethodCallRector::class) ->call('configure', [[ FuncCallToMethodCallRector::FUNC_CALL_TO_CLASS_METHOD_CALL => ValueObjectInliner::inline([ - new FuncNameToMethodCallName('view', 'Namespaced\SomeRenderer', 'render'), + new FuncCallToMethodCall('view', 'Namespaced\SomeRenderer', 'render'), ]), ]]); }; @@ -16488,7 +16488,7 @@ Turns defined `__isset`/`__unset` calls to specific method calls. ```php use Rector\Transform\Rector\Isset_\UnsetAndIssetToMethodCallRector; -use Rector\Transform\ValueObject\IssetUnsetToMethodCall; +use Rector\Transform\ValueObject\UnsetAndIssetToMethodCall; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symplify\SymfonyPhpConfig\ValueObjectInliner; @@ -16498,7 +16498,7 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services->set(UnsetAndIssetToMethodCallRector::class) ->call('configure', [[ UnsetAndIssetToMethodCallRector::ISSET_UNSET_TO_METHOD_CALL => ValueObjectInliner::inline([ - new IssetUnsetToMethodCall('SomeContainer', 'hasService', 'removeService'), + new UnsetAndIssetToMethodCall('SomeContainer', 'hasService', 'removeService'), ]), ]]); }; @@ -16516,7 +16516,7 @@ return static function (ContainerConfigurator $containerConfigurator): void { ```php use Rector\Transform\Rector\Isset_\UnsetAndIssetToMethodCallRector; -use Rector\Transform\ValueObject\IssetUnsetToMethodCall; +use Rector\Transform\ValueObject\UnsetAndIssetToMethodCall; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symplify\SymfonyPhpConfig\ValueObjectInliner; @@ -16526,7 +16526,7 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services->set(UnsetAndIssetToMethodCallRector::class) ->call('configure', [[ UnsetAndIssetToMethodCallRector::ISSET_UNSET_TO_METHOD_CALL => ValueObjectInliner::inline([ - new IssetUnsetToMethodCall('SomeContainer', 'hasService', 'removeService'), + new UnsetAndIssetToMethodCall('SomeContainer', 'hasService', 'removeService'), ]), ]]); }; @@ -16967,7 +16967,7 @@ Change visibility of constant from parent class. ```php use Rector\Visibility\Rector\ClassConst\ChangeConstantVisibilityRector; -use Rector\Visibility\ValueObject\ClassConstantVisibilityChange; +use Rector\Visibility\ValueObject\ChangeConstantVisibility; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symplify\SymfonyPhpConfig\ValueObjectInliner; @@ -16977,7 +16977,7 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services->set(ChangeConstantVisibilityRector::class) ->call('configure', [[ ChangeConstantVisibilityRector::CLASS_CONSTANT_VISIBILITY_CHANGES => ValueObjectInliner::inline([ - new ClassConstantVisibilityChange('ParentObject', 'SOME_CONSTANT', 2), + new ChangeConstantVisibility('ParentObject', 'SOME_CONSTANT', 2), ]), ]]); }; diff --git a/packages/rector-generator/templates/rules/__package__/tests/Rector/__Category__/__Name__/__Configured__Extra__Name__Test.php.inc b/packages/rector-generator/templates/rules/__package__/tests/Rector/__Category__/__Name__/__Configured__Extra__Name__Test.php.inc index 2e24025658d5..fe5d54fa559a 100644 --- a/packages/rector-generator/templates/rules/__package__/tests/Rector/__Category__/__Name__/__Configured__Extra__Name__Test.php.inc +++ b/packages/rector-generator/templates/rules/__package__/tests/Rector/__Category__/__Name__/__Configured__Extra__Name__Test.php.inc @@ -5,6 +5,7 @@ declare(strict_types=1); namespace Rector\__Package__\Tests\Rector\__Category__\__Name__; use Rector\Testing\PHPUnit\AbstractRectorTestCase; +use Symplify\SmartFileSystem\SmartFileInfo; final class __Name__Test extends AbstractRectorTestCase { @@ -22,14 +23,8 @@ final class __Name__Test extends AbstractRectorTestCase yield [new \Symplify\SmartFileSystem\SmartFileInfo(__DIR__ . '/Fixture/some_class.php.inc'), '__ExtraFileName__', __DIR__ . '/Source/extra_file.php']; } - /** - * @return mixed[] - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?\Symplify\SmartFileSystem\SmartFileInfo { - return [ - \Rector\__Package__\Rector\__Category__\__Name__::class => - __TestRuleConfiguration__ - ]; + return new \Symplify\SmartFileSystem\SmartFileInfo(__DIR__ . '/configured_rule.php'); } } diff --git a/packages/rector-generator/templates/rules/__package__/tests/Rector/__Category__/__Name__/__Configured__Name__Test.php.inc b/packages/rector-generator/templates/rules/__package__/tests/Rector/__Category__/__Name__/__Configured__Name__Test.php.inc index 997b544fe57d..397e316d8343 100644 --- a/packages/rector-generator/templates/rules/__package__/tests/Rector/__Category__/__Name__/__Configured__Name__Test.php.inc +++ b/packages/rector-generator/templates/rules/__package__/tests/Rector/__Category__/__Name__/__Configured__Name__Test.php.inc @@ -21,14 +21,8 @@ final class __Name__Test extends AbstractRectorTestCase return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return mixed[] - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?\Symplify\SmartFileSystem\SmartFileInfo { - return [ - \Rector\__Package__\Rector\__Category__\__Name__::class => - __TestRuleConfiguration__ - ]; + return new \Symplify\SmartFileSystem\SmartFileInfo(__DIR__ . '/configured_rule.php'); } } diff --git a/packages/rector-generator/tests/RectorGenerator/Fixture/expected/rules/moderate-package/tests/Rector/MethodCall/WhateverRector/WhateverRectorTest.php.inc b/packages/rector-generator/tests/RectorGenerator/Fixture/expected/rules/moderate-package/tests/Rector/MethodCall/WhateverRector/WhateverRectorTest.php.inc index 41c5afa1395d..89ccc774c23a 100644 --- a/packages/rector-generator/tests/RectorGenerator/Fixture/expected/rules/moderate-package/tests/Rector/MethodCall/WhateverRector/WhateverRectorTest.php.inc +++ b/packages/rector-generator/tests/RectorGenerator/Fixture/expected/rules/moderate-package/tests/Rector/MethodCall/WhateverRector/WhateverRectorTest.php.inc @@ -21,14 +21,8 @@ final class WhateverRectorTest extends AbstractRectorTestCase return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return mixed[] - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?\Symplify\SmartFileSystem\SmartFileInfo { - return [ - \Rector\ModeratePackage\Rector\MethodCall\WhateverRector::class => - [\Rector\ModeratePackage\Rector\MethodCall\WhateverRector::CLASS_TYPE_TO_METHOD_NAME => ['SomeClass' => 'configure']] - ]; + return new \Symplify\SmartFileSystem\SmartFileInfo(__DIR__ . '/configured_rule.php'); } } diff --git a/packages/rector-generator/tests/RectorGenerator/Fixture/expected_3rd_party/utils/rector/tests/Rector/MethodCall/WhateverRector/WhateverRectorTest.php.inc b/packages/rector-generator/tests/RectorGenerator/Fixture/expected_3rd_party/utils/rector/tests/Rector/MethodCall/WhateverRector/WhateverRectorTest.php.inc index 947b75d84c56..e6d6589e1826 100644 --- a/packages/rector-generator/tests/RectorGenerator/Fixture/expected_3rd_party/utils/rector/tests/Rector/MethodCall/WhateverRector/WhateverRectorTest.php.inc +++ b/packages/rector-generator/tests/RectorGenerator/Fixture/expected_3rd_party/utils/rector/tests/Rector/MethodCall/WhateverRector/WhateverRectorTest.php.inc @@ -21,14 +21,8 @@ final class WhateverRectorTest extends AbstractRectorTestCase return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return mixed[] - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?\Symplify\SmartFileSystem\SmartFileInfo { - return [ - \Utils\Rector\Rector\MethodCall\WhateverRector::class => - [\Utils\Rector\Rector\MethodCall\WhateverRector::CLASS_TYPE_TO_METHOD_NAME => ['SomeClass' => 'configure']] - ]; + return new \Symplify\SmartFileSystem\SmartFileInfo(__DIR__ . '/configured_rule.php'); } } diff --git a/packages/testing/src/PHPUnit/AbstractRectorTestCase.php b/packages/testing/src/PHPUnit/AbstractRectorTestCase.php index 946b966fb07e..e617c8c6fbc0 100644 --- a/packages/testing/src/PHPUnit/AbstractRectorTestCase.php +++ b/packages/testing/src/PHPUnit/AbstractRectorTestCase.php @@ -20,7 +20,6 @@ use Rector\Core\Stubs\StubLoader; use Rector\Core\ValueObject\PhpVersion; use Rector\Core\ValueObject\StaticNonPhpFileSuffixes; -use Rector\Naming\Tests\Rector\Class_\RenamePropertyToMatchTypeRector\Source\ContainerInterface; use Rector\Testing\Application\EnabledRectorsProvider; use Rector\Testing\Contract\RunnableInterface; use Rector\Testing\Finder\RectorsFinder; @@ -31,8 +30,6 @@ use Rector\Testing\ValueObject\InputFilePathWithExpectedFile; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -use Symfony\Component\DependencyInjection\Container; -use Symfony\Component\HttpKernel\KernelInterface; use Symplify\EasyTesting\DataProvider\StaticFixtureFinder; use Symplify\EasyTesting\DataProvider\StaticFixtureUpdater; use Symplify\EasyTesting\StaticFixtureSplitter; @@ -97,7 +94,7 @@ abstract class AbstractRectorTestCase extends AbstractKernelTestCase protected $originalTempFileInfo; /** - * @var Container|ContainerInterface|null + * @var SmartFileInfo */ protected static $allRectorContainer; @@ -125,7 +122,7 @@ protected function setUp(): void if ($this->provideConfigFileInfo() !== null) { $configFileInfos = $this->resolveConfigs($this->provideConfigFileInfo()); - $this->bootKernelWithConfigInfos(RectorKernel::class, $configFileInfos); + $this->bootKernelWithConfigs(RectorKernel::class, $configFileInfos); $enabledRectorsProvider = $this->getService(EnabledRectorsProvider::class); $enabledRectorsProvider->reset(); @@ -198,31 +195,8 @@ protected function provideConfigFileInfo(): ?SmartFileInfo return null; } - /** - * @deprecated Use config instead, just to narrow 2 ways to add configured config to just 1. Now - * with PHP its easy pick. - * - * @return mixed[] - */ - protected function getRectorsWithConfiguration(): array - { - // can be implemented, has the highest priority - return []; - } - - /** - * @return mixed[] - */ protected function getCurrentTestRectorClassesWithConfiguration(): array { - if ($this->getRectorsWithConfiguration() !== []) { - foreach (array_keys($this->getRectorsWithConfiguration()) as $rectorClass) { - $this->ensureRectorClassIsValid($rectorClass, 'getRectorsWithConfiguration'); - } - - return $this->getRectorsWithConfiguration(); - } - $rectorClass = $this->getRectorClass(); $this->ensureRectorClassIsValid($rectorClass, 'getRectorClass'); @@ -251,37 +225,12 @@ protected function setParameter(string $name, $value): void $parameterProvider->changeParameter($name, $value); } - /** - * @deprecated Will be supported in Symplify 9 - * @param SmartFileInfo[] $configFileInfos - */ - protected function bootKernelWithConfigInfos(string $class, array $configFileInfos): KernelInterface - { - $configFiles = []; - foreach ($configFileInfos as $configFileInfo) { - $configFiles[] = $configFileInfo->getRealPath(); - } - - return $this->bootKernelWithConfigs($class, $configFiles); - } - protected function getPhpVersion(): int { // to be implemented return self::PHP_VERSION_UNDEFINED; } - protected function assertFileMissing(string $temporaryFilePath): void - { - // PHPUnit 9.0 ready - if (method_exists($this, 'assertFileDoesNotExist')) { - $this->assertFileDoesNotExist($temporaryFilePath); - } else { - // PHPUnit 8.0 ready - $this->assertFileNotExists($temporaryFilePath); - } - } - protected function doTestFileInfoWithoutAutoload(SmartFileInfo $fileInfo): void { $this->autoloadTestFixture = false; @@ -518,6 +467,7 @@ private function createContainerWithAllRectors(): void $coreRectorClasses = $rectorsFinder->findCoreRectorClasses(); $listForConfig = []; + foreach ($coreRectorClasses as $rectorClass) { $listForConfig[$rectorClass] = null; } diff --git a/phpstan.neon b/phpstan.neon index e37b172cac7d..908fce6e3022 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -527,3 +527,8 @@ parameters: - '#Trait method "printArrayItem\(\)" should not contain any logic, but only delegate to other class call#' - '#Trait method "makeKeysExplicit\(\)" should not contain any logic, but only delegate to other class call#' + + - + message: '#For complex configuration use value object over array#' + paths: + - '*/config/configured_rule.php' diff --git a/rector.php b/rector.php index 78a417d9eb5b..e56dcd9dbc6b 100644 --- a/rector.php +++ b/rector.php @@ -20,8 +20,6 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); - $services->set(\Rector\Core\Rector\ClassMethod\GetRectorsWithConfigurationToProvideConfigFileInfoRector::class); - $configuration = ValueObjectInliner::inline([ new InferParamFromClassMethodReturn(AbstractRector::class, 'refactor', 'getNodeTypes'), ]); diff --git a/rules/autodiscovery/tests/Rector/FileNode/MoveServicesBySuffixToDirectoryRector/MoveServicesBySuffixToDirectoryRectorTest.php b/rules/autodiscovery/tests/Rector/FileNode/MoveServicesBySuffixToDirectoryRector/MoveServicesBySuffixToDirectoryRectorTest.php index 21569dd3a3a3..dc868e20c653 100644 --- a/rules/autodiscovery/tests/Rector/FileNode/MoveServicesBySuffixToDirectoryRector/MoveServicesBySuffixToDirectoryRectorTest.php +++ b/rules/autodiscovery/tests/Rector/FileNode/MoveServicesBySuffixToDirectoryRector/MoveServicesBySuffixToDirectoryRectorTest.php @@ -5,7 +5,6 @@ namespace Rector\Autodiscovery\Tests\Rector\FileNode\MoveServicesBySuffixToDirectoryRector; use Iterator; -use Rector\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector; use Rector\FileSystemRector\ValueObject\AddedFileWithContent; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -77,20 +76,8 @@ public function provideData(): Iterator ]; } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - MoveServicesBySuffixToDirectoryRector::class => [ - MoveServicesBySuffixToDirectoryRector::GROUP_NAMES_BY_SUFFIX => [ - 'Repository', - 'Command', - 'Mapper', - 'Controller', - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/autodiscovery/tests/Rector/FileNode/MoveServicesBySuffixToDirectoryRector/config/configured_rule.php b/rules/autodiscovery/tests/Rector/FileNode/MoveServicesBySuffixToDirectoryRector/config/configured_rule.php new file mode 100644 index 000000000000..d47f835e5c8d --- /dev/null +++ b/rules/autodiscovery/tests/Rector/FileNode/MoveServicesBySuffixToDirectoryRector/config/configured_rule.php @@ -0,0 +1,18 @@ +services(); + $services->set(\Rector\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector::class)->call( + 'configure', + [[ + \Rector\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector::GROUP_NAMES_BY_SUFFIX => [ + 'Repository', + 'Command', + 'Mapper', + 'Controller', + ], + ]] + ); +}; diff --git a/rules/autodiscovery/tests/Rector/FileNode/MoveValueObjectsToValueObjectDirectoryRector/MoveValueObjectsToValueObjectDirectoryRectorTest.php b/rules/autodiscovery/tests/Rector/FileNode/MoveValueObjectsToValueObjectDirectoryRector/MoveValueObjectsToValueObjectDirectoryRectorTest.php index 509c71e56ce7..4db40e6cc53d 100644 --- a/rules/autodiscovery/tests/Rector/FileNode/MoveValueObjectsToValueObjectDirectoryRector/MoveValueObjectsToValueObjectDirectoryRectorTest.php +++ b/rules/autodiscovery/tests/Rector/FileNode/MoveValueObjectsToValueObjectDirectoryRector/MoveValueObjectsToValueObjectDirectoryRectorTest.php @@ -5,8 +5,6 @@ namespace Rector\Autodiscovery\Tests\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector; use Iterator; -use Rector\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector; -use Rector\Autodiscovery\Tests\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector\Source\ObviousValueObjectInterface; use Rector\FileSystemRector\ValueObject\AddedFileWithContent; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -62,17 +60,8 @@ public function provideData(): Iterator yield [new SmartFileInfo(__DIR__ . '/Source/Utils/SomeSuffixedTest.php.inc'), null]; } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - MoveValueObjectsToValueObjectDirectoryRector::class => [ - MoveValueObjectsToValueObjectDirectoryRector::TYPES => [ObviousValueObjectInterface::class], - MoveValueObjectsToValueObjectDirectoryRector::SUFFIXES => ['Search'], - MoveValueObjectsToValueObjectDirectoryRector::ENABLE_VALUE_OBJECT_GUESSING => true, - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/autodiscovery/tests/Rector/FileNode/MoveValueObjectsToValueObjectDirectoryRector/config/configured_rule.php b/rules/autodiscovery/tests/Rector/FileNode/MoveValueObjectsToValueObjectDirectoryRector/config/configured_rule.php new file mode 100644 index 000000000000..98043c21f9bd --- /dev/null +++ b/rules/autodiscovery/tests/Rector/FileNode/MoveValueObjectsToValueObjectDirectoryRector/config/configured_rule.php @@ -0,0 +1,37 @@ +services(); + $services->set(\Rector\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector::class)->call( + 'configure', + [[ + \Rector\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector::TYPES => [ + \Rector\Autodiscovery\Tests\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector\Source\ObviousValueObjectInterface::class, + ], + ]] + ); + $services->set(\Rector\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector::class)->call( + 'configure', + [[ + \Rector\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector::TYPES => [ + \Rector\Autodiscovery\Tests\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector\Source\ObviousValueObjectInterface::class, + ], + ]] + )->call('configure', [[ + \Rector\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector::SUFFIXES => ['Search'], + ]]); + $services->set(\Rector\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector::class)->call( + 'configure', + [[ + \Rector\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector::TYPES => [ + \Rector\Autodiscovery\Tests\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector\Source\ObviousValueObjectInterface::class, + ], + ]] + )->call('configure', [[ + \Rector\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector::SUFFIXES => ['Search'], + ]])->call('configure', [[ + \Rector\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector::ENABLE_VALUE_OBJECT_GUESSING => true, + ]]); +}; diff --git a/rules/cakephp/tests/Rector/MethodCall/ArrayToFluentCallRector/ArrayToFluentCallRectorTest.php b/rules/cakephp/tests/Rector/MethodCall/ArrayToFluentCallRector/ArrayToFluentCallRectorTest.php index 51a80481c3d8..8f571f509402 100644 --- a/rules/cakephp/tests/Rector/MethodCall/ArrayToFluentCallRector/ArrayToFluentCallRectorTest.php +++ b/rules/cakephp/tests/Rector/MethodCall/ArrayToFluentCallRector/ArrayToFluentCallRectorTest.php @@ -5,11 +5,6 @@ namespace Rector\CakePHP\Tests\Rector\MethodCall\ArrayToFluentCallRector; use Iterator; -use Rector\CakePHP\Rector\MethodCall\ArrayToFluentCallRector; -use Rector\CakePHP\Tests\Rector\MethodCall\ArrayToFluentCallRector\Source\ConfigurableClass; -use Rector\CakePHP\Tests\Rector\MethodCall\ArrayToFluentCallRector\Source\FactoryClass; -use Rector\CakePHP\ValueObject\ArrayToFluentCall; -use Rector\CakePHP\ValueObject\FactoryMethod; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -28,23 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - ArrayToFluentCallRector::class => [ - ArrayToFluentCallRector::ARRAYS_TO_FLUENT_CALLS => [ - new ArrayToFluentCall(ConfigurableClass::class, [ - 'name' => 'setName', - 'size' => 'setSize', - ]), - ], - ArrayToFluentCallRector::FACTORY_METHODS => [ - new FactoryMethod(FactoryClass::class, 'buildClass', ConfigurableClass::class, 2), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/cakephp/tests/Rector/MethodCall/ArrayToFluentCallRector/config/configured_rule.php b/rules/cakephp/tests/Rector/MethodCall/ArrayToFluentCallRector/config/configured_rule.php new file mode 100644 index 000000000000..bd27eb9925eb --- /dev/null +++ b/rules/cakephp/tests/Rector/MethodCall/ArrayToFluentCallRector/config/configured_rule.php @@ -0,0 +1,26 @@ +services(); + $services->set(ArrayToFluentCallRector::class) + ->call('configure', [[ + ArrayToFluentCallRector::ARRAYS_TO_FLUENT_CALLS => ValueObjectInliner::inline([ + new ArrayToFluentCall(ConfigurableClass::class, [ + 'name' => 'setName', + 'size' => 'setSize', + ]), + ]), + ArrayToFluentCallRector::FACTORY_METHODS => ValueObjectInliner::inline([ + new FactoryMethod(FactoryClass::class, 'buildClass', ConfigurableClass::class, 2), + ]), + ]]); +}; diff --git a/rules/cakephp/tests/Rector/MethodCall/ModalToGetSetRector/ModalToGetSetRectorTest.php b/rules/cakephp/tests/Rector/MethodCall/ModalToGetSetRector/ModalToGetSetRectorTest.php index 0269cb4193f6..22e8028d1988 100644 --- a/rules/cakephp/tests/Rector/MethodCall/ModalToGetSetRector/ModalToGetSetRectorTest.php +++ b/rules/cakephp/tests/Rector/MethodCall/ModalToGetSetRector/ModalToGetSetRectorTest.php @@ -5,9 +5,6 @@ namespace Rector\CakePHP\Tests\Rector\MethodCall\ModalToGetSetRector; use Iterator; -use Rector\CakePHP\Rector\MethodCall\ModalToGetSetRector; -use Rector\CakePHP\Tests\Rector\MethodCall\ModalToGetSetRector\Source\SomeModelType; -use Rector\CakePHP\ValueObject\ModalToGetSet; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -26,27 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - ModalToGetSetRector::class => [ - ModalToGetSetRector::UNPREFIXED_METHODS_TO_GET_SET => [ - new ModalToGetSet(SomeModelType::class, 'config', null, null, 2, 'array'), - new ModalToGetSet( - SomeModelType::class, - 'customMethod', - 'customMethodGetName', - 'customMethodSetName', - 2, - 'array' - ), - new ModalToGetSet(SomeModelType::class, 'makeEntity', 'createEntity', 'generateEntity'), - new ModalToGetSet(SomeModelType::class, 'method'), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/cakephp/tests/Rector/MethodCall/ModalToGetSetRector/config/configured_rule.php b/rules/cakephp/tests/Rector/MethodCall/ModalToGetSetRector/config/configured_rule.php new file mode 100644 index 000000000000..9002d6283e76 --- /dev/null +++ b/rules/cakephp/tests/Rector/MethodCall/ModalToGetSetRector/config/configured_rule.php @@ -0,0 +1,41 @@ +services(); + $services->set(\Rector\CakePHP\Rector\MethodCall\ModalToGetSetRector::class)->call('configure', [[ + \Rector\CakePHP\Rector\MethodCall\ModalToGetSetRector::UNPREFIXED_METHODS_TO_GET_SET => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + new \Rector\CakePHP\ValueObject\ModalToGetSet( + \Rector\CakePHP\Tests\Rector\MethodCall\ModalToGetSetRector\Source\SomeModelType::class, + 'config', + null, + null, + 2, + 'array' + ), + new \Rector\CakePHP\ValueObject\ModalToGetSet( + \Rector\CakePHP\Tests\Rector\MethodCall\ModalToGetSetRector\Source\SomeModelType::class, + 'customMethod', + 'customMethodGetName', + 'customMethodSetName', + 2, + 'array' + ), + new \Rector\CakePHP\ValueObject\ModalToGetSet( + \Rector\CakePHP\Tests\Rector\MethodCall\ModalToGetSetRector\Source\SomeModelType::class, + 'makeEntity', + 'createEntity', + 'generateEntity' + ), + new \Rector\CakePHP\ValueObject\ModalToGetSet( + \Rector\CakePHP\Tests\Rector\MethodCall\ModalToGetSetRector\Source\SomeModelType::class, + 'method' + ), + + + ]), + ]]); +}; diff --git a/rules/cakephp/tests/Rector/MethodCall/RenameMethodCallBasedOnParameterRector/RenameMethodCallBasedOnParameterRectorTest.php b/rules/cakephp/tests/Rector/MethodCall/RenameMethodCallBasedOnParameterRector/RenameMethodCallBasedOnParameterRectorTest.php index a10d98f74053..117b1e7424a7 100644 --- a/rules/cakephp/tests/Rector/MethodCall/RenameMethodCallBasedOnParameterRector/RenameMethodCallBasedOnParameterRectorTest.php +++ b/rules/cakephp/tests/Rector/MethodCall/RenameMethodCallBasedOnParameterRector/RenameMethodCallBasedOnParameterRectorTest.php @@ -5,9 +5,6 @@ namespace Rector\CakePHP\Tests\Rector\MethodCall\RenameMethodCallBasedOnParameterRector; use Iterator; -use Rector\CakePHP\Rector\MethodCall\RenameMethodCallBasedOnParameterRector; -use Rector\CakePHP\Tests\Rector\MethodCall\RenameMethodCallBasedOnParameterRector\Source\SomeModelType; -use Rector\CakePHP\ValueObject\RenameMethodCallBasedOnParameter; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -29,18 +26,8 @@ public function provideData(): iterable return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - RenameMethodCallBasedOnParameterRector::class => [ - RenameMethodCallBasedOnParameterRector::CALLS_WITH_PARAM_RENAMES => [ - new RenameMethodCallBasedOnParameter(SomeModelType::class, 'getParam', 'paging', 'getAttribute'), - new RenameMethodCallBasedOnParameter(SomeModelType::class, 'withParam', 'paging', 'withAttribute'), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/cakephp/tests/Rector/MethodCall/RenameMethodCallBasedOnParameterRector/config/configured_rule.php b/rules/cakephp/tests/Rector/MethodCall/RenameMethodCallBasedOnParameterRector/config/configured_rule.php new file mode 100644 index 000000000000..6ede46a18c67 --- /dev/null +++ b/rules/cakephp/tests/Rector/MethodCall/RenameMethodCallBasedOnParameterRector/config/configured_rule.php @@ -0,0 +1,30 @@ +services(); + $services->set(\Rector\CakePHP\Rector\MethodCall\RenameMethodCallBasedOnParameterRector::class)->call( + 'configure', + [[ + \Rector\CakePHP\Rector\MethodCall\RenameMethodCallBasedOnParameterRector::CALLS_WITH_PARAM_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + new \Rector\CakePHP\ValueObject\RenameMethodCallBasedOnParameter( + \Rector\CakePHP\Tests\Rector\MethodCall\RenameMethodCallBasedOnParameterRector\Source\SomeModelType::class, + 'getParam', + 'paging', + 'getAttribute' + ), + new \Rector\CakePHP\ValueObject\RenameMethodCallBasedOnParameter( + \Rector\CakePHP\Tests\Rector\MethodCall\RenameMethodCallBasedOnParameterRector\Source\SomeModelType::class, + 'withParam', + 'paging', + 'withAttribute' + ), + + + ]), + ]] + ); +}; diff --git a/rules/coding-style/tests/Rector/ClassMethod/ReturnArrayClassMethodToYieldRector/ReturnArrayClassMethodToYieldRectorTest.php b/rules/coding-style/tests/Rector/ClassMethod/ReturnArrayClassMethodToYieldRector/ReturnArrayClassMethodToYieldRectorTest.php index 038c03184ac9..48d405f3e55a 100644 --- a/rules/coding-style/tests/Rector/ClassMethod/ReturnArrayClassMethodToYieldRector/ReturnArrayClassMethodToYieldRectorTest.php +++ b/rules/coding-style/tests/Rector/ClassMethod/ReturnArrayClassMethodToYieldRector/ReturnArrayClassMethodToYieldRectorTest.php @@ -5,11 +5,6 @@ namespace Rector\CodingStyle\Tests\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector; use Iterator; -use PHPUnit\Framework\TestCase; -use Rector\CodingStyle\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector; -use Rector\CodingStyle\Tests\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector\Source\EventSubscriberInterface; -use Rector\CodingStyle\Tests\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector\Source\ParentTestCase; -use Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -28,20 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - ReturnArrayClassMethodToYieldRector::class => [ - ReturnArrayClassMethodToYieldRector::METHODS_TO_YIELDS => [ - new ReturnArrayClassMethodToYield(EventSubscriberInterface::class, 'getSubscribedEvents'), - new ReturnArrayClassMethodToYield(ParentTestCase::class, 'provide*'), - new ReturnArrayClassMethodToYield(ParentTestCase::class, 'dataProvider*'), - new ReturnArrayClassMethodToYield(TestCase::class, 'provideData'), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/coding-style/tests/Rector/ClassMethod/ReturnArrayClassMethodToYieldRector/config/configured_rule.php b/rules/coding-style/tests/Rector/ClassMethod/ReturnArrayClassMethodToYieldRector/config/configured_rule.php new file mode 100644 index 000000000000..d697321031e5 --- /dev/null +++ b/rules/coding-style/tests/Rector/ClassMethod/ReturnArrayClassMethodToYieldRector/config/configured_rule.php @@ -0,0 +1,57 @@ +services(); + $services->set(\Rector\CodingStyle\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector::class)->call( + 'configure', + [[ + \Rector\CodingStyle\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector::METHODS_TO_YIELDS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + + + + + + + + new \Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield( + \Rector\CodingStyle\Tests\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector\Source\EventSubscriberInterface::class, + 'getSubscribedEvents' + ), + new \Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield( + \Rector\CodingStyle\Tests\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector\Source\ParentTestCase::class, + 'provide*' + ), + new \Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield( + \Rector\CodingStyle\Tests\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector\Source\ParentTestCase::class, + 'dataProvider*' + ), + new \Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield( + \PHPUnit\Framework\TestCase::class, + 'provideData' + ), + + + ]), + ]] + ); +}; diff --git a/rules/coding-style/tests/Rector/ClassMethod/YieldClassMethodToArrayClassMethodRector/YieldClassMethodToArrayClassMethodRectorTest.php b/rules/coding-style/tests/Rector/ClassMethod/YieldClassMethodToArrayClassMethodRector/YieldClassMethodToArrayClassMethodRectorTest.php index d9b3ea166bf4..ef04ce230846 100644 --- a/rules/coding-style/tests/Rector/ClassMethod/YieldClassMethodToArrayClassMethodRector/YieldClassMethodToArrayClassMethodRectorTest.php +++ b/rules/coding-style/tests/Rector/ClassMethod/YieldClassMethodToArrayClassMethodRector/YieldClassMethodToArrayClassMethodRectorTest.php @@ -5,8 +5,6 @@ namespace Rector\CodingStyle\Tests\Rector\ClassMethod\YieldClassMethodToArrayClassMethodRector; use Iterator; -use Rector\CodingStyle\Rector\ClassMethod\YieldClassMethodToArrayClassMethodRector; -use Rector\CodingStyle\Tests\Rector\ClassMethod\YieldClassMethodToArrayClassMethodRector\Source\EventSubscriberInterface; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -25,17 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - YieldClassMethodToArrayClassMethodRector::class => [ - YieldClassMethodToArrayClassMethodRector::METHODS_BY_TYPE => [ - EventSubscriberInterface::class => ['getSubscribedEvents'], - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/coding-style/tests/Rector/ClassMethod/YieldClassMethodToArrayClassMethodRector/config/configured_rule.php b/rules/coding-style/tests/Rector/ClassMethod/YieldClassMethodToArrayClassMethodRector/config/configured_rule.php new file mode 100644 index 000000000000..4b9a4f3be254 --- /dev/null +++ b/rules/coding-style/tests/Rector/ClassMethod/YieldClassMethodToArrayClassMethodRector/config/configured_rule.php @@ -0,0 +1,17 @@ +services(); + $services->set(\Rector\CodingStyle\Rector\ClassMethod\YieldClassMethodToArrayClassMethodRector::class)->call( + 'configure', + [[ + \Rector\CodingStyle\Rector\ClassMethod\YieldClassMethodToArrayClassMethodRector::METHODS_BY_TYPE => [ + \Rector\CodingStyle\Tests\Rector\ClassMethod\YieldClassMethodToArrayClassMethodRector\Source\EventSubscriberInterface::class => [ + 'getSubscribedEvents', + ], + ], + ]] + ); +}; diff --git a/rules/coding-style/tests/Rector/FuncCall/FunctionCallToConstantRector/FunctionCallToConstantRectorTest.php b/rules/coding-style/tests/Rector/FuncCall/FunctionCallToConstantRector/FunctionCallToConstantRectorTest.php index 497489a570f7..d69c935c0ee2 100644 --- a/rules/coding-style/tests/Rector/FuncCall/FunctionCallToConstantRector/FunctionCallToConstantRectorTest.php +++ b/rules/coding-style/tests/Rector/FuncCall/FunctionCallToConstantRector/FunctionCallToConstantRectorTest.php @@ -5,7 +5,6 @@ namespace Rector\CodingStyle\Tests\Rector\FuncCall\FunctionCallToConstantRector; use Iterator; -use Rector\CodingStyle\Rector\FuncCall\FunctionCallToConstantRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -24,18 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - FunctionCallToConstantRector::class => [ - FunctionCallToConstantRector::FUNCTIONS_TO_CONSTANTS => [ - 'php_sapi_name' => 'PHP_SAPI', - 'pi' => 'M_PI', - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/coding-style/tests/Rector/FuncCall/FunctionCallToConstantRector/config/configured_rule.php b/rules/coding-style/tests/Rector/FuncCall/FunctionCallToConstantRector/config/configured_rule.php new file mode 100644 index 000000000000..55d14f0375c2 --- /dev/null +++ b/rules/coding-style/tests/Rector/FuncCall/FunctionCallToConstantRector/config/configured_rule.php @@ -0,0 +1,13 @@ +services(); + $services->set(\Rector\CodingStyle\Rector\FuncCall\FunctionCallToConstantRector::class)->call('configure', [[ + \Rector\CodingStyle\Rector\FuncCall\FunctionCallToConstantRector::FUNCTIONS_TO_CONSTANTS => [ + 'php_sapi_name' => 'PHP_SAPI', + 'pi' => 'M_PI', + ], + ]]); +}; diff --git a/rules/coding-style/tests/Rector/MethodCall/PreferThisOrSelfMethodCallRector/PreferThisOrSelfMethodCallRectorTest.php b/rules/coding-style/tests/Rector/MethodCall/PreferThisOrSelfMethodCallRector/PreferThisOrSelfMethodCallRectorTest.php index 34a545adcbfe..442cecdc9880 100644 --- a/rules/coding-style/tests/Rector/MethodCall/PreferThisOrSelfMethodCallRector/PreferThisOrSelfMethodCallRectorTest.php +++ b/rules/coding-style/tests/Rector/MethodCall/PreferThisOrSelfMethodCallRector/PreferThisOrSelfMethodCallRectorTest.php @@ -5,10 +5,6 @@ namespace Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector; use Iterator; -use PHPUnit\Framework\TestCase; -use Rector\CodingStyle\Rector\MethodCall\PreferThisOrSelfMethodCallRector; -use Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source\AbstractTestCase; -use Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source\BeLocalClass; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -27,19 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - PreferThisOrSelfMethodCallRector::class => [ - PreferThisOrSelfMethodCallRector::TYPE_TO_PREFERENCE => [ - AbstractTestCase::class => 'self', - BeLocalClass::class => 'this', - TestCase::class => 'self', - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/coding-style/tests/Rector/MethodCall/PreferThisOrSelfMethodCallRector/config/configured_rule.php b/rules/coding-style/tests/Rector/MethodCall/PreferThisOrSelfMethodCallRector/config/configured_rule.php new file mode 100644 index 000000000000..422c8759938b --- /dev/null +++ b/rules/coding-style/tests/Rector/MethodCall/PreferThisOrSelfMethodCallRector/config/configured_rule.php @@ -0,0 +1,14 @@ +services(); + $services->set(\Rector\CodingStyle\Rector\MethodCall\PreferThisOrSelfMethodCallRector::class)->call('configure', [[ + \Rector\CodingStyle\Rector\MethodCall\PreferThisOrSelfMethodCallRector::TYPE_TO_PREFERENCE => [ + \Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source\AbstractTestCase::class => 'self', + \Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source\BeLocalClass::class => 'this', + \PHPUnit\Framework\TestCase::class => 'self', + ], + ]]); +}; diff --git a/rules/core/src/Rector/ClassMethod/GetRectorsWithConfigurationToProvideConfigFileInfoRector.php b/rules/core/src/Rector/ClassMethod/GetRectorsWithConfigurationToProvideConfigFileInfoRector.php deleted file mode 100644 index 048481d54921..000000000000 --- a/rules/core/src/Rector/ClassMethod/GetRectorsWithConfigurationToProvideConfigFileInfoRector.php +++ /dev/null @@ -1,225 +0,0 @@ -configuratorClosureNodeFactory = $configuratorClosureNodeFactory; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition('Remove unused parameter in constructor', [ - new CodeSample( - <<<'CODE_SAMPLE' -final class SomeClass -{ - /** - * @return mixed[] - */ - protected function getRectorsWithConfiguration(): array - { - return [ - NewArgToMethodCallRector::class => [ - NewArgToMethodCallRector::NEW_ARGS_TO_METHOD_CALLS => [ - new NewArgToMethodCall(SomeDotenv::class, true, 'usePutenv'), - ], - ], - ]; - } -} -CODE_SAMPLE - - , - <<<'CODE_SAMPLE' -final class SomeClass -{ - protected function getRectorsWithConfiguration(): \Symplify\SmartFileSystem\SmartFileInfo - { - return new \Symplify\SmartFileSystem\SmartFileInfo(__DIR__ . '/config/configured_rule.php'); - } -} -CODE_SAMPLE - - ), - ]); - } - - /** - * @return string[] - */ - public function getNodeTypes(): array - { - return [ClassMethod::class]; - } - - /** - * @param ClassMethod $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->isName($node, 'getRectorsWithConfiguration')) { - return null; - } - - $node->name = new Node\Identifier('provideConfigFileInfo'); - - /** @var Return_ $oldReturn */ - $oldReturn = $node->stmts[0]; - - $node->returnType = new Node\NullableType(new FullyQualified(SmartFileInfo::class)); - $this->createReturnTag($node); - - /** @var SmartFileInfo $smartFileInfo */ - $smartFileInfo = $node->getAttribute(SmartFileInfo::class); - $realPath = $smartFileInfo->getRealPath(); - $configFilePath = dirname($realPath) . '/config/configured_rule.php'; - - $services = []; - - $services[] = new Node\Stmt\Expression(new Node\Expr\Assign(new Variable('services'), new MethodCall( - new Variable( - 'containerConfigurator' - ), - 'services' - ))); - - $closure = null; - $serviceVariable = new Variable('services'); - - // get config value - /** @var Array_ $returnedArray */ - $returnedArray = $oldReturn->expr; - foreach ($returnedArray->items as $arrayItem) { - if (! $arrayItem instanceof ArrayItem) { - continue; - } - - if ($arrayItem->key instanceof ClassConstFetch) { - $methodCall = new MethodCall($serviceVariable, 'set', [$arrayItem->key]); - if ($arrayItem->value instanceof Array_) { - if ($arrayItem->value->items === []) { - $services[] = new Node\Stmt\Expression($methodCall); - } else { - foreach ($arrayItem->value->items as $nestedArrayItem) { - if (! $nestedArrayItem instanceof ArrayItem) { - continue; - } - - if ($nestedArrayItem->key instanceof ClassConstFetch) { - $hasValueObjects = $this->hasValueObjects($nestedArrayItem); - - if ($hasValueObjects) { - $configurationArray = new Node\Expr\StaticCall(new FullyQualified( - ValueObjectInliner::class - ), 'inline', [ - $nestedArrayItem->value, - ]); - } else { - $configurationArray = $nestedArrayItem->value; - } - - $arrayConfiguration = new Array_([new ArrayItem( - new Array_([new ArrayItem($configurationArray, $nestedArrayItem->key)])), - ]); - - $methodCall = new MethodCall($methodCall, 'call', [ - new Node\Scalar\String_('configure'), - $arrayConfiguration, - ]); - } - - $services[] = new Node\Stmt\Expression($methodCall); - } - } - } - - $closure = $this->configuratorClosureNodeFactory->createContainerClosureFromStmts($services); - } - } - - if ($closure === null) { - throw new ShouldNotHappenException(); - } - - $return = new Return_($closure); - $fileContent = $this->betterStandardPrinter->prettyPrintFile([$return]); - - dump($fileContent); - - $this->createPhpConfigFileAndDumpToPath($fileContent, $configFilePath); - - $node->stmts = [$this->createReturn()]; - - return $node; - } - - private function createReturn(): Return_ - { - $new = new New_(new FullyQualified(SmartFileInfo::class)); - $new->args[] = new Node\Expr\BinaryOp\Concat(new Node\Scalar\MagicConst\Dir(), new Node\Scalar\String_( - '/config/configured_rule.php' - )); - - return new Return_($new); - } - - private function createReturnTag($node): void - { - $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); - $phpDocInfo->removeByType(ReturnTagValueNode::class); - } - - private function createPhpConfigFileAndDumpToPath(string $fileContent, string $filePath): void - { - $addedFileWithContent = new AddedFileWithContent($filePath, $fileContent); - $this->removedAndAddedFilesCollector->addAddedFile($addedFileWithContent); - } - - private function hasValueObjects(ArrayItem $nestedArrayItem): bool - { - if ($nestedArrayItem->value instanceof Array_) { - foreach ($nestedArrayItem->value->items as $nestedNestedArrayItem) { - if (! $nestedNestedArrayItem instanceof ArrayItem) { - continue; - } - - return $nestedNestedArrayItem->value instanceof New_; - } - } - - return false; - } -} diff --git a/rules/core/tests/Rector/ClassMethod/GetRectorsWithConfigurationToProvideConfigFileInfoRector/Fixture/some_class.php.inc b/rules/core/tests/Rector/ClassMethod/GetRectorsWithConfigurationToProvideConfigFileInfoRector/Fixture/some_class.php.inc deleted file mode 100644 index 03ccc9aa3953..000000000000 --- a/rules/core/tests/Rector/ClassMethod/GetRectorsWithConfigurationToProvideConfigFileInfoRector/Fixture/some_class.php.inc +++ /dev/null @@ -1,36 +0,0 @@ - [ - NewArgToMethodCallRector::NEW_ARGS_TO_METHOD_CALLS => [ - new NewArgToMethodCall(SomeDotenv::class, true, 'usePutenv'), - ], - ], - ]; - } -} - -?> ------ - diff --git a/rules/core/tests/Rector/ClassMethod/GetRectorsWithConfigurationToProvideConfigFileInfoRector/GetRectorsWithConfigurationToProvideConfigFileInfoRectorTest.php b/rules/core/tests/Rector/ClassMethod/GetRectorsWithConfigurationToProvideConfigFileInfoRector/GetRectorsWithConfigurationToProvideConfigFileInfoRectorTest.php deleted file mode 100644 index a809f3ac6dbc..000000000000 --- a/rules/core/tests/Rector/ClassMethod/GetRectorsWithConfigurationToProvideConfigFileInfoRector/GetRectorsWithConfigurationToProvideConfigFileInfoRectorTest.php +++ /dev/null @@ -1,28 +0,0 @@ -doTestFileInfo($fileInfo); - } - - public function provideData(): \Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return \Rector\Core\Rector\ClassMethod\GetRectorsWithConfigurationToProvideConfigFileInfoRector::class; - } -} diff --git a/rules/dead-code/tests/Rector/ClassMethod/RemoveUnusedConstructorParamRector/RemoveUnusedConstructorParamRectorTest.php b/rules/dead-code/tests/Rector/ClassMethod/RemoveUnusedConstructorParamRector/RemoveUnusedConstructorParamRectorTest.php index 535ff5472a15..5fedf2d1f446 100644 --- a/rules/dead-code/tests/Rector/ClassMethod/RemoveUnusedConstructorParamRector/RemoveUnusedConstructorParamRectorTest.php +++ b/rules/dead-code/tests/Rector/ClassMethod/RemoveUnusedConstructorParamRector/RemoveUnusedConstructorParamRectorTest.php @@ -4,20 +4,22 @@ namespace Rector\DeadCode\Tests\Rector\ClassMethod\RemoveUnusedConstructorParamRector; +use Iterator; use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; +use Symplify\SmartFileSystem\SmartFileInfo; final class RemoveUnusedConstructorParamRectorTest extends AbstractRectorTestCase { /** * @dataProvider provideData() */ - public function test(\Symplify\SmartFileSystem\SmartFileInfo $fileInfo): void + public function test(SmartFileInfo $fileInfo): void { $this->doTestFileInfo($fileInfo); } - public function provideData(): \Iterator + public function provideData(): Iterator { return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } diff --git a/rules/dead-doc-block/tests/Rector/ClassLike/RemoveAnnotationRector/RemoveAnnotationRectorTest.php b/rules/dead-doc-block/tests/Rector/ClassLike/RemoveAnnotationRector/RemoveAnnotationRectorTest.php index dba09043bb2a..0b8144a4f414 100644 --- a/rules/dead-doc-block/tests/Rector/ClassLike/RemoveAnnotationRector/RemoveAnnotationRectorTest.php +++ b/rules/dead-doc-block/tests/Rector/ClassLike/RemoveAnnotationRector/RemoveAnnotationRectorTest.php @@ -5,8 +5,6 @@ namespace Rector\DeadDocBlock\Tests\Rector\ClassLike\RemoveAnnotationRector; use Iterator; -use Rector\BetterPhpDocParser\ValueObject\PhpDocNode\JMS\JMSInjectParamsTagValueNode; -use Rector\DeadDocBlock\Rector\ClassLike\RemoveAnnotationRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -25,15 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - RemoveAnnotationRector::class => [ - RemoveAnnotationRector::ANNOTATIONS_TO_REMOVE => ['method', JMSInjectParamsTagValueNode::class], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/dead-doc-block/tests/Rector/ClassLike/RemoveAnnotationRector/config/configured_rule.php b/rules/dead-doc-block/tests/Rector/ClassLike/RemoveAnnotationRector/config/configured_rule.php new file mode 100644 index 000000000000..da21ce844ef5 --- /dev/null +++ b/rules/dead-doc-block/tests/Rector/ClassLike/RemoveAnnotationRector/config/configured_rule.php @@ -0,0 +1,13 @@ +services(); + $services->set(\Rector\DeadDocBlock\Rector\ClassLike\RemoveAnnotationRector::class)->call('configure', [[ + \Rector\DeadDocBlock\Rector\ClassLike\RemoveAnnotationRector::ANNOTATIONS_TO_REMOVE => [ + 'method', + \Rector\BetterPhpDocParser\ValueObject\PhpDocNode\JMS\JMSInjectParamsTagValueNode::class, + ], + ]]); +}; diff --git a/rules/dependency-injection/tests/Rector/Class_/MultiParentingToAbstractDependencyRector/MultiParentingToAbstractDependencyRectorTest.php b/rules/dependency-injection/tests/Rector/Class_/MultiParentingToAbstractDependencyRector/MultiParentingToAbstractDependencyRectorTest.php index 9970a3d7c7cd..970079ee08d8 100644 --- a/rules/dependency-injection/tests/Rector/Class_/MultiParentingToAbstractDependencyRector/MultiParentingToAbstractDependencyRectorTest.php +++ b/rules/dependency-injection/tests/Rector/Class_/MultiParentingToAbstractDependencyRector/MultiParentingToAbstractDependencyRectorTest.php @@ -5,8 +5,6 @@ namespace Rector\DependencyInjection\Tests\Rector\Class_\MultiParentingToAbstractDependencyRector; use Iterator; -use Rector\Core\ValueObject\FrameworkName; -use Rector\DependencyInjection\Rector\Class_\MultiParentingToAbstractDependencyRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -25,15 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - MultiParentingToAbstractDependencyRector::class => [ - MultiParentingToAbstractDependencyRector::FRAMEWORK => FrameworkName::NETTE, - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/nette_config.php'); } } diff --git a/rules/dependency-injection/tests/Rector/Class_/MultiParentingToAbstractDependencyRector/SymfonyMultiParentingToAbstractDependencyRectorTest.php b/rules/dependency-injection/tests/Rector/Class_/MultiParentingToAbstractDependencyRector/SymfonyMultiParentingToAbstractDependencyRectorTest.php index 5376061f034a..06729e0f8d23 100644 --- a/rules/dependency-injection/tests/Rector/Class_/MultiParentingToAbstractDependencyRector/SymfonyMultiParentingToAbstractDependencyRectorTest.php +++ b/rules/dependency-injection/tests/Rector/Class_/MultiParentingToAbstractDependencyRector/SymfonyMultiParentingToAbstractDependencyRectorTest.php @@ -5,8 +5,6 @@ namespace Rector\DependencyInjection\Tests\Rector\Class_\MultiParentingToAbstractDependencyRector; use Iterator; -use Rector\Core\ValueObject\FrameworkName; -use Rector\DependencyInjection\Rector\Class_\MultiParentingToAbstractDependencyRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -25,15 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/FixtureSymfony'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - MultiParentingToAbstractDependencyRector::class => [ - MultiParentingToAbstractDependencyRector::FRAMEWORK => FrameworkName::SYMFONY, - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/symfony_config.php'); } } diff --git a/rules/dependency-injection/tests/Rector/Class_/MultiParentingToAbstractDependencyRector/config/nette_config.php b/rules/dependency-injection/tests/Rector/Class_/MultiParentingToAbstractDependencyRector/config/nette_config.php new file mode 100644 index 000000000000..1788fa6af9e5 --- /dev/null +++ b/rules/dependency-injection/tests/Rector/Class_/MultiParentingToAbstractDependencyRector/config/nette_config.php @@ -0,0 +1,16 @@ +services(); + + $services->set(MultiParentingToAbstractDependencyRector::class) + ->call('configure', [[ + MultiParentingToAbstractDependencyRector::FRAMEWORK => FrameworkName::NETTE, + ]]); +}; diff --git a/rules/dependency-injection/tests/Rector/Class_/MultiParentingToAbstractDependencyRector/config/symfony_config.php b/rules/dependency-injection/tests/Rector/Class_/MultiParentingToAbstractDependencyRector/config/symfony_config.php new file mode 100644 index 000000000000..a9e74fb18c1b --- /dev/null +++ b/rules/dependency-injection/tests/Rector/Class_/MultiParentingToAbstractDependencyRector/config/symfony_config.php @@ -0,0 +1,16 @@ +services(); + + $services->set(MultiParentingToAbstractDependencyRector::class) + ->call('configure', [[ + MultiParentingToAbstractDependencyRector::FRAMEWORK => FrameworkName::SYMFONY, + ]]); +}; diff --git a/rules/doctrine-code-quality/tests/Rector/DoctrineRepositoryAsService/DoctrineRepositoryAsServiceTest.php b/rules/doctrine-code-quality/tests/Rector/DoctrineRepositoryAsService/DoctrineRepositoryAsServiceTest.php index 5ee96408f234..de5c08fae14b 100644 --- a/rules/doctrine-code-quality/tests/Rector/DoctrineRepositoryAsService/DoctrineRepositoryAsServiceTest.php +++ b/rules/doctrine-code-quality/tests/Rector/DoctrineRepositoryAsService/DoctrineRepositoryAsServiceTest.php @@ -5,9 +5,6 @@ namespace Rector\DoctrineCodeQuality\Tests\Rector\DoctrineRepositoryAsService; use Iterator; -use Rector\Doctrine\Rector\Class_\RemoveRepositoryFromEntityAnnotationRector; -use Rector\Doctrine\Rector\MethodCall\ReplaceParentRepositoryCallsByRepositoryPropertyRector; -use Rector\DoctrineCodeQuality\Rector\Class_\MoveRepositoryFromParentToConstructorRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -31,16 +28,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - # order matters, this needs to be first to correctly detect parent repository - MoveRepositoryFromParentToConstructorRector::class => [], - ReplaceParentRepositoryCallsByRepositoryPropertyRector::class => [], - RemoveRepositoryFromEntityAnnotationRector::class => [], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/doctrine-code-quality/tests/Rector/DoctrineRepositoryAsService/config/configured_rule.php b/rules/doctrine-code-quality/tests/Rector/DoctrineRepositoryAsService/config/configured_rule.php new file mode 100644 index 000000000000..6826b1259b51 --- /dev/null +++ b/rules/doctrine-code-quality/tests/Rector/DoctrineRepositoryAsService/config/configured_rule.php @@ -0,0 +1,13 @@ +services(); + $services->set( + # order matters, this needs to be first to correctly detect parent repository + \Rector\DoctrineCodeQuality\Rector\Class_\MoveRepositoryFromParentToConstructorRector::class + ); + $services->set(\Rector\Doctrine\Rector\MethodCall\ReplaceParentRepositoryCallsByRepositoryPropertyRector::class); + $services->set(\Rector\Doctrine\Rector\Class_\RemoveRepositoryFromEntityAnnotationRector::class); +}; diff --git a/rules/doctrine/tests/Rector/Class_/AddEntityIdByConditionRector/AddEntityIdByConditionRectorTest.php b/rules/doctrine/tests/Rector/Class_/AddEntityIdByConditionRector/AddEntityIdByConditionRectorTest.php index 668096d3e884..db440c97c3df 100644 --- a/rules/doctrine/tests/Rector/Class_/AddEntityIdByConditionRector/AddEntityIdByConditionRectorTest.php +++ b/rules/doctrine/tests/Rector/Class_/AddEntityIdByConditionRector/AddEntityIdByConditionRectorTest.php @@ -5,8 +5,6 @@ namespace Rector\Doctrine\Tests\Rector\Class_\AddEntityIdByConditionRector; use Iterator; -use Rector\Doctrine\Rector\Class_\AddEntityIdByConditionRector; -use Rector\Doctrine\Tests\Rector\Class_\AddEntityIdByConditionRector\Source\SomeTrait; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -25,15 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - AddEntityIdByConditionRector::class => [ - AddEntityIdByConditionRector::DETECTED_TRAITS => [SomeTrait::class], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/doctrine/tests/Rector/Class_/AddEntityIdByConditionRector/config/configured_rule.php b/rules/doctrine/tests/Rector/Class_/AddEntityIdByConditionRector/config/configured_rule.php new file mode 100644 index 000000000000..ac28b3cfb653 --- /dev/null +++ b/rules/doctrine/tests/Rector/Class_/AddEntityIdByConditionRector/config/configured_rule.php @@ -0,0 +1,12 @@ +services(); + $services->set(\Rector\Doctrine\Rector\Class_\AddEntityIdByConditionRector::class)->call('configure', [[ + \Rector\Doctrine\Rector\Class_\AddEntityIdByConditionRector::DETECTED_TRAITS => [ + \Rector\Doctrine\Tests\Rector\Class_\AddEntityIdByConditionRector\Source\SomeTrait::class, + ], + ]]); +}; diff --git a/rules/doctrine/tests/Rector/MethodCall/EntityAliasToClassConstantReferenceRector/EntityAliasToClassConstantReferenceRectorTest.php b/rules/doctrine/tests/Rector/MethodCall/EntityAliasToClassConstantReferenceRector/EntityAliasToClassConstantReferenceRectorTest.php index c8d6d92f31a3..85ebcc5a628c 100644 --- a/rules/doctrine/tests/Rector/MethodCall/EntityAliasToClassConstantReferenceRector/EntityAliasToClassConstantReferenceRectorTest.php +++ b/rules/doctrine/tests/Rector/MethodCall/EntityAliasToClassConstantReferenceRector/EntityAliasToClassConstantReferenceRectorTest.php @@ -5,7 +5,6 @@ namespace Rector\Doctrine\Tests\Rector\MethodCall\EntityAliasToClassConstantReferenceRector; use Iterator; -use Rector\Doctrine\Rector\MethodCall\EntityAliasToClassConstantReferenceRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -24,17 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - EntityAliasToClassConstantReferenceRector::class => [ - EntityAliasToClassConstantReferenceRector::ALIASES_TO_NAMESPACES => [ - 'App' => 'App\Entity', - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/doctrine/tests/Rector/MethodCall/EntityAliasToClassConstantReferenceRector/config/configured_rule.php b/rules/doctrine/tests/Rector/MethodCall/EntityAliasToClassConstantReferenceRector/config/configured_rule.php new file mode 100644 index 000000000000..d6931d563490 --- /dev/null +++ b/rules/doctrine/tests/Rector/MethodCall/EntityAliasToClassConstantReferenceRector/config/configured_rule.php @@ -0,0 +1,15 @@ +services(); + $services->set(\Rector\Doctrine\Rector\MethodCall\EntityAliasToClassConstantReferenceRector::class)->call( + 'configure', + [[ + \Rector\Doctrine\Rector\MethodCall\EntityAliasToClassConstantReferenceRector::ALIASES_TO_NAMESPACES => [ + 'App' => 'App\Entity', + ], + ]] + ); +}; diff --git a/rules/generic/tests/Rector/ClassMethod/AddMethodParentCallRector/AddMethodParentCallRectorTest.php b/rules/generic/tests/Rector/ClassMethod/AddMethodParentCallRector/AddMethodParentCallRectorTest.php index 2f6d63be2ca1..534bcc737153 100644 --- a/rules/generic/tests/Rector/ClassMethod/AddMethodParentCallRector/AddMethodParentCallRectorTest.php +++ b/rules/generic/tests/Rector/ClassMethod/AddMethodParentCallRector/AddMethodParentCallRectorTest.php @@ -5,8 +5,6 @@ namespace Rector\Generic\Tests\Rector\ClassMethod\AddMethodParentCallRector; use Iterator; -use Rector\Generic\Rector\ClassMethod\AddMethodParentCallRector; -use Rector\Generic\Tests\Rector\ClassMethod\AddMethodParentCallRector\Source\ParentClassWithNewConstructor; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -25,17 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - AddMethodParentCallRector::class => [ - AddMethodParentCallRector::METHODS_BY_PARENT_TYPES => [ - ParentClassWithNewConstructor::class => '__construct', - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/generic/tests/Rector/ClassMethod/AddMethodParentCallRector/config/configured_rule.php b/rules/generic/tests/Rector/ClassMethod/AddMethodParentCallRector/config/configured_rule.php new file mode 100644 index 000000000000..b0239fbdf712 --- /dev/null +++ b/rules/generic/tests/Rector/ClassMethod/AddMethodParentCallRector/config/configured_rule.php @@ -0,0 +1,12 @@ +services(); + $services->set(\Rector\Generic\Rector\ClassMethod\AddMethodParentCallRector::class)->call('configure', [[ + \Rector\Generic\Rector\ClassMethod\AddMethodParentCallRector::METHODS_BY_PARENT_TYPES => [ + \Rector\Generic\Tests\Rector\ClassMethod\AddMethodParentCallRector\Source\ParentClassWithNewConstructor::class => '__construct', + ], + ]]); +}; diff --git a/rules/generic/tests/Rector/ClassMethod/ArgumentAdderRector/ArgumentAdderRectorTest.php b/rules/generic/tests/Rector/ClassMethod/ArgumentAdderRector/ArgumentAdderRectorTest.php index 152da2e1eb1b..4b161946d9e3 100644 --- a/rules/generic/tests/Rector/ClassMethod/ArgumentAdderRector/ArgumentAdderRectorTest.php +++ b/rules/generic/tests/Rector/ClassMethod/ArgumentAdderRector/ArgumentAdderRectorTest.php @@ -5,11 +5,6 @@ namespace Rector\Generic\Tests\Rector\ClassMethod\ArgumentAdderRector; use Iterator; -use Rector\Generic\NodeAnalyzer\ArgumentAddingScope; -use Rector\Generic\Rector\ClassMethod\ArgumentAdderRector; -use Rector\Generic\Tests\Rector\ClassMethod\ArgumentAdderRector\Source\SomeContainerBuilder; -use Rector\Generic\Tests\Rector\ClassMethod\ArgumentAdderRector\Source\SomeParentClient; -use Rector\Generic\ValueObject\ArgumentAdder; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -28,48 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - ArgumentAdderRector::class => [ - ArgumentAdderRector::ADDED_ARGUMENTS => [ - // covers https://github.com/rectorphp/rector/issues/4267 - new ArgumentAdder( - SomeContainerBuilder::class, - 'sendResetLinkResponse', - 0, - 'request', - null, - 'Illuminate\Http\Illuminate\Http' - ), - - new ArgumentAdder(SomeContainerBuilder::class, 'compile', 0, 'isCompiled', false), - new ArgumentAdder(SomeContainerBuilder::class, 'addCompilerPass', 2, 'priority', 0, 'int'), - - // scoped - new ArgumentAdder( - SomeParentClient::class, - 'submit', - 2, - 'serverParameters', - [], - 'array', - ArgumentAddingScope::SCOPE_PARENT_CALL - ), - new ArgumentAdder( - SomeParentClient::class, - 'submit', - 2, - 'serverParameters', - [], - 'array', - ArgumentAddingScope::SCOPE_CLASS_METHOD - ), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/generic/tests/Rector/ClassMethod/ArgumentAdderRector/config/configured_rule.php b/rules/generic/tests/Rector/ClassMethod/ArgumentAdderRector/config/configured_rule.php new file mode 100644 index 000000000000..4222885b1879 --- /dev/null +++ b/rules/generic/tests/Rector/ClassMethod/ArgumentAdderRector/config/configured_rule.php @@ -0,0 +1,54 @@ +services(); + $services->set(\Rector\Generic\Rector\ClassMethod\ArgumentAdderRector::class)->call('configure', [[ + \Rector\Generic\Rector\ClassMethod\ArgumentAdderRector::ADDED_ARGUMENTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + // covers https://github.com/rectorphp/rector/issues/4267 + new \Rector\Generic\ValueObject\ArgumentAdder( + \Rector\Generic\Tests\Rector\ClassMethod\ArgumentAdderRector\Source\SomeContainerBuilder::class, + 'sendResetLinkResponse', + 0, + 'request', + null, + 'Illuminate\Http\Illuminate\Http' + ), + new \Rector\Generic\ValueObject\ArgumentAdder( + \Rector\Generic\Tests\Rector\ClassMethod\ArgumentAdderRector\Source\SomeContainerBuilder::class, + 'compile', + 0, + 'isCompiled', + false + ), + new \Rector\Generic\ValueObject\ArgumentAdder( + \Rector\Generic\Tests\Rector\ClassMethod\ArgumentAdderRector\Source\SomeContainerBuilder::class, + 'addCompilerPass', + 2, + 'priority', + 0, + 'int' + ), + // scoped + new \Rector\Generic\ValueObject\ArgumentAdder( + \Rector\Generic\Tests\Rector\ClassMethod\ArgumentAdderRector\Source\SomeParentClient::class, + 'submit', + 2, + 'serverParameters', + [], + 'array', + \Rector\Generic\NodeAnalyzer\ArgumentAddingScope::SCOPE_PARENT_CALL + ), + new \Rector\Generic\ValueObject\ArgumentAdder( + \Rector\Generic\Tests\Rector\ClassMethod\ArgumentAdderRector\Source\SomeParentClient::class, + 'submit', + 2, + 'serverParameters', + [], + 'array', + \Rector\Generic\NodeAnalyzer\ArgumentAddingScope::SCOPE_CLASS_METHOD + ), + ]), + ]]); +}; diff --git a/rules/generic/tests/Rector/ClassMethod/ArgumentDefaultValueReplacerRector/ArgumentDefaultValueReplacerRectorTest.php b/rules/generic/tests/Rector/ClassMethod/ArgumentDefaultValueReplacerRector/ArgumentDefaultValueReplacerRectorTest.php index 6ed4c8f4f850..c44c6c519196 100644 --- a/rules/generic/tests/Rector/ClassMethod/ArgumentDefaultValueReplacerRector/ArgumentDefaultValueReplacerRectorTest.php +++ b/rules/generic/tests/Rector/ClassMethod/ArgumentDefaultValueReplacerRector/ArgumentDefaultValueReplacerRectorTest.php @@ -5,8 +5,6 @@ namespace Rector\Generic\Tests\Rector\ClassMethod\ArgumentDefaultValueReplacerRector; use Iterator; -use Rector\Generic\Rector\ClassMethod\ArgumentDefaultValueReplacerRector; -use Rector\Generic\ValueObject\ArgumentDefaultValueReplacer; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -25,53 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - ArgumentDefaultValueReplacerRector::class => [ - ArgumentDefaultValueReplacerRector::REPLACED_ARGUMENTS => [ - new ArgumentDefaultValueReplacer( - 'Symfony\Component\DependencyInjection\Definition', - 'setScope', - 0, - 'Symfony\Component\DependencyInjection\ContainerBuilder::SCOPE_PROTOTYPE', - false - ), - - new ArgumentDefaultValueReplacer('Symfony\Component\Yaml\Yaml', 'parse', 1, [ - false, - false, - true, - ], 'Symfony\Component\Yaml\Yaml::PARSE_OBJECT_FOR_MAP'), - - new ArgumentDefaultValueReplacer('Symfony\Component\Yaml\Yaml', 'parse', 1, [ - false, - true, - ], 'Symfony\Component\Yaml\Yaml::PARSE_OBJECT'), - new ArgumentDefaultValueReplacer('Symfony\Component\Yaml\Yaml', 'parse', 1, false, 0), - new ArgumentDefaultValueReplacer( - 'Symfony\Component\Yaml\Yaml', - 'parse', - 1, - true, - 'Symfony\Component\Yaml\Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE' - ), - new ArgumentDefaultValueReplacer('Symfony\Component\Yaml\Yaml', 'dump', 3, [ - false, - true, - ], 'Symfony\Component\Yaml\Yaml::DUMP_OBJECT'), - new ArgumentDefaultValueReplacer( - 'Symfony\Component\Yaml\Yaml', - 'dump', - 3, - true, - 'Symfony\Component\Yaml\Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE' - ), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/generic/tests/Rector/ClassMethod/ArgumentDefaultValueReplacerRector/config/configured_rule.php b/rules/generic/tests/Rector/ClassMethod/ArgumentDefaultValueReplacerRector/config/configured_rule.php new file mode 100644 index 000000000000..5f812e159f5d --- /dev/null +++ b/rules/generic/tests/Rector/ClassMethod/ArgumentDefaultValueReplacerRector/config/configured_rule.php @@ -0,0 +1,95 @@ +services(); + $services->set(\Rector\Generic\Rector\ClassMethod\ArgumentDefaultValueReplacerRector::class)->call('configure', [[ + \Rector\Generic\Rector\ClassMethod\ArgumentDefaultValueReplacerRector::REPLACED_ARGUMENTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + new \Rector\Generic\ValueObject\ArgumentDefaultValueReplacer( + 'Symfony\Component\DependencyInjection\Definition', + 'setScope', + 0, + 'Symfony\Component\DependencyInjection\ContainerBuilder::SCOPE_PROTOTYPE', + false + ), + new \Rector\Generic\ValueObject\ArgumentDefaultValueReplacer('Symfony\Component\Yaml\Yaml', 'parse', 1, [ + false, + false, + true, + ], 'Symfony\Component\Yaml\Yaml::PARSE_OBJECT_FOR_MAP'), + new \Rector\Generic\ValueObject\ArgumentDefaultValueReplacer('Symfony\Component\Yaml\Yaml', 'parse', 1, [ + false, + true, + ], 'Symfony\Component\Yaml\Yaml::PARSE_OBJECT'), + new \Rector\Generic\ValueObject\ArgumentDefaultValueReplacer( + 'Symfony\Component\Yaml\Yaml', + 'parse', + 1, + false, + 0 + ), + new \Rector\Generic\ValueObject\ArgumentDefaultValueReplacer( + 'Symfony\Component\Yaml\Yaml', + 'parse', + 1, + true, + 'Symfony\Component\Yaml\Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE' + ), + new \Rector\Generic\ValueObject\ArgumentDefaultValueReplacer('Symfony\Component\Yaml\Yaml', 'dump', 3, [ + false, + true, + ], 'Symfony\Component\Yaml\Yaml::DUMP_OBJECT'), + new \Rector\Generic\ValueObject\ArgumentDefaultValueReplacer( + 'Symfony\Component\Yaml\Yaml', + 'dump', + 3, + true, + 'Symfony\Component\Yaml\Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE' + ), + + + + + + + + + + + + + + + + + + + + + + + + + + ]), + ]]); +}; diff --git a/rules/generic/tests/Rector/ClassMethod/NormalToFluentRector/NormalToFluentRectorTest.php b/rules/generic/tests/Rector/ClassMethod/NormalToFluentRector/NormalToFluentRectorTest.php index 2ddf5fda877e..a4b20ce970ef 100644 --- a/rules/generic/tests/Rector/ClassMethod/NormalToFluentRector/NormalToFluentRectorTest.php +++ b/rules/generic/tests/Rector/ClassMethod/NormalToFluentRector/NormalToFluentRectorTest.php @@ -5,9 +5,6 @@ namespace Rector\Generic\Tests\Rector\ClassMethod\NormalToFluentRector; use Iterator; -use Rector\Generic\Rector\ClassMethod\NormalToFluentRector; -use Rector\Generic\Tests\Rector\ClassMethod\NormalToFluentRector\Source\FluentInterfaceClass; -use Rector\Generic\ValueObject\NormalToFluent; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -26,21 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - NormalToFluentRector::class => [ - NormalToFluentRector::CALLS_TO_FLUENT => [ - new NormalToFluent(FluentInterfaceClass::class, [ - 'someFunction', - 'otherFunction', - 'joinThisAsWell', - ]), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/generic/tests/Rector/ClassMethod/NormalToFluentRector/config/configured_rule.php b/rules/generic/tests/Rector/ClassMethod/NormalToFluentRector/config/configured_rule.php new file mode 100644 index 000000000000..7cac6da6d122 --- /dev/null +++ b/rules/generic/tests/Rector/ClassMethod/NormalToFluentRector/config/configured_rule.php @@ -0,0 +1,33 @@ +services(); + $services->set(\Rector\Generic\Rector\ClassMethod\NormalToFluentRector::class)->call('configure', [[ + \Rector\Generic\Rector\ClassMethod\NormalToFluentRector::CALLS_TO_FLUENT => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + new \Rector\Generic\ValueObject\NormalToFluent( + \Rector\Generic\Tests\Rector\ClassMethod\NormalToFluentRector\Source\FluentInterfaceClass::class, + ['someFunction', 'otherFunction', 'joinThisAsWell']), + ] + ), + ]]); +}; diff --git a/rules/generic/tests/Rector/ClassMethod/SingleToManyMethodRector/SingleToManyMethodRectorTest.php b/rules/generic/tests/Rector/ClassMethod/SingleToManyMethodRector/SingleToManyMethodRectorTest.php index 8ede793a706d..4588e7e92f47 100644 --- a/rules/generic/tests/Rector/ClassMethod/SingleToManyMethodRector/SingleToManyMethodRectorTest.php +++ b/rules/generic/tests/Rector/ClassMethod/SingleToManyMethodRector/SingleToManyMethodRectorTest.php @@ -5,9 +5,6 @@ namespace Rector\Generic\Tests\Rector\ClassMethod\SingleToManyMethodRector; use Iterator; -use Rector\Generic\Rector\ClassMethod\SingleToManyMethodRector; -use Rector\Generic\Tests\Rector\ClassMethod\SingleToManyMethodRector\Source\OneToManyInterface; -use Rector\Generic\ValueObject\SingleToManyMethod; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -26,17 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - SingleToManyMethodRector::class => [ - SingleToManyMethodRector::SINGLES_TO_MANY_METHODS => [ - new SingleToManyMethod(OneToManyInterface::class, 'getNode', 'getNodes'), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/generic/tests/Rector/ClassMethod/SingleToManyMethodRector/config/configured_rule.php b/rules/generic/tests/Rector/ClassMethod/SingleToManyMethodRector/config/configured_rule.php new file mode 100644 index 000000000000..535f77387071 --- /dev/null +++ b/rules/generic/tests/Rector/ClassMethod/SingleToManyMethodRector/config/configured_rule.php @@ -0,0 +1,59 @@ +services(); + $services->set(\Rector\Generic\Rector\ClassMethod\SingleToManyMethodRector::class)->call('configure', [[ + \Rector\Generic\Rector\ClassMethod\SingleToManyMethodRector::SINGLES_TO_MANY_METHODS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + new \Rector\Generic\ValueObject\SingleToManyMethod( + \Rector\Generic\Tests\Rector\ClassMethod\SingleToManyMethodRector\Source\OneToManyInterface::class, + 'getNode', + 'getNodes' + ), + + + + + + + + + + + + + + + + + + + + + + + + + + ]), + ]]); +}; diff --git a/rules/generic/tests/Rector/ClassMethod/WrapReturnRector/WrapReturnRectorTest.php b/rules/generic/tests/Rector/ClassMethod/WrapReturnRector/WrapReturnRectorTest.php index f11c8ea21bcd..101dbf8484bb 100644 --- a/rules/generic/tests/Rector/ClassMethod/WrapReturnRector/WrapReturnRectorTest.php +++ b/rules/generic/tests/Rector/ClassMethod/WrapReturnRector/WrapReturnRectorTest.php @@ -5,9 +5,6 @@ namespace Rector\Generic\Tests\Rector\ClassMethod\WrapReturnRector; use Iterator; -use Rector\Generic\Rector\ClassMethod\WrapReturnRector; -use Rector\Generic\Tests\Rector\ClassMethod\WrapReturnRector\Source\SomeReturnClass; -use Rector\Generic\ValueObject\WrapReturn; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -26,15 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - WrapReturnRector::class => [ - WrapReturnRector::TYPE_METHOD_WRAPS => [new WrapReturn(SomeReturnClass::class, 'getItem', true)], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/generic/tests/Rector/ClassMethod/WrapReturnRector/config/configured_rule.php b/rules/generic/tests/Rector/ClassMethod/WrapReturnRector/config/configured_rule.php new file mode 100644 index 000000000000..8e0156edae06 --- /dev/null +++ b/rules/generic/tests/Rector/ClassMethod/WrapReturnRector/config/configured_rule.php @@ -0,0 +1,59 @@ +services(); + $services->set(\Rector\Generic\Rector\ClassMethod\WrapReturnRector::class)->call('configure', [[ + \Rector\Generic\Rector\ClassMethod\WrapReturnRector::TYPE_METHOD_WRAPS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + new \Rector\Generic\ValueObject\WrapReturn( + \Rector\Generic\Tests\Rector\ClassMethod\WrapReturnRector\Source\SomeReturnClass::class, + 'getItem', + true + ), + + + + + + + + + + + + + + + + + + + + + + + + + + ]), + ]]); +}; diff --git a/rules/generic/tests/Rector/Class_/AddInterfaceByTraitRector/AddInterfaceByTraitRectorTest.php b/rules/generic/tests/Rector/Class_/AddInterfaceByTraitRector/AddInterfaceByTraitRectorTest.php index e2cd6dd0c677..26b729ca310a 100644 --- a/rules/generic/tests/Rector/Class_/AddInterfaceByTraitRector/AddInterfaceByTraitRectorTest.php +++ b/rules/generic/tests/Rector/Class_/AddInterfaceByTraitRector/AddInterfaceByTraitRectorTest.php @@ -5,9 +5,6 @@ namespace Rector\Generic\Tests\Rector\Class_\AddInterfaceByTraitRector; use Iterator; -use Rector\Generic\Rector\Class_\AddInterfaceByTraitRector; -use Rector\Generic\Tests\Rector\Class_\AddInterfaceByTraitRector\Source\SomeInterface; -use Rector\Generic\Tests\Rector\Class_\AddInterfaceByTraitRector\Source\SomeTrait; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -26,17 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - AddInterfaceByTraitRector::class => [ - AddInterfaceByTraitRector::INTERFACE_BY_TRAIT => [ - SomeTrait::class => SomeInterface::class, - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/generic/tests/Rector/Class_/AddInterfaceByTraitRector/config/configured_rule.php b/rules/generic/tests/Rector/Class_/AddInterfaceByTraitRector/config/configured_rule.php new file mode 100644 index 000000000000..7d10e096b144 --- /dev/null +++ b/rules/generic/tests/Rector/Class_/AddInterfaceByTraitRector/config/configured_rule.php @@ -0,0 +1,12 @@ +services(); + $services->set(\Rector\Generic\Rector\Class_\AddInterfaceByTraitRector::class)->call('configure', [[ + \Rector\Generic\Rector\Class_\AddInterfaceByTraitRector::INTERFACE_BY_TRAIT => [ + \Rector\Generic\Tests\Rector\Class_\AddInterfaceByTraitRector\Source\SomeTrait::class => \Rector\Generic\Tests\Rector\Class_\AddInterfaceByTraitRector\Source\SomeInterface::class, + ], + ]]); +}; diff --git a/rules/generic/tests/Rector/Class_/AddPropertyByParentRector/AddPropertyByParentRectorTest.php b/rules/generic/tests/Rector/Class_/AddPropertyByParentRector/AddPropertyByParentRectorTest.php index 828d4e28fc46..696b753a9739 100644 --- a/rules/generic/tests/Rector/Class_/AddPropertyByParentRector/AddPropertyByParentRectorTest.php +++ b/rules/generic/tests/Rector/Class_/AddPropertyByParentRector/AddPropertyByParentRectorTest.php @@ -5,9 +5,6 @@ namespace Rector\Generic\Tests\Rector\Class_\AddPropertyByParentRector; use Iterator; -use Rector\Generic\Rector\Class_\AddPropertyByParentRector; -use Rector\Generic\Tests\Rector\Class_\AddPropertyByParentRector\Source\SomeParentClassToAddDependencyBy; -use Rector\Generic\ValueObject\AddPropertyByParent; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -26,17 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - AddPropertyByParentRector::class => [ - AddPropertyByParentRector::PARENT_DEPENDENCIES => [ - new AddPropertyByParent(SomeParentClassToAddDependencyBy::class, 'SomeDependency'), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/generic/tests/Rector/Class_/AddPropertyByParentRector/config/configured_rule.php b/rules/generic/tests/Rector/Class_/AddPropertyByParentRector/config/configured_rule.php new file mode 100644 index 000000000000..f8060794da5c --- /dev/null +++ b/rules/generic/tests/Rector/Class_/AddPropertyByParentRector/config/configured_rule.php @@ -0,0 +1,58 @@ +services(); + $services->set(\Rector\Generic\Rector\Class_\AddPropertyByParentRector::class)->call('configure', [[ + \Rector\Generic\Rector\Class_\AddPropertyByParentRector::PARENT_DEPENDENCIES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + new \Rector\Generic\ValueObject\AddPropertyByParent( + \Rector\Generic\Tests\Rector\Class_\AddPropertyByParentRector\Source\SomeParentClassToAddDependencyBy::class, + 'SomeDependency' + ), + + + + + + + + + + + + + + + + + + + + + + + + + + ]), + ]]); +}; diff --git a/rules/generic/tests/Rector/Class_/MergeInterfacesRector/MergeInterfacesRectorTest.php b/rules/generic/tests/Rector/Class_/MergeInterfacesRector/MergeInterfacesRectorTest.php index 95e57c0b482b..9bcccf1a3b1a 100644 --- a/rules/generic/tests/Rector/Class_/MergeInterfacesRector/MergeInterfacesRectorTest.php +++ b/rules/generic/tests/Rector/Class_/MergeInterfacesRector/MergeInterfacesRectorTest.php @@ -5,9 +5,6 @@ namespace Rector\Generic\Tests\Rector\Class_\MergeInterfacesRector; use Iterator; -use Rector\Generic\Rector\Class_\MergeInterfacesRector; -use Rector\Generic\Tests\Rector\Class_\MergeInterfacesRector\Source\SomeInterface; -use Rector\Generic\Tests\Rector\Class_\MergeInterfacesRector\Source\SomeOldInterface; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -26,17 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - MergeInterfacesRector::class => [ - MergeInterfacesRector::OLD_TO_NEW_INTERFACES => [ - SomeOldInterface::class => SomeInterface::class, - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/generic/tests/Rector/Class_/MergeInterfacesRector/config/configured_rule.php b/rules/generic/tests/Rector/Class_/MergeInterfacesRector/config/configured_rule.php new file mode 100644 index 000000000000..3ba2d3f19ff0 --- /dev/null +++ b/rules/generic/tests/Rector/Class_/MergeInterfacesRector/config/configured_rule.php @@ -0,0 +1,12 @@ +services(); + $services->set(\Rector\Generic\Rector\Class_\MergeInterfacesRector::class)->call('configure', [[ + \Rector\Generic\Rector\Class_\MergeInterfacesRector::OLD_TO_NEW_INTERFACES => [ + \Rector\Generic\Tests\Rector\Class_\MergeInterfacesRector\Source\SomeOldInterface::class => \Rector\Generic\Tests\Rector\Class_\MergeInterfacesRector\Source\SomeInterface::class, + ], + ]]); +}; diff --git a/rules/generic/tests/Rector/FuncCall/SwapFuncCallArgumentsRector/SwapFuncCallArgumentsRectorTest.php b/rules/generic/tests/Rector/FuncCall/SwapFuncCallArgumentsRector/SwapFuncCallArgumentsRectorTest.php index 44f330f97531..f8e921ec3d1a 100644 --- a/rules/generic/tests/Rector/FuncCall/SwapFuncCallArgumentsRector/SwapFuncCallArgumentsRectorTest.php +++ b/rules/generic/tests/Rector/FuncCall/SwapFuncCallArgumentsRector/SwapFuncCallArgumentsRectorTest.php @@ -5,8 +5,6 @@ namespace Rector\Generic\Tests\Rector\FuncCall\SwapFuncCallArgumentsRector; use Iterator; -use Rector\Generic\Rector\FuncCall\SwapFuncCallArgumentsRector; -use Rector\Generic\ValueObject\SwapFuncCallArguments; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -25,17 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - SwapFuncCallArgumentsRector::class => [ - SwapFuncCallArgumentsRector::FUNCTION_ARGUMENT_SWAPS => [ - new SwapFuncCallArguments('some_function', [1, 0]), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/generic/tests/Rector/FuncCall/SwapFuncCallArgumentsRector/config/configured_rule.php b/rules/generic/tests/Rector/FuncCall/SwapFuncCallArgumentsRector/config/configured_rule.php new file mode 100644 index 000000000000..8a1ceacd18d6 --- /dev/null +++ b/rules/generic/tests/Rector/FuncCall/SwapFuncCallArgumentsRector/config/configured_rule.php @@ -0,0 +1,31 @@ +services(); + $services->set(\Rector\Generic\Rector\FuncCall\SwapFuncCallArgumentsRector::class)->call('configure', [[ + \Rector\Generic\Rector\FuncCall\SwapFuncCallArgumentsRector::FUNCTION_ARGUMENT_SWAPS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + new \Rector\Generic\ValueObject\SwapFuncCallArguments('some_function', [1, 0]), + ] + ), + ]]); +}; diff --git a/rules/generic/tests/Rector/Property/InjectAnnotationClassRector/InjectAnnotationClassRectorTest.php b/rules/generic/tests/Rector/Property/InjectAnnotationClassRector/InjectAnnotationClassRectorTest.php index 9938bb93b0f7..47c09b84f6f5 100644 --- a/rules/generic/tests/Rector/Property/InjectAnnotationClassRector/InjectAnnotationClassRectorTest.php +++ b/rules/generic/tests/Rector/Property/InjectAnnotationClassRector/InjectAnnotationClassRectorTest.php @@ -4,11 +4,8 @@ namespace Rector\Generic\Tests\Rector\Property\InjectAnnotationClassRector; -use DI\Annotation\Inject as PHPDIInject; use Iterator; -use JMS\DiExtraBundle\Annotation\Inject; use Rector\Core\Configuration\Option; -use Rector\Generic\Rector\Property\InjectAnnotationClassRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -32,15 +29,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - InjectAnnotationClassRector::class => [ - InjectAnnotationClassRector::ANNOTATION_CLASSES => [Inject::class, PHPDIInject::class], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/generic/tests/Rector/Property/InjectAnnotationClassRector/config/configured_rule.php b/rules/generic/tests/Rector/Property/InjectAnnotationClassRector/config/configured_rule.php new file mode 100644 index 000000000000..b48ceb599d19 --- /dev/null +++ b/rules/generic/tests/Rector/Property/InjectAnnotationClassRector/config/configured_rule.php @@ -0,0 +1,13 @@ +services(); + $services->set(\Rector\Generic\Rector\Property\InjectAnnotationClassRector::class)->call('configure', [[ + \Rector\Generic\Rector\Property\InjectAnnotationClassRector::ANNOTATION_CLASSES => [ + \JMS\DiExtraBundle\Annotation\Inject::class, + \DI\Annotation\Inject::class, + ], + ]]); +}; diff --git a/rules/generic/tests/Rector/RectorOrder/RectorOrderTest.php b/rules/generic/tests/Rector/RectorOrder/RectorOrderTest.php index a21b47e71e5d..18fe401695aa 100644 --- a/rules/generic/tests/Rector/RectorOrder/RectorOrderTest.php +++ b/rules/generic/tests/Rector/RectorOrder/RectorOrderTest.php @@ -5,9 +5,6 @@ namespace Rector\Generic\Tests\Rector\RectorOrder; use Iterator; -use Rector\PHPUnit\Rector\MethodCall\AssertComparisonToSpecificMethodRector; -use Rector\PHPUnit\Rector\MethodCall\AssertFalseStrposToContainsRector; -use Rector\PHPUnit\Rector\MethodCall\AssertSameBoolNullToSpecificMethodRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -29,16 +26,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - // order matters - return [ - AssertComparisonToSpecificMethodRector::class => [], - AssertSameBoolNullToSpecificMethodRector::class => [], - AssertFalseStrposToContainsRector::class => [], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/generic/tests/Rector/RectorOrder/config/configured_rule.php b/rules/generic/tests/Rector/RectorOrder/config/configured_rule.php new file mode 100644 index 000000000000..b4c9c2915edd --- /dev/null +++ b/rules/generic/tests/Rector/RectorOrder/config/configured_rule.php @@ -0,0 +1,10 @@ +services(); + $services->set(\Rector\PHPUnit\Rector\MethodCall\AssertComparisonToSpecificMethodRector::class); + $services->set(\Rector\PHPUnit\Rector\MethodCall\AssertSameBoolNullToSpecificMethodRector::class); + $services->set(\Rector\PHPUnit\Rector\MethodCall\AssertFalseStrposToContainsRector::class); +}; diff --git a/rules/legacy/tests/Rector/FileWithoutNamespace/AddTopIncludeRector/AddTopIncludeRectorTest.php b/rules/legacy/tests/Rector/FileWithoutNamespace/AddTopIncludeRector/AddTopIncludeRectorTest.php index dcac3027a0ca..58047ed974f1 100644 --- a/rules/legacy/tests/Rector/FileWithoutNamespace/AddTopIncludeRector/AddTopIncludeRectorTest.php +++ b/rules/legacy/tests/Rector/FileWithoutNamespace/AddTopIncludeRector/AddTopIncludeRectorTest.php @@ -5,7 +5,6 @@ namespace Rector\Legacy\Tests\Rector\FileWithoutNamespace\AddTopIncludeRector; use Iterator; -use Rector\Legacy\Rector\FileWithoutNamespace\AddTopIncludeRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -24,15 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - AddTopIncludeRector::class => [ - AddTopIncludeRector::AUTOLOAD_FILE_PATH => '/../autoloader.php', - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/legacy/tests/Rector/FileWithoutNamespace/AddTopIncludeRector/config/configured_rule.php b/rules/legacy/tests/Rector/FileWithoutNamespace/AddTopIncludeRector/config/configured_rule.php new file mode 100644 index 000000000000..9dac980ee24d --- /dev/null +++ b/rules/legacy/tests/Rector/FileWithoutNamespace/AddTopIncludeRector/config/configured_rule.php @@ -0,0 +1,10 @@ +services(); + $services->set(\Rector\Legacy\Rector\FileWithoutNamespace\AddTopIncludeRector::class)->call('configure', [[ + \Rector\Legacy\Rector\FileWithoutNamespace\AddTopIncludeRector::AUTOLOAD_FILE_PATH => '/../autoloader.php', + ]]); +}; diff --git a/rules/nette-tester-to-phpunit/tests/Rector/Class_/NetteTesterClassToPHPUnitClassRector/NetteTesterPHPUnitRectorTest.php b/rules/nette-tester-to-phpunit/tests/Rector/Class_/NetteTesterClassToPHPUnitClassRector/NetteTesterPHPUnitRectorTest.php index ee979591e803..0f369050a2ff 100644 --- a/rules/nette-tester-to-phpunit/tests/Rector/Class_/NetteTesterClassToPHPUnitClassRector/NetteTesterPHPUnitRectorTest.php +++ b/rules/nette-tester-to-phpunit/tests/Rector/Class_/NetteTesterClassToPHPUnitClassRector/NetteTesterPHPUnitRectorTest.php @@ -5,8 +5,6 @@ namespace Rector\NetteTesterToPHPUnit\Tests\Rector\Class_\NetteTesterClassToPHPUnitClassRector; use Iterator; -use Rector\NetteTesterToPHPUnit\Rector\Class_\NetteTesterClassToPHPUnitClassRector; -use Rector\NetteTesterToPHPUnit\Rector\StaticCall\NetteAssertToPHPUnitAssertRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -25,14 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - NetteAssertToPHPUnitAssertRector::class => [], - NetteTesterClassToPHPUnitClassRector::class => [], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/nette-tester-to-phpunit/tests/Rector/Class_/NetteTesterClassToPHPUnitClassRector/config/configured_rule.php b/rules/nette-tester-to-phpunit/tests/Rector/Class_/NetteTesterClassToPHPUnitClassRector/config/configured_rule.php new file mode 100644 index 000000000000..450e83b4478f --- /dev/null +++ b/rules/nette-tester-to-phpunit/tests/Rector/Class_/NetteTesterClassToPHPUnitClassRector/config/configured_rule.php @@ -0,0 +1,9 @@ +services(); + $services->set(\Rector\NetteTesterToPHPUnit\Rector\StaticCall\NetteAssertToPHPUnitAssertRector::class); + $services->set(\Rector\NetteTesterToPHPUnit\Rector\Class_\NetteTesterClassToPHPUnitClassRector::class); +}; diff --git a/rules/php-spec-to-phpunit/tests/Rector/Variable/PhpSpecToPHPUnitRector/PhpSpecToPHPUnitRectorTest.php b/rules/php-spec-to-phpunit/tests/Rector/Variable/PhpSpecToPHPUnitRector/PhpSpecToPHPUnitRectorTest.php index 5a88561de42e..b5a5a467cc27 100644 --- a/rules/php-spec-to-phpunit/tests/Rector/Variable/PhpSpecToPHPUnitRector/PhpSpecToPHPUnitRectorTest.php +++ b/rules/php-spec-to-phpunit/tests/Rector/Variable/PhpSpecToPHPUnitRector/PhpSpecToPHPUnitRectorTest.php @@ -5,12 +5,6 @@ namespace Rector\PhpSpecToPHPUnit\Tests\Rector\Variable\PhpSpecToPHPUnitRector; use Iterator; -use Rector\PhpSpecToPHPUnit\Rector\Class_\AddMockPropertiesRector; -use Rector\PhpSpecToPHPUnit\Rector\Class_\PhpSpecClassToPHPUnitClassRector; -use Rector\PhpSpecToPHPUnit\Rector\ClassMethod\PhpSpecMethodToPHPUnitMethodRector; -use Rector\PhpSpecToPHPUnit\Rector\MethodCall\PhpSpecMocksToPHPUnitMocksRector; -use Rector\PhpSpecToPHPUnit\Rector\MethodCall\PhpSpecPromisesToPHPUnitAssertRector; -use Rector\PhpSpecToPHPUnit\Rector\Variable\MockVariableToPropertyFetchRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -29,19 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - # 1. first convert mocks - PhpSpecMocksToPHPUnitMocksRector::class => [], - PhpSpecPromisesToPHPUnitAssertRector::class => [], - PhpSpecMethodToPHPUnitMethodRector::class => [], - PhpSpecClassToPHPUnitClassRector::class => [], - AddMockPropertiesRector::class => [], - MockVariableToPropertyFetchRector::class => [], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/php-spec-to-phpunit/tests/Rector/Variable/PhpSpecToPHPUnitRector/config/configured_rule.php b/rules/php-spec-to-phpunit/tests/Rector/Variable/PhpSpecToPHPUnitRector/config/configured_rule.php new file mode 100644 index 000000000000..045eb993ac05 --- /dev/null +++ b/rules/php-spec-to-phpunit/tests/Rector/Variable/PhpSpecToPHPUnitRector/config/configured_rule.php @@ -0,0 +1,16 @@ +services(); + $services->set( + # 1. first convert mocks + \Rector\PhpSpecToPHPUnit\Rector\MethodCall\PhpSpecMocksToPHPUnitMocksRector::class + ); + $services->set(\Rector\PhpSpecToPHPUnit\Rector\MethodCall\PhpSpecPromisesToPHPUnitAssertRector::class); + $services->set(\Rector\PhpSpecToPHPUnit\Rector\ClassMethod\PhpSpecMethodToPHPUnitMethodRector::class); + $services->set(\Rector\PhpSpecToPHPUnit\Rector\Class_\PhpSpecClassToPHPUnitClassRector::class); + $services->set(\Rector\PhpSpecToPHPUnit\Rector\Class_\AddMockPropertiesRector::class); + $services->set(\Rector\PhpSpecToPHPUnit\Rector\Variable\MockVariableToPropertyFetchRector::class); +}; diff --git a/rules/php71/tests/Rector/Name/ReservedObjectRector/ReservedObjectRectorTest.php b/rules/php71/tests/Rector/Name/ReservedObjectRector/ReservedObjectRectorTest.php index 570f42173070..c4b5066ac4be 100644 --- a/rules/php71/tests/Rector/Name/ReservedObjectRector/ReservedObjectRectorTest.php +++ b/rules/php71/tests/Rector/Name/ReservedObjectRector/ReservedObjectRectorTest.php @@ -5,7 +5,6 @@ namespace Rector\Php71\Tests\Rector\Name\ReservedObjectRector; use Iterator; -use Rector\Php71\Rector\Name\ReservedObjectRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -24,18 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - ReservedObjectRector::class => [ - ReservedObjectRector::RESERVED_KEYWORDS_TO_REPLACEMENTS => [ - 'ReservedObject' => 'SmartObject', - 'Object' => 'AnotherSmartObject', - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/php71/tests/Rector/Name/ReservedObjectRector/config/configured_rule.php b/rules/php71/tests/Rector/Name/ReservedObjectRector/config/configured_rule.php new file mode 100644 index 000000000000..11dd63a5920f --- /dev/null +++ b/rules/php71/tests/Rector/Name/ReservedObjectRector/config/configured_rule.php @@ -0,0 +1,13 @@ +services(); + $services->set(\Rector\Php71\Rector\Name\ReservedObjectRector::class)->call('configure', [[ + \Rector\Php71\Rector\Name\ReservedObjectRector::RESERVED_KEYWORDS_TO_REPLACEMENTS => [ + 'ReservedObject' => 'SmartObject', + 'Object' => 'AnotherSmartObject', + ], + ]]); +}; diff --git a/rules/php74/tests/Rector/Function_/ReservedFnFunctionRector/ReservedFnFunctionRectorTest.php b/rules/php74/tests/Rector/Function_/ReservedFnFunctionRector/ReservedFnFunctionRectorTest.php index f58e396f309b..1bbc508aa470 100644 --- a/rules/php74/tests/Rector/Function_/ReservedFnFunctionRector/ReservedFnFunctionRectorTest.php +++ b/rules/php74/tests/Rector/Function_/ReservedFnFunctionRector/ReservedFnFunctionRectorTest.php @@ -5,7 +5,6 @@ namespace Rector\Php74\Tests\Rector\Function_\ReservedFnFunctionRector; use Iterator; -use Rector\Php74\Rector\Function_\ReservedFnFunctionRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -24,18 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - ReservedFnFunctionRector::class => [ - ReservedFnFunctionRector::RESERVED_NAMES_TO_NEW_ONES => [ - // for testing purposes of "fn" even on PHP 7.3- - 'reservedFn' => 'f', - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/php74/tests/Rector/Function_/ReservedFnFunctionRector/config/configured_rule.php b/rules/php74/tests/Rector/Function_/ReservedFnFunctionRector/config/configured_rule.php new file mode 100644 index 000000000000..01ad0c2d5c90 --- /dev/null +++ b/rules/php74/tests/Rector/Function_/ReservedFnFunctionRector/config/configured_rule.php @@ -0,0 +1,13 @@ +services(); + $services->set(\Rector\Php74\Rector\Function_\ReservedFnFunctionRector::class)->call('configure', [[ + \Rector\Php74\Rector\Function_\ReservedFnFunctionRector::RESERVED_NAMES_TO_NEW_ONES => [ + // for testing purposes of "fn" even on PHP 7.3- + 'reservedFn' => 'f', + ], + ]]); +}; diff --git a/rules/php74/tests/Rector/LNumber/AddLiteralSeparatorToNumberRector/AddLiteralSeparatorToNumberRectorTest.php b/rules/php74/tests/Rector/LNumber/AddLiteralSeparatorToNumberRector/AddLiteralSeparatorToNumberRectorTest.php index 3e7f71dcbd8b..8e81144913dd 100644 --- a/rules/php74/tests/Rector/LNumber/AddLiteralSeparatorToNumberRector/AddLiteralSeparatorToNumberRectorTest.php +++ b/rules/php74/tests/Rector/LNumber/AddLiteralSeparatorToNumberRector/AddLiteralSeparatorToNumberRectorTest.php @@ -5,7 +5,6 @@ namespace Rector\Php74\Tests\Rector\LNumber\AddLiteralSeparatorToNumberRector; use Iterator; -use Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -24,15 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - AddLiteralSeparatorToNumberRector::class => [ - AddLiteralSeparatorToNumberRector::LIMIT_VALUE => 1000000, - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/php74/tests/Rector/LNumber/AddLiteralSeparatorToNumberRector/config/configured_rule.php b/rules/php74/tests/Rector/LNumber/AddLiteralSeparatorToNumberRector/config/configured_rule.php new file mode 100644 index 000000000000..b2c4d976eb8a --- /dev/null +++ b/rules/php74/tests/Rector/LNumber/AddLiteralSeparatorToNumberRector/config/configured_rule.php @@ -0,0 +1,10 @@ +services(); + $services->set(\Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector::class)->call('configure', [[ + \Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector::LIMIT_VALUE => 1000000, + ]]); +}; diff --git a/rules/php74/tests/Rector/Property/TypedPropertyRector/ClassLikeTypesOnlyTest.php b/rules/php74/tests/Rector/Property/TypedPropertyRector/ClassLikeTypesOnlyTest.php index a061c84e2a32..6490206ad062 100644 --- a/rules/php74/tests/Rector/Property/TypedPropertyRector/ClassLikeTypesOnlyTest.php +++ b/rules/php74/tests/Rector/Property/TypedPropertyRector/ClassLikeTypesOnlyTest.php @@ -5,7 +5,6 @@ namespace Rector\Php74\Tests\Rector\Property\TypedPropertyRector; use Iterator; -use Rector\Php74\Rector\Property\TypedPropertyRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -24,15 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/FixtureClassLikeTypeOnly'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - TypedPropertyRector::class => [ - TypedPropertyRector::CLASS_LIKE_TYPE_ONLY => true, - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/class_types_only.php'); } } diff --git a/rules/php74/tests/Rector/Property/TypedPropertyRector/DoctrineTypedPropertyRectorTest.php b/rules/php74/tests/Rector/Property/TypedPropertyRector/DoctrineTypedPropertyRectorTest.php index 3f8137d84a5b..e5ee32d4b892 100644 --- a/rules/php74/tests/Rector/Property/TypedPropertyRector/DoctrineTypedPropertyRectorTest.php +++ b/rules/php74/tests/Rector/Property/TypedPropertyRector/DoctrineTypedPropertyRectorTest.php @@ -6,7 +6,6 @@ use Iterator; use Rector\Core\ValueObject\PhpVersionFeature; -use Rector\Php74\Rector\Property\TypedPropertyRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -25,16 +24,9 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/FixtureDoctrine'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - TypedPropertyRector::class => [ - TypedPropertyRector::CLASS_LIKE_TYPE_ONLY => false, - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } protected function getPhpVersion(): int diff --git a/rules/php74/tests/Rector/Property/TypedPropertyRector/TypedPropertyRectorTest.php b/rules/php74/tests/Rector/Property/TypedPropertyRector/TypedPropertyRectorTest.php index ae403fa377e8..655ea1f90e50 100644 --- a/rules/php74/tests/Rector/Property/TypedPropertyRector/TypedPropertyRectorTest.php +++ b/rules/php74/tests/Rector/Property/TypedPropertyRector/TypedPropertyRectorTest.php @@ -6,7 +6,6 @@ use Iterator; use Rector\Core\ValueObject\PhpVersionFeature; -use Rector\Php74\Rector\Property\TypedPropertyRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -30,15 +29,8 @@ protected function getPhpVersion(): int return PhpVersionFeature::UNION_TYPES - 1; } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - TypedPropertyRector::class => [ - TypedPropertyRector::CLASS_LIKE_TYPE_ONLY => false, - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/php74/tests/Rector/Property/TypedPropertyRector/config/class_types_only.php b/rules/php74/tests/Rector/Property/TypedPropertyRector/config/class_types_only.php new file mode 100644 index 000000000000..a6bdcff520ee --- /dev/null +++ b/rules/php74/tests/Rector/Property/TypedPropertyRector/config/class_types_only.php @@ -0,0 +1,10 @@ +services(); + $services->set(\Rector\Php74\Rector\Property\TypedPropertyRector::class)->call('configure', [[ + \Rector\Php74\Rector\Property\TypedPropertyRector::CLASS_LIKE_TYPE_ONLY => true, + ]]); +}; diff --git a/rules/php74/tests/Rector/Property/TypedPropertyRector/config/configured_rule.php b/rules/php74/tests/Rector/Property/TypedPropertyRector/config/configured_rule.php new file mode 100644 index 000000000000..f857d064ee24 --- /dev/null +++ b/rules/php74/tests/Rector/Property/TypedPropertyRector/config/configured_rule.php @@ -0,0 +1,10 @@ +services(); + $services->set(\Rector\Php74\Rector\Property\TypedPropertyRector::class)->call('configure', [[ + \Rector\Php74\Rector\Property\TypedPropertyRector::CLASS_LIKE_TYPE_ONLY => false, + ]]); +}; diff --git a/rules/phpunit/src/Rector/Class_/ArrayArgumentInTestToDataProviderRector.php b/rules/phpunit/src/Rector/Class_/ArrayArgumentToDataProviderRector.php similarity index 97% rename from rules/phpunit/src/Rector/Class_/ArrayArgumentInTestToDataProviderRector.php rename to rules/phpunit/src/Rector/Class_/ArrayArgumentToDataProviderRector.php index fc7327465dc5..a89eca535af7 100644 --- a/rules/phpunit/src/Rector/Class_/ArrayArgumentInTestToDataProviderRector.php +++ b/rules/phpunit/src/Rector/Class_/ArrayArgumentToDataProviderRector.php @@ -34,11 +34,11 @@ use Webmozart\Assert\Assert; /** - * @see \Rector\PHPUnit\Tests\Rector\Class_\ArrayArgumentInTestToDataProviderRector\ArrayArgumentInTestToDataProviderRectorTest + * @see \Rector\PHPUnit\Tests\Rector\Class_\ArrayArgumentToDataProviderRector\ArrayArgumentToDataProviderRectorTest * * @see why → https://blog.martinhujer.cz/how-to-use-data-providers-in-phpunit/ */ -final class ArrayArgumentInTestToDataProviderRector extends AbstractRector implements ConfigurableRectorInterface +final class ArrayArgumentToDataProviderRector extends AbstractRector implements ConfigurableRectorInterface { /** * @api diff --git a/rules/phpunit/tests/Rector/Class_/ArrayArgumentInTestToDataProviderRector/ArrayArgumentInTestToDataProviderRectorTest.php b/rules/phpunit/tests/Rector/Class_/ArrayArgumentInTestToDataProviderRector/ArrayArgumentInTestToDataProviderRectorTest.php deleted file mode 100644 index 96c03f9a6de5..000000000000 --- a/rules/phpunit/tests/Rector/Class_/ArrayArgumentInTestToDataProviderRector/ArrayArgumentInTestToDataProviderRectorTest.php +++ /dev/null @@ -1,46 +0,0 @@ -doTestFileInfo($fileInfo); - } - - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array - { - return [ - ArrayArgumentInTestToDataProviderRector::class => [ - ArrayArgumentInTestToDataProviderRector::ARRAY_ARGUMENTS_TO_DATA_PROVIDERS => [ - new ArrayArgumentToDataProvider( - 'PHPUnit\Framework\TestCase', - 'doTestMultiple', - 'doTestSingle', - 'variable' - ), - ], - ], - ]; - } -} diff --git a/rules/phpunit/tests/Rector/Class_/ArrayArgumentToDataProviderRector/ArrayArgumentToDataProviderRectorTest.php b/rules/phpunit/tests/Rector/Class_/ArrayArgumentToDataProviderRector/ArrayArgumentToDataProviderRectorTest.php new file mode 100644 index 000000000000..6ba4821192a3 --- /dev/null +++ b/rules/phpunit/tests/Rector/Class_/ArrayArgumentToDataProviderRector/ArrayArgumentToDataProviderRectorTest.php @@ -0,0 +1,30 @@ +doTestFileInfo($fileInfo); + } + + public function provideData(): Iterator + { + return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); + } + + protected function provideConfigFileInfo(): ?SmartFileInfo + { + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); + } +} diff --git a/rules/phpunit/tests/Rector/Class_/ArrayArgumentInTestToDataProviderRector/Fixture/fixture.php.inc b/rules/phpunit/tests/Rector/Class_/ArrayArgumentToDataProviderRector/Fixture/fixture.php.inc similarity index 72% rename from rules/phpunit/tests/Rector/Class_/ArrayArgumentInTestToDataProviderRector/Fixture/fixture.php.inc rename to rules/phpunit/tests/Rector/Class_/ArrayArgumentToDataProviderRector/Fixture/fixture.php.inc index 591e4953eb56..ab7f8a17b722 100644 --- a/rules/phpunit/tests/Rector/Class_/ArrayArgumentInTestToDataProviderRector/Fixture/fixture.php.inc +++ b/rules/phpunit/tests/Rector/Class_/ArrayArgumentToDataProviderRector/Fixture/fixture.php.inc @@ -1,6 +1,6 @@ services(); + + $services->set(ArrayArgumentToDataProviderRector::class) + ->call('configure', [[ + ArrayArgumentToDataProviderRector::ARRAY_ARGUMENTS_TO_DATA_PROVIDERS => ValueObjectInliner::inline([ + new ArrayArgumentToDataProvider( + 'PHPUnit\Framework\TestCase', + 'doTestMultiple', + 'doTestSingle', + 'variable' + ), + ]), + ]]); +}; diff --git a/rules/removing-static/tests/Rector/Class_/PHPUnitStaticToKernelTestCaseGetRector/PHPUnitStaticToKernelTestCaseGetRectorTest.php b/rules/removing-static/tests/Rector/Class_/PHPUnitStaticToKernelTestCaseGetRector/PHPUnitStaticToKernelTestCaseGetRectorTest.php index ed3e1b96899f..34ead9c7c902 100644 --- a/rules/removing-static/tests/Rector/Class_/PHPUnitStaticToKernelTestCaseGetRector/PHPUnitStaticToKernelTestCaseGetRectorTest.php +++ b/rules/removing-static/tests/Rector/Class_/PHPUnitStaticToKernelTestCaseGetRector/PHPUnitStaticToKernelTestCaseGetRectorTest.php @@ -5,8 +5,6 @@ namespace Rector\RemovingStatic\Tests\Rector\Class_\PHPUnitStaticToKernelTestCaseGetRector; use Iterator; -use Rector\RemovingStatic\Rector\Class_\PHPUnitStaticToKernelTestCaseGetRector; -use Rector\RemovingStatic\Tests\Rector\Class_\PHPUnitStaticToKernelTestCaseGetRector\Source\ClassWithStaticMethods; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -25,15 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - PHPUnitStaticToKernelTestCaseGetRector::class => [ - PHPUnitStaticToKernelTestCaseGetRector::STATIC_CLASS_TYPES => [ClassWithStaticMethods::class], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/removing-static/tests/Rector/Class_/PHPUnitStaticToKernelTestCaseGetRector/config/configured_rule.php b/rules/removing-static/tests/Rector/Class_/PHPUnitStaticToKernelTestCaseGetRector/config/configured_rule.php new file mode 100644 index 000000000000..bcbb47e6b7a1 --- /dev/null +++ b/rules/removing-static/tests/Rector/Class_/PHPUnitStaticToKernelTestCaseGetRector/config/configured_rule.php @@ -0,0 +1,15 @@ +services(); + $services->set(\Rector\RemovingStatic\Rector\Class_\PHPUnitStaticToKernelTestCaseGetRector::class)->call( + 'configure', + [[ + \Rector\RemovingStatic\Rector\Class_\PHPUnitStaticToKernelTestCaseGetRector::STATIC_CLASS_TYPES => [ + \Rector\RemovingStatic\Tests\Rector\Class_\PHPUnitStaticToKernelTestCaseGetRector\Source\ClassWithStaticMethods::class, + ], + ]] + ); +}; diff --git a/rules/removing-static/tests/Rector/Class_/PassFactoryToEntityRector/PassFactoryToEntityRectorTest.php b/rules/removing-static/tests/Rector/Class_/PassFactoryToEntityRector/PassFactoryToEntityRectorTest.php index e1064b32bfc4..67f5b92b4e21 100644 --- a/rules/removing-static/tests/Rector/Class_/PassFactoryToEntityRector/PassFactoryToEntityRectorTest.php +++ b/rules/removing-static/tests/Rector/Class_/PassFactoryToEntityRector/PassFactoryToEntityRectorTest.php @@ -5,9 +5,6 @@ namespace Rector\RemovingStatic\Tests\Rector\Class_\PassFactoryToEntityRector; use Iterator; -use Rector\RemovingStatic\Rector\Class_\NewUniqueObjectToEntityFactoryRector; -use Rector\RemovingStatic\Rector\Class_\PassFactoryToUniqueObjectRector; -use Rector\RemovingStatic\Tests\Rector\Class_\PassFactoryToEntityRector\Source\TurnMeToService; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\EasyTesting\StaticFixtureSplitter; use Symplify\SmartFileSystem\SmartFileInfo; @@ -35,20 +32,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/FixtureWithMultipleArguments'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - $typesToServices = [TurnMeToService::class]; - - return [ - PassFactoryToUniqueObjectRector::class => [ - PassFactoryToUniqueObjectRector::TYPES_TO_SERVICES => $typesToServices, - ], - NewUniqueObjectToEntityFactoryRector::class => [ - NewUniqueObjectToEntityFactoryRector::TYPES_TO_SERVICES => $typesToServices, - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/removing-static/tests/Rector/Class_/PassFactoryToEntityRector/config/configured_rule.php b/rules/removing-static/tests/Rector/Class_/PassFactoryToEntityRector/config/configured_rule.php new file mode 100644 index 000000000000..c805c5bdf6d7 --- /dev/null +++ b/rules/removing-static/tests/Rector/Class_/PassFactoryToEntityRector/config/configured_rule.php @@ -0,0 +1,24 @@ +services(); + + $typesToServices = [TurnMeToService::class]; + + $services->set(PassFactoryToUniqueObjectRector::class) + ->call('configure', [[ + PassFactoryToUniqueObjectRector::TYPES_TO_SERVICES => $typesToServices, + ]]); + + $services->set(NewUniqueObjectToEntityFactoryRector::class) + ->call('configure', [[ + NewUniqueObjectToEntityFactoryRector::TYPES_TO_SERVICES => $typesToServices, + ]]); +}; diff --git a/rules/removing-static/tests/Rector/Class_/StaticTypeToSetterInjectionRector/StaticTypeToSetterInjectionRectorTest.php b/rules/removing-static/tests/Rector/Class_/StaticTypeToSetterInjectionRector/StaticTypeToSetterInjectionRectorTest.php index 9d7f28fc2d0d..be8251c56065 100644 --- a/rules/removing-static/tests/Rector/Class_/StaticTypeToSetterInjectionRector/StaticTypeToSetterInjectionRectorTest.php +++ b/rules/removing-static/tests/Rector/Class_/StaticTypeToSetterInjectionRector/StaticTypeToSetterInjectionRectorTest.php @@ -5,9 +5,6 @@ namespace Rector\RemovingStatic\Tests\Rector\Class_\StaticTypeToSetterInjectionRector; use Iterator; -use Rector\RemovingStatic\Rector\Class_\StaticTypeToSetterInjectionRector; -use Rector\RemovingStatic\Tests\Rector\Class_\StaticTypeToSetterInjectionRector\Source\GenericEntityFactory; -use Rector\RemovingStatic\Tests\Rector\Class_\StaticTypeToSetterInjectionRector\Source\GenericEntityFactoryWithInterface; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -26,19 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - StaticTypeToSetterInjectionRector::class => [ - StaticTypeToSetterInjectionRector::STATIC_TYPES => [ - GenericEntityFactory::class, - // with adding a parent interface to the class - 'ParentSetterEnforcingInterface' => GenericEntityFactoryWithInterface::class, - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/removing-static/tests/Rector/Class_/StaticTypeToSetterInjectionRector/config/configured_rule.php b/rules/removing-static/tests/Rector/Class_/StaticTypeToSetterInjectionRector/config/configured_rule.php new file mode 100644 index 000000000000..8e65151424e0 --- /dev/null +++ b/rules/removing-static/tests/Rector/Class_/StaticTypeToSetterInjectionRector/config/configured_rule.php @@ -0,0 +1,14 @@ +services(); + $services->set(\Rector\RemovingStatic\Rector\Class_\StaticTypeToSetterInjectionRector::class)->call('configure', [[ + \Rector\RemovingStatic\Rector\Class_\StaticTypeToSetterInjectionRector::STATIC_TYPES => [ + \Rector\RemovingStatic\Tests\Rector\Class_\StaticTypeToSetterInjectionRector\Source\GenericEntityFactory::class, + // with adding a parent interface to the class + 'ParentSetterEnforcingInterface' => \Rector\RemovingStatic\Tests\Rector\Class_\StaticTypeToSetterInjectionRector\Source\GenericEntityFactoryWithInterface::class, + ], + ]]); +}; diff --git a/rules/removing/tests/Rector/ClassMethod/ArgumentRemoverRector/ArgumentRemoverRectorTest.php b/rules/removing/tests/Rector/ClassMethod/ArgumentRemoverRector/ArgumentRemoverRectorTest.php index 961a8f0e9876..ac42746726ad 100644 --- a/rules/removing/tests/Rector/ClassMethod/ArgumentRemoverRector/ArgumentRemoverRectorTest.php +++ b/rules/removing/tests/Rector/ClassMethod/ArgumentRemoverRector/ArgumentRemoverRectorTest.php @@ -5,12 +5,7 @@ namespace Rector\Removing\Tests\Rector\ClassMethod\ArgumentRemoverRector; use Iterator; -use Rector\Removing\Rector\ClassMethod\ArgumentRemoverRector; -use Rector\Removing\Tests\Rector\ClassMethod\ArgumentRemoverRector\Source\Persister; -use Rector\Removing\Tests\Rector\ClassMethod\ArgumentRemoverRector\Source\RemoveInTheMiddle; -use Rector\Removing\ValueObject\ArgumentRemover; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Symfony\Component\Yaml\Yaml; use Symplify\SmartFileSystem\SmartFileInfo; final class ArgumentRemoverRectorTest extends AbstractRectorTestCase @@ -28,26 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - ArgumentRemoverRector::class => [ - ArgumentRemoverRector::REMOVED_ARGUMENTS => [ - new ArgumentRemover(Persister::class, 'getSelectJoinColumnSQL', 4, null), - new ArgumentRemover(Yaml::class, 'parse', 1, [ - 'Symfony\Component\Yaml\Yaml::PARSE_KEYS_AS_STRINGS', - 'hey', - 55, - 5.5, - ]), - new ArgumentRemover(RemoveInTheMiddle::class, 'run', 1, [ - 'name' => 'second', - ]), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/removing/tests/Rector/ClassMethod/ArgumentRemoverRector/config/configured_rule.php b/rules/removing/tests/Rector/ClassMethod/ArgumentRemoverRector/config/configured_rule.php new file mode 100644 index 000000000000..f8f15b17ac6b --- /dev/null +++ b/rules/removing/tests/Rector/ClassMethod/ArgumentRemoverRector/config/configured_rule.php @@ -0,0 +1,47 @@ +services(); + $services->set(\Rector\Removing\Rector\ClassMethod\ArgumentRemoverRector::class)->call('configure', [[ + \Rector\Removing\Rector\ClassMethod\ArgumentRemoverRector::REMOVED_ARGUMENTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + new \Rector\Removing\ValueObject\ArgumentRemover( + \Rector\Removing\Tests\Rector\ClassMethod\ArgumentRemoverRector\Source\Persister::class, + 'getSelectJoinColumnSQL', + 4, + null + ), new \Rector\Removing\ValueObject\ArgumentRemover( + \Symfony\Component\Yaml\Yaml::class, + 'parse', + 1, + [ + 'Symfony\Component\Yaml\Yaml::PARSE_KEYS_AS_STRINGS', + 'hey', + 55, + 5.5, + + ]), new \Rector\Removing\ValueObject\ArgumentRemover(\Rector\Removing\Tests\Rector\ClassMethod\ArgumentRemoverRector\Source\RemoveInTheMiddle::class, 'run', 1, [ + 'name' => 'second', + ]), ] + ), + ]]); +}; diff --git a/rules/removing/tests/Rector/Class_/RemoveInterfacesRector/RemoveInterfacesRectorTest.php b/rules/removing/tests/Rector/Class_/RemoveInterfacesRector/RemoveInterfacesRectorTest.php index cb5d8f2b0854..2978ec85e9d2 100644 --- a/rules/removing/tests/Rector/Class_/RemoveInterfacesRector/RemoveInterfacesRectorTest.php +++ b/rules/removing/tests/Rector/Class_/RemoveInterfacesRector/RemoveInterfacesRectorTest.php @@ -5,8 +5,6 @@ namespace Rector\Removing\Tests\Rector\Class_\RemoveInterfacesRector; use Iterator; -use Rector\Removing\Rector\Class_\RemoveInterfacesRector; -use Rector\Removing\Tests\Rector\Class_\RemoveInterfacesRector\Source\SomeInterface; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -25,15 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - RemoveInterfacesRector::class => [ - RemoveInterfacesRector::INTERFACES_TO_REMOVE => [SomeInterface::class], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/removing/tests/Rector/Class_/RemoveInterfacesRector/config/configured_rule.php b/rules/removing/tests/Rector/Class_/RemoveInterfacesRector/config/configured_rule.php new file mode 100644 index 000000000000..0dbf9909ca3e --- /dev/null +++ b/rules/removing/tests/Rector/Class_/RemoveInterfacesRector/config/configured_rule.php @@ -0,0 +1,12 @@ +services(); + $services->set(\Rector\Removing\Rector\Class_\RemoveInterfacesRector::class)->call('configure', [[ + \Rector\Removing\Rector\Class_\RemoveInterfacesRector::INTERFACES_TO_REMOVE => [ + \Rector\Removing\Tests\Rector\Class_\RemoveInterfacesRector\Source\SomeInterface::class, + ], + ]]); +}; diff --git a/rules/removing/tests/Rector/Class_/RemoveParentRector/RemoveParentRectorTest.php b/rules/removing/tests/Rector/Class_/RemoveParentRector/RemoveParentRectorTest.php index 8ae7c7ab2434..85cb49e955a4 100644 --- a/rules/removing/tests/Rector/Class_/RemoveParentRector/RemoveParentRectorTest.php +++ b/rules/removing/tests/Rector/Class_/RemoveParentRector/RemoveParentRectorTest.php @@ -5,8 +5,6 @@ namespace Rector\Removing\Tests\Rector\Class_\RemoveParentRector; use Iterator; -use Rector\Removing\Rector\Class_\RemoveParentRector; -use Rector\Removing\Tests\Rector\Class_\RemoveParentRector\Source\ParentTypeToBeRemoved; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -25,15 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - RemoveParentRector::class => [ - RemoveParentRector::PARENT_TYPES_TO_REMOVE => [ParentTypeToBeRemoved::class], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/removing/tests/Rector/Class_/RemoveParentRector/config/configured_rule.php b/rules/removing/tests/Rector/Class_/RemoveParentRector/config/configured_rule.php new file mode 100644 index 000000000000..83ecc72bcdda --- /dev/null +++ b/rules/removing/tests/Rector/Class_/RemoveParentRector/config/configured_rule.php @@ -0,0 +1,12 @@ +services(); + $services->set(\Rector\Removing\Rector\Class_\RemoveParentRector::class)->call('configure', [[ + \Rector\Removing\Rector\Class_\RemoveParentRector::PARENT_TYPES_TO_REMOVE => [ + \Rector\Removing\Tests\Rector\Class_\RemoveParentRector\Source\ParentTypeToBeRemoved::class, + ], + ]]); +}; diff --git a/rules/removing/tests/Rector/Class_/RemoveTraitRector/RemoveTraitRectorTest.php b/rules/removing/tests/Rector/Class_/RemoveTraitRector/RemoveTraitRectorTest.php index fd62ac914cd8..e431a8590579 100644 --- a/rules/removing/tests/Rector/Class_/RemoveTraitRector/RemoveTraitRectorTest.php +++ b/rules/removing/tests/Rector/Class_/RemoveTraitRector/RemoveTraitRectorTest.php @@ -5,8 +5,6 @@ namespace Rector\Removing\Tests\Rector\Class_\RemoveTraitRector; use Iterator; -use Rector\Removing\Rector\Class_\RemoveTraitRector; -use Rector\Removing\Tests\Rector\Class_\RemoveTraitRector\Source\TraitToBeRemoved; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -25,15 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - RemoveTraitRector::class => [ - RemoveTraitRector::TRAITS_TO_REMOVE => [TraitToBeRemoved::class], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/removing/tests/Rector/Class_/RemoveTraitRector/config/configured_rule.php b/rules/removing/tests/Rector/Class_/RemoveTraitRector/config/configured_rule.php new file mode 100644 index 000000000000..2cb3ef1c2166 --- /dev/null +++ b/rules/removing/tests/Rector/Class_/RemoveTraitRector/config/configured_rule.php @@ -0,0 +1,12 @@ +services(); + $services->set(\Rector\Removing\Rector\Class_\RemoveTraitRector::class)->call('configure', [[ + \Rector\Removing\Rector\Class_\RemoveTraitRector::TRAITS_TO_REMOVE => [ + \Rector\Removing\Tests\Rector\Class_\RemoveTraitRector\Source\TraitToBeRemoved::class, + ], + ]]); +}; diff --git a/rules/removing/tests/Rector/FuncCall/RemoveFuncCallArgRector/RemoveFuncCallArgRectorTest.php b/rules/removing/tests/Rector/FuncCall/RemoveFuncCallArgRector/RemoveFuncCallArgRectorTest.php index 3fb09d2b61e0..b6d515d4b471 100644 --- a/rules/removing/tests/Rector/FuncCall/RemoveFuncCallArgRector/RemoveFuncCallArgRectorTest.php +++ b/rules/removing/tests/Rector/FuncCall/RemoveFuncCallArgRector/RemoveFuncCallArgRectorTest.php @@ -5,8 +5,6 @@ namespace Rector\Removing\Tests\Rector\FuncCall\RemoveFuncCallArgRector; use Iterator; -use Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector; -use Rector\Removing\ValueObject\RemoveFuncCallArg; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use SplFileInfo; use Symplify\SmartFileSystem\SmartFileInfo; @@ -29,17 +27,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - RemoveFuncCallArgRector::class => [ - RemoveFuncCallArgRector::REMOVED_FUNCTION_ARGUMENTS => [ - new RemoveFuncCallArg('ldap_first_attribute', 2), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/removing/tests/Rector/FuncCall/RemoveFuncCallArgRector/config/configured_rule.php b/rules/removing/tests/Rector/FuncCall/RemoveFuncCallArgRector/config/configured_rule.php new file mode 100644 index 000000000000..325c50c4e0f9 --- /dev/null +++ b/rules/removing/tests/Rector/FuncCall/RemoveFuncCallArgRector/config/configured_rule.php @@ -0,0 +1,55 @@ +services(); + $services->set(\Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::class)->call('configure', [[ + \Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::REMOVED_FUNCTION_ARGUMENTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + new \Rector\Removing\ValueObject\RemoveFuncCallArg('ldap_first_attribute', 2), + + + + + + + + + + + + + + + + + + + + + + + + + + ]), + ]]); +}; diff --git a/rules/removing/tests/Rector/FuncCall/RemoveFuncCallRector/RemoveFuncCallRectorTest.php b/rules/removing/tests/Rector/FuncCall/RemoveFuncCallRector/RemoveFuncCallRectorTest.php index f0248906647e..cbd82121826b 100644 --- a/rules/removing/tests/Rector/FuncCall/RemoveFuncCallRector/RemoveFuncCallRectorTest.php +++ b/rules/removing/tests/Rector/FuncCall/RemoveFuncCallRector/RemoveFuncCallRectorTest.php @@ -5,8 +5,6 @@ namespace Rector\Removing\Tests\Rector\FuncCall\RemoveFuncCallRector; use Iterator; -use Rector\Removing\Rector\FuncCall\RemoveFuncCallRector; -use Rector\Removing\ValueObject\RemoveFuncCall; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use SplFileInfo; use Symplify\SmartFileSystem\SmartFileInfo; @@ -29,22 +27,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - RemoveFuncCallRector::class => [ - RemoveFuncCallRector::REMOVE_FUNC_CALLS => [ - new RemoveFuncCall('ini_get', [ - 0 => ['y2k_compliance', 'safe_mode', 'magic_quotes_runtime'], - ]), - new RemoveFuncCall('ini_set', [ - 0 => ['y2k_compliance', 'safe_mode', 'magic_quotes_runtime'], - ]), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/removing/tests/Rector/FuncCall/RemoveFuncCallRector/config/configured_rule.php b/rules/removing/tests/Rector/FuncCall/RemoveFuncCallRector/config/configured_rule.php new file mode 100644 index 000000000000..49d89e227c9e --- /dev/null +++ b/rules/removing/tests/Rector/FuncCall/RemoveFuncCallRector/config/configured_rule.php @@ -0,0 +1,34 @@ +services(); + $services->set(\Rector\Removing\Rector\FuncCall\RemoveFuncCallRector::class)->call('configure', [[ + \Rector\Removing\Rector\FuncCall\RemoveFuncCallRector::REMOVE_FUNC_CALLS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + new \Rector\Removing\ValueObject\RemoveFuncCall('ini_get', [ + 0 => ['y2k_compliance', 'safe_mode', 'magic_quotes_runtime'], + ]), new \Rector\Removing\ValueObject\RemoveFuncCall('ini_set', [ + 0 => ['y2k_compliance', 'safe_mode', 'magic_quotes_runtime'], + ]), ] + ), + ]]); +}; diff --git a/rules/renaming/tests/Rector/ClassConstFetch/RenameClassConstFetchRector/RenameClassConstFetchRectorTest.php b/rules/renaming/tests/Rector/ClassConstFetch/RenameClassConstFetchRector/RenameClassConstFetchRectorTest.php index d56b6c492ef2..4d428919efd7 100644 --- a/rules/renaming/tests/Rector/ClassConstFetch/RenameClassConstFetchRector/RenameClassConstFetchRectorTest.php +++ b/rules/renaming/tests/Rector/ClassConstFetch/RenameClassConstFetchRector/RenameClassConstFetchRectorTest.php @@ -5,11 +5,6 @@ namespace Rector\Renaming\Tests\Rector\ClassConstFetch\RenameClassConstFetchRector; use Iterator; -use Rector\Renaming\Rector\ClassConstFetch\RenameClassConstFetchRector; -use Rector\Renaming\Tests\Rector\ClassConstFetch\RenameClassConstFetchRector\Source\DifferentClass; -use Rector\Renaming\Tests\Rector\ClassConstFetch\RenameClassConstFetchRector\Source\LocalFormEvents; -use Rector\Renaming\ValueObject\RenameClassAndConstFetch; -use Rector\Renaming\ValueObject\RenameClassConstFetch; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -28,25 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - RenameClassConstFetchRector::class => [ - RenameClassConstFetchRector::CLASS_CONSTANT_RENAME => [ - new RenameClassConstFetch(LocalFormEvents::class, 'PRE_BIND', 'PRE_SUBMIT'), - new RenameClassConstFetch(LocalFormEvents::class, 'BIND', 'SUBMIT'), - new RenameClassConstFetch(LocalFormEvents::class, 'POST_BIND', 'POST_SUBMIT'), - new RenameClassAndConstFetch( - LocalFormEvents::class, - 'OLD_CONSTANT', - DifferentClass::class, - 'NEW_CONSTANT' - ), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/renaming/tests/Rector/ClassConstFetch/RenameClassConstFetchRector/config/configured_rule.php b/rules/renaming/tests/Rector/ClassConstFetch/RenameClassConstFetchRector/config/configured_rule.php new file mode 100644 index 000000000000..ddd7b2bdbc46 --- /dev/null +++ b/rules/renaming/tests/Rector/ClassConstFetch/RenameClassConstFetchRector/config/configured_rule.php @@ -0,0 +1,75 @@ +services(); + $services->set(\Rector\Renaming\Rector\ClassConstFetch\RenameClassConstFetchRector::class)->call('configure', [[ + \Rector\Renaming\Rector\ClassConstFetch\RenameClassConstFetchRector::CLASS_CONSTANT_RENAME => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + new \Rector\Renaming\ValueObject\RenameClassConstFetch( + \Rector\Renaming\Tests\Rector\ClassConstFetch\RenameClassConstFetchRector\Source\LocalFormEvents::class, + 'PRE_BIND', + 'PRE_SUBMIT' + ), + new \Rector\Renaming\ValueObject\RenameClassConstFetch( + \Rector\Renaming\Tests\Rector\ClassConstFetch\RenameClassConstFetchRector\Source\LocalFormEvents::class, + 'BIND', + 'SUBMIT' + ), + new \Rector\Renaming\ValueObject\RenameClassConstFetch( + \Rector\Renaming\Tests\Rector\ClassConstFetch\RenameClassConstFetchRector\Source\LocalFormEvents::class, + 'POST_BIND', + 'POST_SUBMIT' + ), + new \Rector\Renaming\ValueObject\RenameClassAndConstFetch( + \Rector\Renaming\Tests\Rector\ClassConstFetch\RenameClassConstFetchRector\Source\LocalFormEvents::class, + 'OLD_CONSTANT', + \Rector\Renaming\Tests\Rector\ClassConstFetch\RenameClassConstFetchRector\Source\DifferentClass::class, + 'NEW_CONSTANT' + ), + + + + + + + + + + + + + + + + + + + + + + + + + + ]), + ]]); +}; diff --git a/rules/renaming/tests/Rector/ClassMethod/RenameAnnotationRector/RenameAnnotationRectorTest.php b/rules/renaming/tests/Rector/ClassMethod/RenameAnnotationRector/RenameAnnotationRectorTest.php index 4179c8cbd92c..4ccc8398dc4a 100644 --- a/rules/renaming/tests/Rector/ClassMethod/RenameAnnotationRector/RenameAnnotationRectorTest.php +++ b/rules/renaming/tests/Rector/ClassMethod/RenameAnnotationRector/RenameAnnotationRectorTest.php @@ -5,8 +5,6 @@ namespace Rector\Renaming\Tests\Rector\ClassMethod\RenameAnnotationRector; use Iterator; -use Rector\Renaming\Rector\ClassMethod\RenameAnnotationRector; -use Rector\Renaming\ValueObject\RenameAnnotation; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -25,17 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - RenameAnnotationRector::class => [ - RenameAnnotationRector::RENAMED_ANNOTATIONS_IN_TYPES => [ - new RenameAnnotation('PHPUnit\Framework\TestCase', 'scenario', 'test'), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/renaming/tests/Rector/ClassMethod/RenameAnnotationRector/config/configured_rule.php b/rules/renaming/tests/Rector/ClassMethod/RenameAnnotationRector/config/configured_rule.php new file mode 100644 index 000000000000..d51d6eb1a8f3 --- /dev/null +++ b/rules/renaming/tests/Rector/ClassMethod/RenameAnnotationRector/config/configured_rule.php @@ -0,0 +1,59 @@ +services(); + $services->set(\Rector\Renaming\Rector\ClassMethod\RenameAnnotationRector::class)->call('configure', [[ + \Rector\Renaming\Rector\ClassMethod\RenameAnnotationRector::RENAMED_ANNOTATIONS_IN_TYPES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + new \Rector\Renaming\ValueObject\RenameAnnotation( + 'PHPUnit\Framework\TestCase', + 'scenario', + 'test' + ), + + + + + + + + + + + + + + + + + + + + + + + + + + ]), + ]]); +}; diff --git a/rules/renaming/tests/Rector/ConstFetch/RenameConstantRector/RenameConstantRectorTest.php b/rules/renaming/tests/Rector/ConstFetch/RenameConstantRector/RenameConstantRectorTest.php index 8ff4e987bd77..5d816d361713 100644 --- a/rules/renaming/tests/Rector/ConstFetch/RenameConstantRector/RenameConstantRectorTest.php +++ b/rules/renaming/tests/Rector/ConstFetch/RenameConstantRector/RenameConstantRectorTest.php @@ -5,7 +5,6 @@ namespace Rector\Renaming\Tests\Rector\ConstFetch\RenameConstantRector; use Iterator; -use Rector\Renaming\Rector\ConstFetch\RenameConstantRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -24,18 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - RenameConstantRector::class => [ - RenameConstantRector::OLD_TO_NEW_CONSTANTS => [ - 'MYSQL_ASSOC' => 'MYSQLI_ASSOC', - 'OLD_CONSTANT' => 'NEW_CONSTANT', - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/renaming/tests/Rector/ConstFetch/RenameConstantRector/config/configured_rule.php b/rules/renaming/tests/Rector/ConstFetch/RenameConstantRector/config/configured_rule.php new file mode 100644 index 000000000000..cd44afbcf6d7 --- /dev/null +++ b/rules/renaming/tests/Rector/ConstFetch/RenameConstantRector/config/configured_rule.php @@ -0,0 +1,13 @@ +services(); + $services->set(\Rector\Renaming\Rector\ConstFetch\RenameConstantRector::class)->call('configure', [[ + \Rector\Renaming\Rector\ConstFetch\RenameConstantRector::OLD_TO_NEW_CONSTANTS => [ + 'MYSQL_ASSOC' => 'MYSQLI_ASSOC', + 'OLD_CONSTANT' => 'NEW_CONSTANT', + ], + ]]); +}; diff --git a/rules/renaming/tests/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/PseudoNamespaceToNamespaceRectorTest.php b/rules/renaming/tests/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/PseudoNamespaceToNamespaceRectorTest.php index 7a82af1f540d..2e93a02a809b 100644 --- a/rules/renaming/tests/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/PseudoNamespaceToNamespaceRectorTest.php +++ b/rules/renaming/tests/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/PseudoNamespaceToNamespaceRectorTest.php @@ -5,8 +5,6 @@ namespace Rector\Renaming\Tests\Rector\FileWithoutNamespace\PseudoNamespaceToNamespaceRector; use Iterator; -use Rector\Renaming\Rector\FileWithoutNamespace\PseudoNamespaceToNamespaceRector; -use Rector\Renaming\ValueObject\PseudoNamespaceToNamespace; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -25,21 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - PseudoNamespaceToNamespaceRector::class => [ - PseudoNamespaceToNamespaceRector::NAMESPACE_PREFIXES_WITH_EXCLUDED_CLASSES => [ - new PseudoNamespaceToNamespace('PHPUnit_', ['PHPUnit_Framework_MockObject_MockObject']), - new PseudoNamespaceToNamespace('ChangeMe_', ['KeepMe_']), - new PseudoNamespaceToNamespace( - 'Rector_Renaming_Tests_Rector_FileWithoutNamespace_PseudoNamespaceToNamespaceRector_Fixture_' - ), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/renaming/tests/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/config/configured_rule.php b/rules/renaming/tests/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/config/configured_rule.php new file mode 100644 index 000000000000..a873271a977e --- /dev/null +++ b/rules/renaming/tests/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/config/configured_rule.php @@ -0,0 +1,71 @@ +services(); + $services->set(\Rector\Renaming\Rector\FileWithoutNamespace\PseudoNamespaceToNamespaceRector::class)->call( + 'configure', + [[ + \Rector\Renaming\Rector\FileWithoutNamespace\PseudoNamespaceToNamespaceRector::NAMESPACE_PREFIXES_WITH_EXCLUDED_CLASSES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + + + + + + + + new \Rector\Renaming\ValueObject\PseudoNamespaceToNamespace('PHPUnit_', [ + 'PHPUnit_Framework_MockObject_MockObject', + ]), + new \Rector\Renaming\ValueObject\PseudoNamespaceToNamespace('ChangeMe_', ['KeepMe_']), + new \Rector\Renaming\ValueObject\PseudoNamespaceToNamespace( + 'Rector_Renaming_Tests_Rector_FileWithoutNamespace_PseudoNamespaceToNamespaceRector_Fixture_' + ), + + + + + + + + + + + + + + + + + + + + + + + + + + ]), + ]] + ); +}; diff --git a/rules/renaming/tests/Rector/FuncCall/RenameFunctionRector/RenameFunctionRectorTest.php b/rules/renaming/tests/Rector/FuncCall/RenameFunctionRector/RenameFunctionRectorTest.php index 57107284af1e..fddefe04fd59 100644 --- a/rules/renaming/tests/Rector/FuncCall/RenameFunctionRector/RenameFunctionRectorTest.php +++ b/rules/renaming/tests/Rector/FuncCall/RenameFunctionRector/RenameFunctionRectorTest.php @@ -5,7 +5,6 @@ namespace Rector\Renaming\Tests\Rector\FuncCall\RenameFunctionRector; use Iterator; -use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -24,18 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - RenameFunctionRector::class => [ - RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [ - 'view' => 'Laravel\Templating\render', - 'sprintf' => 'Safe\sprintf', - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/renaming/tests/Rector/FuncCall/RenameFunctionRector/config/configured_rule.php b/rules/renaming/tests/Rector/FuncCall/RenameFunctionRector/config/configured_rule.php new file mode 100644 index 000000000000..1dd8ecb7730f --- /dev/null +++ b/rules/renaming/tests/Rector/FuncCall/RenameFunctionRector/config/configured_rule.php @@ -0,0 +1,13 @@ +services(); + $services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[ + \Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [ + 'view' => 'Laravel\Templating\render', + 'sprintf' => 'Safe\sprintf', + ], + ]]); +}; diff --git a/rules/renaming/tests/Rector/MethodCall/RenameMethodRector/RenameMethodRectorTest.php b/rules/renaming/tests/Rector/MethodCall/RenameMethodRector/RenameMethodRectorTest.php index 2b0373266705..b5ab66cffa87 100644 --- a/rules/renaming/tests/Rector/MethodCall/RenameMethodRector/RenameMethodRectorTest.php +++ b/rules/renaming/tests/Rector/MethodCall/RenameMethodRector/RenameMethodRectorTest.php @@ -5,12 +5,6 @@ namespace Rector\Renaming\Tests\Rector\MethodCall\RenameMethodRector; use Iterator; -use Nette\Utils\Html; -use Rector\Renaming\Rector\MethodCall\RenameMethodRector; -use Rector\Renaming\Tests\Rector\MethodCall\RenameMethodRector\Fixture\SkipSelfMethodRename; -use Rector\Renaming\Tests\Rector\MethodCall\RenameMethodRector\Source\AbstractType; -use Rector\Renaming\ValueObject\MethodCallRename; -use Rector\Renaming\ValueObject\MethodCallRenameWithArrayKey; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -29,22 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - RenameMethodRector::class => [ - RenameMethodRector::METHOD_CALL_RENAMES => [ - new MethodCallRename(AbstractType::class, 'setDefaultOptions', 'configureOptions'), - new MethodCallRename(Html::class, 'add', 'addHtml'), - new MethodCallRename('*Presenter', 'run', '__invoke'), - new MethodCallRename(SkipSelfMethodRename::class, 'preventPHPStormRefactoring', 'gone'), - // with array key - new MethodCallRenameWithArrayKey(Html::class, 'addToArray', 'addToHtmlArray', 'hey'), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/renaming/tests/Rector/MethodCall/RenameMethodRector/config/configured_rule.php b/rules/renaming/tests/Rector/MethodCall/RenameMethodRector/config/configured_rule.php new file mode 100644 index 000000000000..3311289415d7 --- /dev/null +++ b/rules/renaming/tests/Rector/MethodCall/RenameMethodRector/config/configured_rule.php @@ -0,0 +1,30 @@ +services(); + $services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->call('configure', [[ + \Rector\Renaming\Rector\MethodCall\RenameMethodRector::METHOD_CALL_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + new \Rector\Renaming\ValueObject\MethodCallRename( + \Rector\Renaming\Tests\Rector\MethodCall\RenameMethodRector\Source\AbstractType::class, + 'setDefaultOptions', + 'configureOptions' + ), + new \Rector\Renaming\ValueObject\MethodCallRename(\Nette\Utils\Html::class, 'add', 'addHtml'), + new \Rector\Renaming\ValueObject\MethodCallRename('*Presenter', 'run', '__invoke'), + new \Rector\Renaming\ValueObject\MethodCallRename( + \Rector\Renaming\Tests\Rector\MethodCall\RenameMethodRector\Fixture\SkipSelfMethodRename::class, + 'preventPHPStormRefactoring', + 'gone' + ), + // with array key + new \Rector\Renaming\ValueObject\MethodCallRenameWithArrayKey( + \Nette\Utils\Html::class, + 'addToArray', + 'addToHtmlArray', + 'hey' + ), + ]), + ]]); +}; diff --git a/rules/renaming/tests/Rector/Name/RenameClassRector/AutoImportNamesParameter74Test.php b/rules/renaming/tests/Rector/Name/RenameClassRector/AutoImportNamesParameter74Test.php index 4656002b989b..f4624c6d68dc 100644 --- a/rules/renaming/tests/Rector/Name/RenameClassRector/AutoImportNamesParameter74Test.php +++ b/rules/renaming/tests/Rector/Name/RenameClassRector/AutoImportNamesParameter74Test.php @@ -5,11 +5,6 @@ namespace Rector\Renaming\Tests\Rector\Name\RenameClassRector; use Iterator; -use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector; -use Rector\Core\Configuration\Option; -use Rector\Renaming\Rector\Name\RenameClassRector; -use Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\NewClass; -use Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\OldClass; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -24,8 +19,6 @@ final class AutoImportNamesParameter74Test extends AbstractRectorTestCase */ public function test(SmartFileInfo $fileInfo): void { - $this->setParameter(Option::AUTO_IMPORT_NAMES, true); - $this->doTestFileInfo($fileInfo); } @@ -34,19 +27,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/FixtureAutoImportNames74'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - # this class causes to "partial_expression.php.inc" to fail - SimplifyEmptyArrayCheckRector::class => [], - RenameClassRector::class => [ - RenameClassRector::OLD_TO_NEW_CLASSES => [ - OldClass::class => NewClass::class, - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/auto_import_names.php'); } } diff --git a/rules/renaming/tests/Rector/Name/RenameClassRector/AutoImportNamesParameterTest.php b/rules/renaming/tests/Rector/Name/RenameClassRector/AutoImportNamesParameterTest.php index 7a2d8644c48e..ad9de79bff2a 100644 --- a/rules/renaming/tests/Rector/Name/RenameClassRector/AutoImportNamesParameterTest.php +++ b/rules/renaming/tests/Rector/Name/RenameClassRector/AutoImportNamesParameterTest.php @@ -5,11 +5,6 @@ namespace Rector\Renaming\Tests\Rector\Name\RenameClassRector; use Iterator; -use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector; -use Rector\Core\Configuration\Option; -use Rector\Renaming\Rector\Name\RenameClassRector; -use Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\NewClass; -use Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\OldClass; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -23,8 +18,6 @@ final class AutoImportNamesParameterTest extends AbstractRectorTestCase */ public function test(SmartFileInfo $fileInfo): void { - $this->setParameter(Option::AUTO_IMPORT_NAMES, true); - $this->doTestFileInfo($fileInfo); } @@ -33,19 +26,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/FixtureAutoImportNames'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - # this class causes to "partial_expression.php.inc" to fail - SimplifyEmptyArrayCheckRector::class => [], - RenameClassRector::class => [ - RenameClassRector::OLD_TO_NEW_CLASSES => [ - OldClass::class => NewClass::class, - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/auto_import_names.php'); } } diff --git a/rules/renaming/tests/Rector/Name/RenameClassRector/FunctionAutoImportNamesParameterTest.php b/rules/renaming/tests/Rector/Name/RenameClassRector/FunctionAutoImportNamesParameterTest.php index f35b1023eed1..95130c1de740 100644 --- a/rules/renaming/tests/Rector/Name/RenameClassRector/FunctionAutoImportNamesParameterTest.php +++ b/rules/renaming/tests/Rector/Name/RenameClassRector/FunctionAutoImportNamesParameterTest.php @@ -6,9 +6,6 @@ use Iterator; use Rector\Core\Configuration\Option; -use Rector\Renaming\Rector\Name\RenameClassRector; -use Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\NewClass; -use Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\OldClass; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -32,17 +29,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/FixtureAutoImportNamesFunction'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - RenameClassRector::class => [ - RenameClassRector::OLD_TO_NEW_CLASSES => [ - OldClass::class => NewClass::class, - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/renaming/tests/Rector/Name/RenameClassRector/RenameClassRectorTest.php b/rules/renaming/tests/Rector/Name/RenameClassRector/RenameClassRectorTest.php index ad6f654265e1..272212ff0d16 100644 --- a/rules/renaming/tests/Rector/Name/RenameClassRector/RenameClassRectorTest.php +++ b/rules/renaming/tests/Rector/Name/RenameClassRector/RenameClassRectorTest.php @@ -5,15 +5,6 @@ namespace Rector\Renaming\Tests\Rector\Name\RenameClassRector; use Iterator; -use Manual\Twig\TwigFilter; -use Manual_Twig_Filter; -use Rector\Renaming\Rector\Name\RenameClassRector; -use Rector\Renaming\Tests\Rector\Name\RenameClassRector\Fixture\DuplicatedClass; -use Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\AbstractManualExtension; -use Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\NewClass; -use Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\NewClassWithoutTypo; -use Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\OldClass; -use Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\OldClassWithTypo; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -41,37 +32,8 @@ public function testClassNameDuplication(): void $this->doTestFileInfo($fixtureFileInfo); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - RenameClassRector::class => [ - RenameClassRector::OLD_TO_NEW_CLASSES => [ - 'FqnizeNamespaced' => 'Abc\FqnizeNamespaced', - OldClass::class => NewClass::class, - OldClassWithTypo::class => NewClassWithoutTypo::class, - 'DateTime' => 'DateTimeInterface', - 'Countable' => 'stdClass', - Manual_Twig_Filter::class => TwigFilter::class, - 'Twig_AbstractManualExtension' => AbstractManualExtension::class, - 'Twig_Extension_Sandbox' => 'Twig\Extension\SandboxExtension', - // Renaming class itself and its namespace - 'MyNamespace\MyClass' => 'MyNewNamespace\MyNewClass', - 'MyNamespace\MyTrait' => 'MyNewNamespace\MyNewTrait', - 'MyNamespace\MyInterface' => 'MyNewNamespace\MyNewInterface', - 'MyOldClass' => 'MyNamespace\MyNewClass', - 'AnotherMyOldClass' => 'AnotherMyNewClass', - 'MyNamespace\AnotherMyClass' => 'MyNewClassWithoutNamespace', - // test duplicated class - @see https://github.com/rectorphp/rector/issues/1438 - 'Rector\Renaming\Tests\Rector\Name\RenameClassRector\Fixture\SingularClass' => DuplicatedClass::class, - // test duplicated class - @see https://github.com/rectorphp/rector/issues/5389 - 'MyFooInterface' => 'MyBazInterface', - 'MyBarInterface' => 'MyBazInterface', - \Acme\Foo\DoNotUpdateExistingTargetNamespace::class => \Acme\Bar\DoNotUpdateExistingTargetNamespace::class, - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/renaming/tests/Rector/Name/RenameClassRector/RenameNonPhpTest.php b/rules/renaming/tests/Rector/Name/RenameClassRector/RenameNonPhpTest.php index ff03a2e26432..c3d50984227c 100644 --- a/rules/renaming/tests/Rector/Name/RenameClassRector/RenameNonPhpTest.php +++ b/rules/renaming/tests/Rector/Name/RenameClassRector/RenameNonPhpTest.php @@ -6,9 +6,6 @@ use Iterator; use Rector\Core\ValueObject\StaticNonPhpFileSuffixes; -use Rector\Renaming\Rector\Name\RenameClassRector; -use Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\NewClass; -use Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\OldClass; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -30,21 +27,8 @@ public function provideData(): Iterator ); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - RenameClassRector::class => [ - RenameClassRector::OLD_TO_NEW_CLASSES => [ - OldClass::class => NewClass::class, - // Laravel - 'Session' => 'Illuminate\Support\Facades\Session', - 'Form' => 'Collective\Html\FormFacade', - 'Html' => 'Collective\Html\HtmlFacade', - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/non_php_config.php'); } } diff --git a/rules/renaming/tests/Rector/Name/RenameClassRector/config/auto_import_names.php b/rules/renaming/tests/Rector/Name/RenameClassRector/config/auto_import_names.php new file mode 100644 index 000000000000..2348cb2715d5 --- /dev/null +++ b/rules/renaming/tests/Rector/Name/RenameClassRector/config/auto_import_names.php @@ -0,0 +1,25 @@ +parameters(); + $parameters->set(Option::AUTO_IMPORT_NAMES, true); + + $services = $containerConfigurator->services(); + + $services->set(SimplifyEmptyArrayCheckRector::class); + + $services->set(RenameClassRector::class) + ->call('configure', [[ + RenameClassRector::OLD_TO_NEW_CLASSES => [ + \Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\OldClass::class => NewClass::class, + ], + ]]); +}; diff --git a/rules/renaming/tests/Rector/Name/RenameClassRector/config/configured_rule.php b/rules/renaming/tests/Rector/Name/RenameClassRector/config/configured_rule.php new file mode 100644 index 000000000000..7702febfa6e1 --- /dev/null +++ b/rules/renaming/tests/Rector/Name/RenameClassRector/config/configured_rule.php @@ -0,0 +1,42 @@ +services(); + + $services->set(RenameClassRector::class) + ->call('configure', [[ + RenameClassRector::OLD_TO_NEW_CLASSES => [ + 'FqnizeNamespaced' => 'Abc\FqnizeNamespaced', + \Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\OldClass::class => NewClass::class, + OldClassWithTypo::class => NewClassWithoutTypo::class, + 'DateTime' => 'DateTimeInterface', + 'Countable' => 'stdClass', + Manual_Twig_Filter::class => TwigFilter::class, + 'Twig_AbstractManualExtension' => AbstractManualExtension::class, + 'Twig_Extension_Sandbox' => 'Twig\Extension\SandboxExtension', + // Renaming class itself and its namespace + 'MyNamespace\MyClass' => 'MyNewNamespace\MyNewClass', + 'MyNamespace\MyTrait' => 'MyNewNamespace\MyNewTrait', + 'MyNamespace\MyInterface' => 'MyNewNamespace\MyNewInterface', + 'MyOldClass' => 'MyNamespace\MyNewClass', + 'AnotherMyOldClass' => 'AnotherMyNewClass', + 'MyNamespace\AnotherMyClass' => 'MyNewClassWithoutNamespace', + // test duplicated class - @see https://github.com/rectorphp/rector/issues/1438 + 'Rector\Renaming\Tests\Rector\Name\RenameClassRector\Fixture\SingularClass' => DuplicatedClass::class, + // test duplicated class - @see https://github.com/rectorphp/rector/issues/5389 + 'MyFooInterface' => 'MyBazInterface', + 'MyBarInterface' => 'MyBazInterface', + \Acme\Foo\DoNotUpdateExistingTargetNamespace::class => DoNotUpdateExistingTargetNamespace::class, + ], + ]]); +}; diff --git a/rules/renaming/tests/Rector/Name/RenameClassRector/config/non_php_config.php b/rules/renaming/tests/Rector/Name/RenameClassRector/config/non_php_config.php new file mode 100644 index 000000000000..11f384718ffd --- /dev/null +++ b/rules/renaming/tests/Rector/Name/RenameClassRector/config/non_php_config.php @@ -0,0 +1,20 @@ +services(); + + $services->set(RenameClassRector::class) + ->call('configure', [[ + RenameClassRector::OLD_TO_NEW_CLASSES => [ + \Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\OldClass::class => NewClass::class, + // Laravel + 'Session' => 'Illuminate\Support\Facades\Session', + 'Form' => 'Collective\Html\FormFacade', + 'Html' => 'Collective\Html\HtmlFacade', + ], + ]]); +}; diff --git a/rules/renaming/tests/Rector/Namespace_/RenameNamespaceRector/RenameNamespaceRectorTest.php b/rules/renaming/tests/Rector/Namespace_/RenameNamespaceRector/RenameNamespaceRectorTest.php index eed24dab5ffd..cb752555c398 100644 --- a/rules/renaming/tests/Rector/Namespace_/RenameNamespaceRector/RenameNamespaceRectorTest.php +++ b/rules/renaming/tests/Rector/Namespace_/RenameNamespaceRector/RenameNamespaceRectorTest.php @@ -5,7 +5,6 @@ namespace Rector\Renaming\Tests\Rector\Namespace_\RenameNamespaceRector; use Iterator; -use Rector\Renaming\Rector\Namespace_\RenameNamespaceRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -24,20 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - RenameNamespaceRector::class => [ - RenameNamespaceRector::OLD_TO_NEW_NAMESPACES => [ - 'OldNamespace' => 'NewNamespace', - 'OldNamespaceWith\OldSplitNamespace' => 'NewNamespaceWith\NewSplitNamespace', - 'Old\Long\AnyNamespace' => 'Short\AnyNamespace', - 'PHPUnit_Framework_' => 'PHPUnit\Framework\\', - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/renaming/tests/Rector/Namespace_/RenameNamespaceRector/config/configured_rule.php b/rules/renaming/tests/Rector/Namespace_/RenameNamespaceRector/config/configured_rule.php new file mode 100644 index 000000000000..d6cfb01c9efb --- /dev/null +++ b/rules/renaming/tests/Rector/Namespace_/RenameNamespaceRector/config/configured_rule.php @@ -0,0 +1,15 @@ +services(); + $services->set(\Rector\Renaming\Rector\Namespace_\RenameNamespaceRector::class)->call('configure', [[ + \Rector\Renaming\Rector\Namespace_\RenameNamespaceRector::OLD_TO_NEW_NAMESPACES => [ + 'OldNamespace' => 'NewNamespace', + 'OldNamespaceWith\OldSplitNamespace' => 'NewNamespaceWith\NewSplitNamespace', + 'Old\Long\AnyNamespace' => 'Short\AnyNamespace', + 'PHPUnit_Framework_' => 'PHPUnit\Framework\\', + ], + ]]); +}; diff --git a/rules/renaming/tests/Rector/PropertyFetch/RenamePropertyRector/RenamePropertyRectorTest.php b/rules/renaming/tests/Rector/PropertyFetch/RenamePropertyRector/RenamePropertyRectorTest.php index bf69d666396a..9b2a5999ddcc 100644 --- a/rules/renaming/tests/Rector/PropertyFetch/RenamePropertyRector/RenamePropertyRectorTest.php +++ b/rules/renaming/tests/Rector/PropertyFetch/RenamePropertyRector/RenamePropertyRectorTest.php @@ -5,9 +5,6 @@ namespace Rector\Renaming\Tests\Rector\PropertyFetch\RenamePropertyRector; use Iterator; -use Rector\Renaming\Rector\PropertyFetch\RenamePropertyRector; -use Rector\Renaming\Tests\Rector\PropertyFetch\RenamePropertyRector\Source\ClassWithProperties; -use Rector\Renaming\ValueObject\RenameProperty; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -26,18 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - RenamePropertyRector::class => [ - RenamePropertyRector::RENAMED_PROPERTIES => [ - new RenameProperty(ClassWithProperties::class, 'oldProperty', 'newProperty'), - new RenameProperty(ClassWithProperties::class, 'anotherOldProperty', 'anotherNewProperty'), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/renaming/tests/Rector/PropertyFetch/RenamePropertyRector/config/configured_rule.php b/rules/renaming/tests/Rector/PropertyFetch/RenamePropertyRector/config/configured_rule.php new file mode 100644 index 000000000000..513cd703e95e --- /dev/null +++ b/rules/renaming/tests/Rector/PropertyFetch/RenamePropertyRector/config/configured_rule.php @@ -0,0 +1,64 @@ +services(); + $services->set(\Rector\Renaming\Rector\PropertyFetch\RenamePropertyRector::class)->call('configure', [[ + \Rector\Renaming\Rector\PropertyFetch\RenamePropertyRector::RENAMED_PROPERTIES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + new \Rector\Renaming\ValueObject\RenameProperty( + \Rector\Renaming\Tests\Rector\PropertyFetch\RenamePropertyRector\Source\ClassWithProperties::class, + 'oldProperty', + 'newProperty' + ), + new \Rector\Renaming\ValueObject\RenameProperty( + \Rector\Renaming\Tests\Rector\PropertyFetch\RenamePropertyRector\Source\ClassWithProperties::class, + 'anotherOldProperty', + 'anotherNewProperty' + ), + + + + + + + + + + + + + + + + + + + + + + + + + + ]), + ]]); +}; diff --git a/rules/renaming/tests/Rector/StaticCall/RenameStaticMethodRector/RenameStaticMethodRectorTest.php b/rules/renaming/tests/Rector/StaticCall/RenameStaticMethodRector/RenameStaticMethodRectorTest.php index c32af1fcf7c1..660a0c360c98 100644 --- a/rules/renaming/tests/Rector/StaticCall/RenameStaticMethodRector/RenameStaticMethodRectorTest.php +++ b/rules/renaming/tests/Rector/StaticCall/RenameStaticMethodRector/RenameStaticMethodRectorTest.php @@ -5,10 +5,6 @@ namespace Rector\Renaming\Tests\Rector\StaticCall\RenameStaticMethodRector; use Iterator; -use Nette\Utils\Html; -use Rector\Renaming\Rector\StaticCall\RenameStaticMethodRector; -use Rector\Renaming\Tests\Rector\StaticCall\RenameStaticMethodRector\Source\FormMacros; -use Rector\Renaming\ValueObject\RenameStaticMethod; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -27,23 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - RenameStaticMethodRector::class => [ - RenameStaticMethodRector::OLD_TO_NEW_METHODS_BY_CLASSES => [ - new RenameStaticMethod(Html::class, 'add', Html::class, 'addHtml'), - new RenameStaticMethod( - FormMacros::class, - 'renderFormBegin', - 'Nette\Bridges\FormsLatte\Runtime', - 'renderFormBegin' - ), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/renaming/tests/Rector/StaticCall/RenameStaticMethodRector/config/configured_rule.php b/rules/renaming/tests/Rector/StaticCall/RenameStaticMethodRector/config/configured_rule.php new file mode 100644 index 000000000000..e2726342a428 --- /dev/null +++ b/rules/renaming/tests/Rector/StaticCall/RenameStaticMethodRector/config/configured_rule.php @@ -0,0 +1,66 @@ +services(); + $services->set(\Rector\Renaming\Rector\StaticCall\RenameStaticMethodRector::class)->call('configure', [[ + \Rector\Renaming\Rector\StaticCall\RenameStaticMethodRector::OLD_TO_NEW_METHODS_BY_CLASSES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + new \Rector\Renaming\ValueObject\RenameStaticMethod( + \Nette\Utils\Html::class, + 'add', + \Nette\Utils\Html::class, + 'addHtml' + ), + new \Rector\Renaming\ValueObject\RenameStaticMethod( + \Rector\Renaming\Tests\Rector\StaticCall\RenameStaticMethodRector\Source\FormMacros::class, + 'renderFormBegin', + 'Nette\Bridges\FormsLatte\Runtime', + 'renderFormBegin' + ), + + + + + + + + + + + + + + + + + + + + + + + + + + ]), + ]]); +}; diff --git a/rules/renaming/tests/Rector/String_/RenameStringRector/RenameStringRectorTest.php b/rules/renaming/tests/Rector/String_/RenameStringRector/RenameStringRectorTest.php index 1e4817ed4147..5dc04c1c7712 100644 --- a/rules/renaming/tests/Rector/String_/RenameStringRector/RenameStringRectorTest.php +++ b/rules/renaming/tests/Rector/String_/RenameStringRector/RenameStringRectorTest.php @@ -5,7 +5,6 @@ namespace Rector\Renaming\Tests\Rector\String_\RenameStringRector; use Iterator; -use Rector\Renaming\Rector\String_\RenameStringRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -24,18 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return mixed[] - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - RenameStringRector::class => - [ - RenameStringRector::STRING_CHANGES => [ - 'ROLE_PREVIOUS_ADMIN' => 'IS_IMPERSONATOR', - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/renaming/tests/Rector/String_/RenameStringRector/config/configured_rule.php b/rules/renaming/tests/Rector/String_/RenameStringRector/config/configured_rule.php new file mode 100644 index 000000000000..843e32fbf1cd --- /dev/null +++ b/rules/renaming/tests/Rector/String_/RenameStringRector/config/configured_rule.php @@ -0,0 +1,12 @@ +services(); + $services->set(\Rector\Renaming\Rector\String_\RenameStringRector::class)->call('configure', [[ + \Rector\Renaming\Rector\String_\RenameStringRector::STRING_CHANGES => [ + 'ROLE_PREVIOUS_ADMIN' => 'IS_IMPERSONATOR', + ], + ]]); +}; diff --git a/rules/restoration/src/Rector/Namespace_/CompleteImportForPartialAnnotationRector.php b/rules/restoration/src/Rector/Namespace_/CompleteImportForPartialAnnotationRector.php index 8b895cff31a0..0900b4667824 100644 --- a/rules/restoration/src/Rector/Namespace_/CompleteImportForPartialAnnotationRector.php +++ b/rules/restoration/src/Rector/Namespace_/CompleteImportForPartialAnnotationRector.php @@ -12,7 +12,7 @@ use PhpParser\Node\Stmt\Use_; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; -use Rector\Restoration\ValueObject\UseWithAlias; +use Rector\Restoration\ValueObject\CompleteImportForPartialAnnotation; use Symplify\Astral\ValueObject\NodeBuilder\UseBuilder; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -29,7 +29,7 @@ final class CompleteImportForPartialAnnotationRector extends AbstractRector impl public const USE_IMPORTS_TO_RESTORE = '$useImportsToRestore'; /** - * @var UseWithAlias[] + * @var CompleteImportForPartialAnnotation[] */ private $useImportsToRestore = []; @@ -60,7 +60,9 @@ class SomeClass CODE_SAMPLE , [ - self::USE_IMPORTS_TO_RESTORE => [new UseWithAlias('Doctrine\ORM\Mapping', 'ORM')], + self::USE_IMPORTS_TO_RESTORE => [ + new CompleteImportForPartialAnnotation('Doctrine\ORM\Mapping', 'ORM'), + ], ] ), ]); @@ -97,21 +99,23 @@ public function refactor(Node $node): ?Node } /** - * @param UseWithAlias[][] $configuration + * @param CompleteImportForPartialAnnotation[][] $configuration */ public function configure(array $configuration): void { $default = [ - new UseWithAlias('Doctrine\ORM\Mapping', 'ORM'), - new UseWithAlias('Symfony\Component\Validator\Constraints', 'Assert'), - new UseWithAlias('JMS\Serializer\Annotation', 'Serializer'), + new CompleteImportForPartialAnnotation('Doctrine\ORM\Mapping', 'ORM'), + new CompleteImportForPartialAnnotation('Symfony\Component\Validator\Constraints', 'Assert'), + new CompleteImportForPartialAnnotation('JMS\Serializer\Annotation', 'Serializer'), ]; $this->useImportsToRestore = array_merge($configuration[self::USE_IMPORTS_TO_RESTORE] ?? [], $default); } - private function addImportToNamespaceIfMissing(Namespace_ $namespace, UseWithAlias $useWithAlias): Namespace_ - { + private function addImportToNamespaceIfMissing( + Namespace_ $namespace, + CompleteImportForPartialAnnotation $useWithAlias + ): Namespace_ { foreach ($namespace->stmts as $stmt) { if (! $stmt instanceof Use_) { continue; @@ -131,8 +135,10 @@ private function addImportToNamespaceIfMissing(Namespace_ $namespace, UseWithAli return $this->addImportToNamespace($namespace, $useWithAlias); } - private function addImportToNamespace(Namespace_ $namespace, UseWithAlias $useWithAlias): Namespace_ - { + private function addImportToNamespace( + Namespace_ $namespace, + CompleteImportForPartialAnnotation $useWithAlias + ): Namespace_ { $useBuilder = new UseBuilder($useWithAlias->getUse()); if ($useWithAlias->getAlias() !== '') { $useBuilder->as($useWithAlias->getAlias()); diff --git a/rules/restoration/src/ValueObject/UseWithAlias.php b/rules/restoration/src/ValueObject/CompleteImportForPartialAnnotation.php similarity index 91% rename from rules/restoration/src/ValueObject/UseWithAlias.php rename to rules/restoration/src/ValueObject/CompleteImportForPartialAnnotation.php index 13acef73d6df..0b92576ad5c2 100644 --- a/rules/restoration/src/ValueObject/UseWithAlias.php +++ b/rules/restoration/src/ValueObject/CompleteImportForPartialAnnotation.php @@ -4,7 +4,7 @@ namespace Rector\Restoration\ValueObject; -final class UseWithAlias +final class CompleteImportForPartialAnnotation { /** * @var string diff --git a/rules/restoration/tests/Rector/ClassMethod/InferParamFromClassMethodReturnRector/config/configured_rule.php b/rules/restoration/tests/Rector/ClassMethod/InferParamFromClassMethodReturnRector/config/configured_rule.php index e4abdbf51bea..f8a4702f31c8 100644 --- a/rules/restoration/tests/Rector/ClassMethod/InferParamFromClassMethodReturnRector/config/configured_rule.php +++ b/rules/restoration/tests/Rector/ClassMethod/InferParamFromClassMethodReturnRector/config/configured_rule.php @@ -11,12 +11,14 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); - $inlinedValueObjects = ValueObjectInliner::inline([ - new InferParamFromClassMethodReturn(SomeType::class, 'process', 'getNodeTypes'), - ]); - $services->set(InferParamFromClassMethodReturnRector::class) ->call('configure', [[ - InferParamFromClassMethodReturnRector::INFER_PARAMS_FROM_CLASS_METHOD_RETURNS => $inlinedValueObjects, + InferParamFromClassMethodReturnRector::INFER_PARAMS_FROM_CLASS_METHOD_RETURNS => ValueObjectInliner::inline([ + + + new InferParamFromClassMethodReturn(SomeType::class, 'process', 'getNodeTypes'), + + + ]), ]]); }; diff --git a/rules/restoration/tests/Rector/Namespace_/CompleteImportForPartialAnnotationRector/CompleteImportForPartialAnnotationRectorTest.php b/rules/restoration/tests/Rector/Namespace_/CompleteImportForPartialAnnotationRector/CompleteImportForPartialAnnotationRectorTest.php index 6528610d8b3e..0c3434cf1ac0 100644 --- a/rules/restoration/tests/Rector/Namespace_/CompleteImportForPartialAnnotationRector/CompleteImportForPartialAnnotationRectorTest.php +++ b/rules/restoration/tests/Rector/Namespace_/CompleteImportForPartialAnnotationRector/CompleteImportForPartialAnnotationRectorTest.php @@ -5,8 +5,6 @@ namespace Rector\Restoration\Tests\Rector\Namespace_\CompleteImportForPartialAnnotationRector; use Iterator; -use Rector\Restoration\Rector\Namespace_\CompleteImportForPartialAnnotationRector; -use Rector\Restoration\ValueObject\UseWithAlias; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -25,17 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - CompleteImportForPartialAnnotationRector::class => [ - CompleteImportForPartialAnnotationRector::USE_IMPORTS_TO_RESTORE => [ - new UseWithAlias('Doctrine\ORM\Mapping', 'ORM'), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/restoration/tests/Rector/Namespace_/CompleteImportForPartialAnnotationRector/config/configured_rule.php b/rules/restoration/tests/Rector/Namespace_/CompleteImportForPartialAnnotationRector/config/configured_rule.php new file mode 100644 index 000000000000..6f46df54a36f --- /dev/null +++ b/rules/restoration/tests/Rector/Namespace_/CompleteImportForPartialAnnotationRector/config/configured_rule.php @@ -0,0 +1,17 @@ +services(); + $services->set(CompleteImportForPartialAnnotationRector::class) + ->call('configure', [[ + CompleteImportForPartialAnnotationRector::USE_IMPORTS_TO_RESTORE => ValueObjectInliner::inline([ + new CompleteImportForPartialAnnotation('Doctrine\ORM\Mapping', 'ORM'), + ]), + ]] + ); +}; diff --git a/rules/restoration/tests/Rector/New_/CompleteMissingDependencyInNewRector/CompleteMissingDependencyInNewRectorTest.php b/rules/restoration/tests/Rector/New_/CompleteMissingDependencyInNewRector/CompleteMissingDependencyInNewRectorTest.php index 476a1fed6c49..2b6a37c6f874 100644 --- a/rules/restoration/tests/Rector/New_/CompleteMissingDependencyInNewRector/CompleteMissingDependencyInNewRectorTest.php +++ b/rules/restoration/tests/Rector/New_/CompleteMissingDependencyInNewRector/CompleteMissingDependencyInNewRectorTest.php @@ -5,8 +5,6 @@ namespace Rector\Restoration\Tests\Rector\New_\CompleteMissingDependencyInNewRector; use Iterator; -use Rector\Restoration\Rector\New_\CompleteMissingDependencyInNewRector; -use Rector\Restoration\Tests\Rector\New_\CompleteMissingDependencyInNewRector\Source\RandomDependency; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -25,17 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - CompleteMissingDependencyInNewRector::class => [ - CompleteMissingDependencyInNewRector::CLASS_TO_INSTANTIATE_BY_TYPE => [ - RandomDependency::class => RandomDependency::class, - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/restoration/tests/Rector/New_/CompleteMissingDependencyInNewRector/config/configured_rule.php b/rules/restoration/tests/Rector/New_/CompleteMissingDependencyInNewRector/config/configured_rule.php new file mode 100644 index 000000000000..36776ac4b3a3 --- /dev/null +++ b/rules/restoration/tests/Rector/New_/CompleteMissingDependencyInNewRector/config/configured_rule.php @@ -0,0 +1,12 @@ +services(); + $services->set(\Rector\Restoration\Rector\New_\CompleteMissingDependencyInNewRector::class)->call('configure', [[ + \Rector\Restoration\Rector\New_\CompleteMissingDependencyInNewRector::CLASS_TO_INSTANTIATE_BY_TYPE => [ + \Rector\Restoration\Tests\Rector\New_\CompleteMissingDependencyInNewRector\Source\RandomDependency::class => \Rector\Restoration\Tests\Rector\New_\CompleteMissingDependencyInNewRector\Source\RandomDependency::class, + ], + ]]); +}; diff --git a/rules/symfony/tests/Rector/Class_/ChangeFileLoaderInExtensionAndKernelRector/ChangeFileLoaderInExtensionAndKernelRectorTest.php b/rules/symfony/tests/Rector/Class_/ChangeFileLoaderInExtensionAndKernelRector/ChangeFileLoaderInExtensionAndKernelRectorTest.php index b3642ced5893..e3a031afa003 100644 --- a/rules/symfony/tests/Rector/Class_/ChangeFileLoaderInExtensionAndKernelRector/ChangeFileLoaderInExtensionAndKernelRectorTest.php +++ b/rules/symfony/tests/Rector/Class_/ChangeFileLoaderInExtensionAndKernelRector/ChangeFileLoaderInExtensionAndKernelRectorTest.php @@ -5,7 +5,6 @@ namespace Rector\Symfony\Tests\Rector\Class_\ChangeFileLoaderInExtensionAndKernelRector; use Iterator; -use Rector\Symfony\Rector\Class_\ChangeFileLoaderInExtensionAndKernelRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -24,16 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - ChangeFileLoaderInExtensionAndKernelRector::class => [ - ChangeFileLoaderInExtensionAndKernelRector::FROM => 'xml', - ChangeFileLoaderInExtensionAndKernelRector::TO => 'yaml', - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/symfony/tests/Rector/Class_/ChangeFileLoaderInExtensionAndKernelRector/config/configured_rule.php b/rules/symfony/tests/Rector/Class_/ChangeFileLoaderInExtensionAndKernelRector/config/configured_rule.php new file mode 100644 index 000000000000..c226386b2cae --- /dev/null +++ b/rules/symfony/tests/Rector/Class_/ChangeFileLoaderInExtensionAndKernelRector/config/configured_rule.php @@ -0,0 +1,16 @@ +services(); + + $services->set(ChangeFileLoaderInExtensionAndKernelRector::class) + ->call('configure', [[ + ChangeFileLoaderInExtensionAndKernelRector::FROM => 'xml', + ChangeFileLoaderInExtensionAndKernelRector::TO => 'yaml', + ]]); +}; diff --git a/rules/symfony/tests/Rector/MethodCall/GetToConstructorInjectionRector/GetToConstructorInjectionRectorTest.php b/rules/symfony/tests/Rector/MethodCall/GetToConstructorInjectionRector/GetToConstructorInjectionRectorTest.php index a04e3e08a243..4bbdac594fe7 100644 --- a/rules/symfony/tests/Rector/MethodCall/GetToConstructorInjectionRector/GetToConstructorInjectionRectorTest.php +++ b/rules/symfony/tests/Rector/MethodCall/GetToConstructorInjectionRector/GetToConstructorInjectionRectorTest.php @@ -5,10 +5,6 @@ namespace Rector\Symfony\Tests\Rector\MethodCall\GetToConstructorInjectionRector; use Iterator; -use Rector\Core\Configuration\Option; -use Rector\Symfony\Rector\MethodCall\GetToConstructorInjectionRector; -use Rector\Symfony\Tests\Rector\MethodCall\GetToConstructorInjectionRector\Source\GetTrait; -use Rector\Symfony\Tests\Rector\Source\SymfonyController; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -19,7 +15,6 @@ final class GetToConstructorInjectionRectorTest extends AbstractRectorTestCase */ public function test(SmartFileInfo $fileInfo): void { - $this->setParameter(Option::SYMFONY_CONTAINER_XML_PATH_PARAMETER, __DIR__ . '/xml/services.xml'); $this->doTestFileInfo($fileInfo); } @@ -28,15 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - GetToConstructorInjectionRector::class => [ - GetToConstructorInjectionRector::GET_METHOD_AWARE_TYPES => [SymfonyController::class, GetTrait::class], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/symfony/tests/Rector/MethodCall/GetToConstructorInjectionRector/config/configured_rule.php b/rules/symfony/tests/Rector/MethodCall/GetToConstructorInjectionRector/config/configured_rule.php new file mode 100644 index 000000000000..78931038b8b9 --- /dev/null +++ b/rules/symfony/tests/Rector/MethodCall/GetToConstructorInjectionRector/config/configured_rule.php @@ -0,0 +1,18 @@ +parameters(); + $parameters->set(Option::SYMFONY_CONTAINER_XML_PATH_PARAMETER, __DIR__ . '/../xml/services.xml'); + + $services = $containerConfigurator->services(); + $services->set(\Rector\Symfony\Rector\MethodCall\GetToConstructorInjectionRector::class)->call('configure', [[ + \Rector\Symfony\Rector\MethodCall\GetToConstructorInjectionRector::GET_METHOD_AWARE_TYPES => [ + \Rector\Symfony\Tests\Rector\Source\SymfonyController::class, + \Rector\Symfony\Tests\Rector\MethodCall\GetToConstructorInjectionRector\Source\GetTrait::class, + ], + ]]); +}; diff --git a/rules/symfony4/tests/Rector/MethodCall/ContainerGetToConstructorInjectionRector/ContainerGetToConstructorInjectionRectorTest.php b/rules/symfony4/tests/Rector/MethodCall/ContainerGetToConstructorInjectionRector/ContainerGetToConstructorInjectionRectorTest.php index 47c0d361e36a..69961b3268c8 100644 --- a/rules/symfony4/tests/Rector/MethodCall/ContainerGetToConstructorInjectionRector/ContainerGetToConstructorInjectionRectorTest.php +++ b/rules/symfony4/tests/Rector/MethodCall/ContainerGetToConstructorInjectionRector/ContainerGetToConstructorInjectionRectorTest.php @@ -5,11 +5,6 @@ namespace Rector\Symfony4\Tests\Rector\MethodCall\ContainerGetToConstructorInjectionRector; use Iterator; -use Rector\Core\Configuration\Option; -use Rector\Symfony4\Rector\MethodCall\ContainerGetToConstructorInjectionRector; -use Rector\Symfony4\Tests\Rector\MethodCall\ContainerGetToConstructorInjectionRector\Source\ContainerAwareParentClass; -use Rector\Symfony4\Tests\Rector\MethodCall\ContainerGetToConstructorInjectionRector\Source\ContainerAwareParentCommand; -use Rector\Symfony4\Tests\Rector\MethodCall\ContainerGetToConstructorInjectionRector\Source\ThisClassCallsMethodInConstructor; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; @@ -20,7 +15,6 @@ final class ContainerGetToConstructorInjectionRectorTest extends AbstractRectorT */ public function test(SmartFileInfo $fileInfo): void { - $this->setParameter(Option::SYMFONY_CONTAINER_XML_PATH_PARAMETER, __DIR__ . '/xml/services.xml'); $this->doTestFileInfo($fileInfo); } @@ -29,19 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - ContainerGetToConstructorInjectionRector::class => [ - ContainerGetToConstructorInjectionRector::CONTAINER_AWARE_PARENT_TYPES => [ - ContainerAwareParentClass::class, - ContainerAwareParentCommand::class, - ThisClassCallsMethodInConstructor::class, - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/symfony4/tests/Rector/MethodCall/ContainerGetToConstructorInjectionRector/config/configured_rule.php b/rules/symfony4/tests/Rector/MethodCall/ContainerGetToConstructorInjectionRector/config/configured_rule.php new file mode 100644 index 000000000000..ac139ed0a885 --- /dev/null +++ b/rules/symfony4/tests/Rector/MethodCall/ContainerGetToConstructorInjectionRector/config/configured_rule.php @@ -0,0 +1,24 @@ +parameters(); + $parameters->set(Option::SYMFONY_CONTAINER_XML_PATH_PARAMETER, __DIR__ . '/../xml/services.xml'); + + $services = $containerConfigurator->services(); + $services->set(ContainerGetToConstructorInjectionRector::class) + ->call('configure', [[ + ContainerGetToConstructorInjectionRector::CONTAINER_AWARE_PARENT_TYPES => [ + ContainerAwareParentClass::class, + ContainerAwareParentCommand::class, + ThisClassCallsMethodInConstructor::class, + ], + ]] + ); +}; diff --git a/rules/transform/src/Rector/ClassConstFetch/ClassConstFetchToStringRector.php b/rules/transform/src/Rector/ClassConstFetch/ClassConstFetchToValueRector.php similarity index 94% rename from rules/transform/src/Rector/ClassConstFetch/ClassConstFetchToStringRector.php rename to rules/transform/src/Rector/ClassConstFetch/ClassConstFetchToValueRector.php index 7853e1e5bcbb..abd4085879a4 100644 --- a/rules/transform/src/Rector/ClassConstFetch/ClassConstFetchToStringRector.php +++ b/rules/transform/src/Rector/ClassConstFetch/ClassConstFetchToValueRector.php @@ -15,9 +15,9 @@ use Webmozart\Assert\Assert; /** - * @see \Rector\Transform\Tests\Rector\ClassConstFetch\ClassConstFetchToStringRector\ClassConstFetchToStringRectorTest + * @see \Rector\Transform\Tests\Rector\ClassConstFetch\ClassConstFetchToValueRector\ClassConstFetchToValueRectorTest */ -final class ClassConstFetchToStringRector extends AbstractRector implements ConfigurableRectorInterface +final class ClassConstFetchToValueRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var string diff --git a/rules/transform/src/Rector/FuncCall/FuncCallToMethodCallRector.php b/rules/transform/src/Rector/FuncCall/FuncCallToMethodCallRector.php index 0544ba4f7862..9f0a46f36674 100644 --- a/rules/transform/src/Rector/FuncCall/FuncCallToMethodCallRector.php +++ b/rules/transform/src/Rector/FuncCall/FuncCallToMethodCallRector.php @@ -10,7 +10,7 @@ use PhpParser\Node\Stmt\ClassMethod; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Transform\Rector\AbstractToMethodCallRector; -use Rector\Transform\ValueObject\FuncNameToMethodCallName; +use Rector\Transform\ValueObject\FuncCallToMethodCall; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use Webmozart\Assert\Assert; @@ -26,7 +26,7 @@ final class FuncCallToMethodCallRector extends AbstractToMethodCallRector public const FUNC_CALL_TO_CLASS_METHOD_CALL = 'function_to_class_to_method_call'; /** - * @var FuncNameToMethodCallName[] + * @var FuncCallToMethodCall[] */ private $funcNameToMethodCallNames = []; @@ -66,7 +66,7 @@ public function run() , [ self::FUNC_CALL_TO_CLASS_METHOD_CALL => [ - new FuncNameToMethodCallName('view', 'Namespaced\SomeRenderer', 'render'), + new FuncCallToMethodCall('view', 'Namespaced\SomeRenderer', 'render'), ], ] ), @@ -123,7 +123,7 @@ public function refactor(Node $node): ?Node public function configure(array $configuration): void { $funcCallsToClassMethodCalls = $configuration[self::FUNC_CALL_TO_CLASS_METHOD_CALL] ?? []; - Assert::allIsInstanceOf($funcCallsToClassMethodCalls, FuncNameToMethodCallName::class); + Assert::allIsInstanceOf($funcCallsToClassMethodCalls, FuncCallToMethodCall::class); $this->funcNameToMethodCallNames = $funcCallsToClassMethodCalls; } } diff --git a/rules/transform/src/Rector/Isset_/UnsetAndIssetToMethodCallRector.php b/rules/transform/src/Rector/Isset_/UnsetAndIssetToMethodCallRector.php index 9dcad9187a77..6ef79c7e0495 100644 --- a/rules/transform/src/Rector/Isset_/UnsetAndIssetToMethodCallRector.php +++ b/rules/transform/src/Rector/Isset_/UnsetAndIssetToMethodCallRector.php @@ -10,7 +10,7 @@ use PhpParser\Node\Stmt\Unset_; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; -use Rector\Transform\ValueObject\IssetUnsetToMethodCall; +use Rector\Transform\ValueObject\UnsetAndIssetToMethodCall; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use Webmozart\Assert\Assert; @@ -26,13 +26,13 @@ final class UnsetAndIssetToMethodCallRector extends AbstractRector implements Co public const ISSET_UNSET_TO_METHOD_CALL = 'isset_unset_to_method_call'; /** - * @var IssetUnsetToMethodCall[] + * @var UnsetAndIssetToMethodCall[] */ private $issetUnsetToMethodCalls = []; public function getRuleDefinition(): RuleDefinition { - $issetUnsetToMethodCall = new IssetUnsetToMethodCall('SomeContainer', 'hasService', 'removeService'); + $issetUnsetToMethodCall = new UnsetAndIssetToMethodCall('SomeContainer', 'hasService', 'removeService'); return new RuleDefinition('Turns defined `__isset`/`__unset` calls to specific method calls.', [ new ConfiguredCodeSample( @@ -104,7 +104,7 @@ public function refactor(Node $node): ?Node public function configure(array $configuration): void { $issetUnsetToMethodCalls = $configuration[self::ISSET_UNSET_TO_METHOD_CALL] ?? []; - Assert::allIsInstanceOf($issetUnsetToMethodCalls, IssetUnsetToMethodCall::class); + Assert::allIsInstanceOf($issetUnsetToMethodCalls, UnsetAndIssetToMethodCall::class); $this->issetUnsetToMethodCalls = $issetUnsetToMethodCalls; } @@ -112,7 +112,7 @@ public function configure(array $configuration): void private function processArrayDimFetchNode( Node $node, ArrayDimFetch $arrayDimFetch, - IssetUnsetToMethodCall $issetUnsetToMethodCall + UnsetAndIssetToMethodCall $issetUnsetToMethodCall ): ?Node { if ($node instanceof Isset_) { if ($issetUnsetToMethodCall->getIssetMethodCall() === '') { diff --git a/rules/transform/src/ValueObject/FuncNameToMethodCallName.php b/rules/transform/src/ValueObject/FuncCallToMethodCall.php similarity index 95% rename from rules/transform/src/ValueObject/FuncNameToMethodCallName.php rename to rules/transform/src/ValueObject/FuncCallToMethodCall.php index 1b72564fe593..e45591dc5d04 100644 --- a/rules/transform/src/ValueObject/FuncNameToMethodCallName.php +++ b/rules/transform/src/ValueObject/FuncCallToMethodCall.php @@ -4,7 +4,7 @@ namespace Rector\Transform\ValueObject; -final class FuncNameToMethodCallName +final class FuncCallToMethodCall { /** * @var string diff --git a/rules/transform/src/ValueObject/IssetUnsetToMethodCall.php b/rules/transform/src/ValueObject/UnsetAndIssetToMethodCall.php similarity index 95% rename from rules/transform/src/ValueObject/IssetUnsetToMethodCall.php rename to rules/transform/src/ValueObject/UnsetAndIssetToMethodCall.php index 93ef051e069c..6d6bb0fccfe7 100644 --- a/rules/transform/src/ValueObject/IssetUnsetToMethodCall.php +++ b/rules/transform/src/ValueObject/UnsetAndIssetToMethodCall.php @@ -4,7 +4,7 @@ namespace Rector\Transform\ValueObject; -final class IssetUnsetToMethodCall +final class UnsetAndIssetToMethodCall { /** * @var string diff --git a/rules/transform/tests/Rector/Assign/DimFetchAssignToMethodCallRector/DimFetchAssignToMethodCallRectorTest.php b/rules/transform/tests/Rector/Assign/DimFetchAssignToMethodCallRector/DimFetchAssignToMethodCallRectorTest.php index ac2a2ce900ff..8bf7aeb32fc0 100644 --- a/rules/transform/tests/Rector/Assign/DimFetchAssignToMethodCallRector/DimFetchAssignToMethodCallRectorTest.php +++ b/rules/transform/tests/Rector/Assign/DimFetchAssignToMethodCallRector/DimFetchAssignToMethodCallRectorTest.php @@ -6,8 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\Assign\DimFetchAssignToMethodCallRector; -use Rector\Transform\ValueObject\DimFetchAssignToMethodCall; use Symplify\SmartFileSystem\SmartFileInfo; final class DimFetchAssignToMethodCallRectorTest extends AbstractRectorTestCase @@ -25,21 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array> - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - DimFetchAssignToMethodCallRector::class => [ - DimFetchAssignToMethodCallRector::DIM_FETCH_ASSIGN_TO_METHOD_CALL => [ - new DimFetchAssignToMethodCall( - 'Nette\Application\Routers\RouteList', - 'Nette\Application\Routers\Route', - 'addRoute' - ), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/Assign/DimFetchAssignToMethodCallRector/config/configured_rule.php b/rules/transform/tests/Rector/Assign/DimFetchAssignToMethodCallRector/config/configured_rule.php new file mode 100644 index 000000000000..c1cb1823d577 --- /dev/null +++ b/rules/transform/tests/Rector/Assign/DimFetchAssignToMethodCallRector/config/configured_rule.php @@ -0,0 +1,59 @@ +services(); + $services->set(\Rector\Transform\Rector\Assign\DimFetchAssignToMethodCallRector::class)->call('configure', [[ + \Rector\Transform\Rector\Assign\DimFetchAssignToMethodCallRector::DIM_FETCH_ASSIGN_TO_METHOD_CALL => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + new \Rector\Transform\ValueObject\DimFetchAssignToMethodCall( + 'Nette\Application\Routers\RouteList', + 'Nette\Application\Routers\Route', + 'addRoute' + ), + + + + + + + + + + + + + + + + + + + + + + + + + + ]), + ]]); +}; diff --git a/rules/transform/tests/Rector/Assign/GetAndSetToMethodCallRector/GetAndSetToMethodCallRectorTest.php b/rules/transform/tests/Rector/Assign/GetAndSetToMethodCallRector/GetAndSetToMethodCallRectorTest.php index f7a09dcb0cf9..48c090e58a39 100644 --- a/rules/transform/tests/Rector/Assign/GetAndSetToMethodCallRector/GetAndSetToMethodCallRectorTest.php +++ b/rules/transform/tests/Rector/Assign/GetAndSetToMethodCallRector/GetAndSetToMethodCallRectorTest.php @@ -6,9 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\Assign\GetAndSetToMethodCallRector; -use Rector\Transform\Tests\Rector\Assign\GetAndSetToMethodCallRector\Source\Klarka; -use Rector\Transform\Tests\Rector\Assign\GetAndSetToMethodCallRector\Source\SomeContainer; use Symplify\SmartFileSystem\SmartFileInfo; final class GetAndSetToMethodCallRectorTest extends AbstractRectorTestCase @@ -26,23 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - GetAndSetToMethodCallRector::class => [ - GetAndSetToMethodCallRector::TYPE_TO_METHOD_CALLS => [ - SomeContainer::class => [ - 'get' => 'getService', - 'set' => 'addService', - ], - Klarka::class => [ - 'get' => 'get', - ], - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/Assign/GetAndSetToMethodCallRector/config/configured_rule.php b/rules/transform/tests/Rector/Assign/GetAndSetToMethodCallRector/config/configured_rule.php new file mode 100644 index 000000000000..dd1e1ed4a5c3 --- /dev/null +++ b/rules/transform/tests/Rector/Assign/GetAndSetToMethodCallRector/config/configured_rule.php @@ -0,0 +1,18 @@ +services(); + $services->set(\Rector\Transform\Rector\Assign\GetAndSetToMethodCallRector::class)->call('configure', [[ + \Rector\Transform\Rector\Assign\GetAndSetToMethodCallRector::TYPE_TO_METHOD_CALLS => [ + \Rector\Transform\Tests\Rector\Assign\GetAndSetToMethodCallRector\Source\SomeContainer::class => [ + 'get' => 'getService', + 'set' => 'addService', + ], + \Rector\Transform\Tests\Rector\Assign\GetAndSetToMethodCallRector\Source\Klarka::class => [ + 'get' => 'get', + ], + ], + ]]); +}; diff --git a/rules/transform/tests/Rector/Assign/PropertyAssignToMethodCallRector/PropertyAssignToMethodCallRectorTest.php b/rules/transform/tests/Rector/Assign/PropertyAssignToMethodCallRector/PropertyAssignToMethodCallRectorTest.php index 622ee2a41bf3..f7e6fa756fa1 100644 --- a/rules/transform/tests/Rector/Assign/PropertyAssignToMethodCallRector/PropertyAssignToMethodCallRectorTest.php +++ b/rules/transform/tests/Rector/Assign/PropertyAssignToMethodCallRector/PropertyAssignToMethodCallRectorTest.php @@ -6,9 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\Assign\PropertyAssignToMethodCallRector; -use Rector\Transform\Tests\Rector\Assign\PropertyAssignToMethodCallRector\Source\ChoiceControl; -use Rector\Transform\ValueObject\PropertyAssignToMethodCall; use Symplify\SmartFileSystem\SmartFileInfo; final class PropertyAssignToMethodCallRectorTest extends AbstractRectorTestCase @@ -26,17 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - PropertyAssignToMethodCallRector::class => [ - PropertyAssignToMethodCallRector::PROPERTY_ASSIGNS_TO_METHODS_CALLS => [ - new PropertyAssignToMethodCall(ChoiceControl::class, 'checkAllowedValues', 'checkDefaultValue'), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/Assign/PropertyAssignToMethodCallRector/config/configured_rule.php b/rules/transform/tests/Rector/Assign/PropertyAssignToMethodCallRector/config/configured_rule.php new file mode 100644 index 000000000000..62a7453845eb --- /dev/null +++ b/rules/transform/tests/Rector/Assign/PropertyAssignToMethodCallRector/config/configured_rule.php @@ -0,0 +1,59 @@ +services(); + $services->set(\Rector\Transform\Rector\Assign\PropertyAssignToMethodCallRector::class)->call('configure', [[ + \Rector\Transform\Rector\Assign\PropertyAssignToMethodCallRector::PROPERTY_ASSIGNS_TO_METHODS_CALLS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + new \Rector\Transform\ValueObject\PropertyAssignToMethodCall( + \Rector\Transform\Tests\Rector\Assign\PropertyAssignToMethodCallRector\Source\ChoiceControl::class, + 'checkAllowedValues', + 'checkDefaultValue' + ), + + + + + + + + + + + + + + + + + + + + + + + + + + ]), + ]]); +}; diff --git a/rules/transform/tests/Rector/Assign/PropertyFetchToMethodCallRector/PropertyFetchToMethodCallRectorTest.php b/rules/transform/tests/Rector/Assign/PropertyFetchToMethodCallRector/PropertyFetchToMethodCallRectorTest.php index 9108a8433d3b..ffbcb5807349 100644 --- a/rules/transform/tests/Rector/Assign/PropertyFetchToMethodCallRector/PropertyFetchToMethodCallRectorTest.php +++ b/rules/transform/tests/Rector/Assign/PropertyFetchToMethodCallRector/PropertyFetchToMethodCallRectorTest.php @@ -6,9 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\Assign\PropertyFetchToMethodCallRector; -use Rector\Transform\Tests\Rector\Assign\PropertyFetchToMethodCallRector\Source\Translator; -use Rector\Transform\ValueObject\PropertyFetchToMethodCall; use Symplify\SmartFileSystem\SmartFileInfo; final class PropertyFetchToMethodCallRectorTest extends AbstractRectorTestCase @@ -26,24 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - PropertyFetchToMethodCallRector::class => [ - PropertyFetchToMethodCallRector::PROPERTIES_TO_METHOD_CALLS => [ - new PropertyFetchToMethodCall(Translator::class, 'locale', 'getLocale', 'setLocale'), - - new PropertyFetchToMethodCall( - 'Rector\Transform\Tests\Rector\Assign\PropertyFetchToMethodCallRector\Fixture\Fixture2', - 'parameter', - 'getConfig', - null, - ['parameter']), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/Assign/PropertyFetchToMethodCallRector/config/configured_rule.php b/rules/transform/tests/Rector/Assign/PropertyFetchToMethodCallRector/config/configured_rule.php new file mode 100644 index 000000000000..695d2e1939ca --- /dev/null +++ b/rules/transform/tests/Rector/Assign/PropertyFetchToMethodCallRector/config/configured_rule.php @@ -0,0 +1,42 @@ +services(); + $services->set(\Rector\Transform\Rector\Assign\PropertyFetchToMethodCallRector::class)->call('configure', [[ + \Rector\Transform\Rector\Assign\PropertyFetchToMethodCallRector::PROPERTIES_TO_METHOD_CALLS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + new \Rector\Transform\ValueObject\PropertyFetchToMethodCall( + \Rector\Transform\Tests\Rector\Assign\PropertyFetchToMethodCallRector\Source\Translator::class, + 'locale', + 'getLocale', + 'setLocale' + ), + new \Rector\Transform\ValueObject\PropertyFetchToMethodCall( + 'Rector\Transform\Tests\Rector\Assign\PropertyFetchToMethodCallRector\Fixture\Fixture2', + 'parameter', + 'getConfig', + null, + ['parameter']), + ] + ), + ]]); +}; diff --git a/rules/transform/tests/Rector/ClassConstFetch/ClassConstFetchToStringRector/ClassConstFetchToStringRectorTest.php b/rules/transform/tests/Rector/ClassConstFetch/ClassConstFetchToStringRector/ClassConstFetchToStringRectorTest.php deleted file mode 100644 index f846c9229986..000000000000 --- a/rules/transform/tests/Rector/ClassConstFetch/ClassConstFetchToStringRector/ClassConstFetchToStringRectorTest.php +++ /dev/null @@ -1,43 +0,0 @@ -doTestFileInfo($fileInfo); - } - - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array - { - return [ - ClassConstFetchToStringRector::class => [ - ClassConstFetchToStringRector::CLASS_CONST_FETCHES_TO_VALUES => [ - new ClassConstFetchToValue(OldClassWithConstants::class, 'DEVELOPMENT', 'development'), - new ClassConstFetchToValue(OldClassWithConstants::class, 'PRODUCTION', 'production'), - ], - ], - ]; - } -} diff --git a/rules/transform/tests/Rector/ClassConstFetch/ClassConstFetchToValueRector/ClassConstFetchToValueRectorTest.php b/rules/transform/tests/Rector/ClassConstFetch/ClassConstFetchToValueRector/ClassConstFetchToValueRectorTest.php new file mode 100644 index 000000000000..8d9c070e79e7 --- /dev/null +++ b/rules/transform/tests/Rector/ClassConstFetch/ClassConstFetchToValueRector/ClassConstFetchToValueRectorTest.php @@ -0,0 +1,30 @@ +doTestFileInfo($fileInfo); + } + + public function provideData(): Iterator + { + return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); + } + + protected function provideConfigFileInfo(): ?SmartFileInfo + { + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); + } +} diff --git a/rules/transform/tests/Rector/ClassConstFetch/ClassConstFetchToStringRector/Fixture/fixture.php.inc b/rules/transform/tests/Rector/ClassConstFetch/ClassConstFetchToValueRector/Fixture/fixture.php.inc similarity index 77% rename from rules/transform/tests/Rector/ClassConstFetch/ClassConstFetchToStringRector/Fixture/fixture.php.inc rename to rules/transform/tests/Rector/ClassConstFetch/ClassConstFetchToValueRector/Fixture/fixture.php.inc index 8c7eb39effcd..a7b21ac56adc 100644 --- a/rules/transform/tests/Rector/ClassConstFetch/ClassConstFetchToStringRector/Fixture/fixture.php.inc +++ b/rules/transform/tests/Rector/ClassConstFetch/ClassConstFetchToValueRector/Fixture/fixture.php.inc @@ -1,8 +1,8 @@ services(); + + $services->set(ClassConstFetchToValueRector::class) + ->call('configure', [[ + ClassConstFetchToValueRector::CLASS_CONST_FETCHES_TO_VALUES => ValueObjectInliner::inline([ + new ClassConstFetchToValue(OldClassWithConstants::class, 'DEVELOPMENT', 'development'), + new ClassConstFetchToValue(OldClassWithConstants::class, 'PRODUCTION', 'production'), + ]), + ]]); +}; diff --git a/rules/transform/tests/Rector/Class_/ParentClassToTraitsRector/ParentClassToTraitsRectorTest.php b/rules/transform/tests/Rector/Class_/ParentClassToTraitsRector/ParentClassToTraitsRectorTest.php index 6e6cd8d3fd97..82fd42032c67 100644 --- a/rules/transform/tests/Rector/Class_/ParentClassToTraitsRector/ParentClassToTraitsRectorTest.php +++ b/rules/transform/tests/Rector/Class_/ParentClassToTraitsRector/ParentClassToTraitsRectorTest.php @@ -6,12 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\Class_\ParentClassToTraitsRector; -use Rector\Transform\Tests\Rector\Class_\ParentClassToTraitsRector\Source\AnotherParentObject; -use Rector\Transform\Tests\Rector\Class_\ParentClassToTraitsRector\Source\ParentObject; -use Rector\Transform\Tests\Rector\Class_\ParentClassToTraitsRector\Source\SecondTrait; -use Rector\Transform\Tests\Rector\Class_\ParentClassToTraitsRector\Source\SomeTrait; -use Rector\Transform\ValueObject\ParentClassToTraits; use Symplify\SmartFileSystem\SmartFileInfo; final class ParentClassToTraitsRectorTest extends AbstractRectorTestCase @@ -29,18 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - ParentClassToTraitsRector::class => [ - ParentClassToTraitsRector::PARENT_CLASS_TO_TRAITS => [ - new ParentClassToTraits(ParentObject::class, [SomeTrait::class]), - new ParentClassToTraits(AnotherParentObject::class, [SomeTrait::class, SecondTrait::class]), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/Class_/ParentClassToTraitsRector/config/configured_rule.php b/rules/transform/tests/Rector/Class_/ParentClassToTraitsRector/config/configured_rule.php new file mode 100644 index 000000000000..f3fc99c77815 --- /dev/null +++ b/rules/transform/tests/Rector/Class_/ParentClassToTraitsRector/config/configured_rule.php @@ -0,0 +1,40 @@ +services(); + $services->set(\Rector\Transform\Rector\Class_\ParentClassToTraitsRector::class)->call('configure', [[ + \Rector\Transform\Rector\Class_\ParentClassToTraitsRector::PARENT_CLASS_TO_TRAITS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + new \Rector\Transform\ValueObject\ParentClassToTraits( + \Rector\Transform\Tests\Rector\Class_\ParentClassToTraitsRector\Source\ParentObject::class, + [\Rector\Transform\Tests\Rector\Class_\ParentClassToTraitsRector\Source\SomeTrait::class]), + new \Rector\Transform\ValueObject\ParentClassToTraits( + \Rector\Transform\Tests\Rector\Class_\ParentClassToTraitsRector\Source\AnotherParentObject::class, + [ + \Rector\Transform\Tests\Rector\Class_\ParentClassToTraitsRector\Source\SomeTrait::class, + \Rector\Transform\Tests\Rector\Class_\ParentClassToTraitsRector\Source\SecondTrait::class, + + ]), + ] + ), + ]]); +}; diff --git a/rules/transform/tests/Rector/Expression/MethodCallToReturnRector/MethodCallToReturnRectorTest.php b/rules/transform/tests/Rector/Expression/MethodCallToReturnRector/MethodCallToReturnRectorTest.php index cbbeb035d061..ee5c7ca9b6e2 100644 --- a/rules/transform/tests/Rector/Expression/MethodCallToReturnRector/MethodCallToReturnRectorTest.php +++ b/rules/transform/tests/Rector/Expression/MethodCallToReturnRector/MethodCallToReturnRectorTest.php @@ -6,9 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\Expression\MethodCallToReturnRector; -use Rector\Transform\Tests\Rector\Expression\MethodCallToReturnRector\Source\ReturnDeny; -use Rector\Transform\ValueObject\MethodCallToReturn; use Symplify\SmartFileSystem\SmartFileInfo; final class MethodCallToReturnRectorTest extends AbstractRectorTestCase @@ -26,15 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - MethodCallToReturnRector::class => [ - MethodCallToReturnRector::METHOD_CALL_WRAPS => [new MethodCallToReturn(ReturnDeny::class, 'deny')], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/Expression/MethodCallToReturnRector/config/configured_rule.php b/rules/transform/tests/Rector/Expression/MethodCallToReturnRector/config/configured_rule.php new file mode 100644 index 000000000000..3ece9443df45 --- /dev/null +++ b/rules/transform/tests/Rector/Expression/MethodCallToReturnRector/config/configured_rule.php @@ -0,0 +1,58 @@ +services(); + $services->set(\Rector\Transform\Rector\Expression\MethodCallToReturnRector::class)->call('configure', [[ + \Rector\Transform\Rector\Expression\MethodCallToReturnRector::METHOD_CALL_WRAPS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + new \Rector\Transform\ValueObject\MethodCallToReturn( + \Rector\Transform\Tests\Rector\Expression\MethodCallToReturnRector\Source\ReturnDeny::class, + 'deny' + ), + + + + + + + + + + + + + + + + + + + + + + + + + + ]), + ]]); +}; diff --git a/rules/transform/tests/Rector/FuncCall/ArgumentFuncCallToMethodCallRector/ArgumentFuncCallToMethodCallRectorTest.php b/rules/transform/tests/Rector/FuncCall/ArgumentFuncCallToMethodCallRector/ArgumentFuncCallToMethodCallRectorTest.php index 510fab04396e..34ff873230eb 100644 --- a/rules/transform/tests/Rector/FuncCall/ArgumentFuncCallToMethodCallRector/ArgumentFuncCallToMethodCallRectorTest.php +++ b/rules/transform/tests/Rector/FuncCall/ArgumentFuncCallToMethodCallRector/ArgumentFuncCallToMethodCallRectorTest.php @@ -6,9 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\FuncCall\ArgumentFuncCallToMethodCallRector; -use Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall; -use Rector\Transform\ValueObject\ArrayFuncCallToMethodCall; use Symplify\SmartFileSystem\SmartFileInfo; final class ArgumentFuncCallToMethodCallRectorTest extends AbstractRectorTestCase @@ -26,28 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - ArgumentFuncCallToMethodCallRector::class => [ - ArgumentFuncCallToMethodCallRector::FUNCTIONS_TO_METHOD_CALLS => [ - new ArgumentFuncCallToMethodCall('view', 'Illuminate\Contracts\View\Factory', 'make'), - new ArgumentFuncCallToMethodCall('route', 'Illuminate\Routing\UrlGenerator', 'route'), - new ArgumentFuncCallToMethodCall('back', 'Illuminate\Routing\Redirector', 'back', 'back'), - new ArgumentFuncCallToMethodCall( - 'broadcast', - 'Illuminate\Contracts\Broadcasting\Factory', - 'event' - ), - ], - ArgumentFuncCallToMethodCallRector::ARRAY_FUNCTIONS_TO_METHOD_CALLS => [ - new ArrayFuncCallToMethodCall('config', 'Illuminate\Contracts\Config\Repository', 'set', 'get'), - new ArrayFuncCallToMethodCall('session', 'Illuminate\Session\SessionManager', 'put', 'get'), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/FuncCall/ArgumentFuncCallToMethodCallRector/config/configured_rule.php b/rules/transform/tests/Rector/FuncCall/ArgumentFuncCallToMethodCallRector/config/configured_rule.php new file mode 100644 index 000000000000..0578d5cea8e4 --- /dev/null +++ b/rules/transform/tests/Rector/FuncCall/ArgumentFuncCallToMethodCallRector/config/configured_rule.php @@ -0,0 +1,27 @@ +services(); + + $services->set(ArgumentFuncCallToMethodCallRector::class) + ->call('configure', [[ + ArgumentFuncCallToMethodCallRector::FUNCTIONS_TO_METHOD_CALLS => ValueObjectInliner::inline([ + new ArgumentFuncCallToMethodCall('view', 'Illuminate\Contracts\View\Factory', 'make'), + new ArgumentFuncCallToMethodCall('route', 'Illuminate\Routing\UrlGenerator', 'route'), + new ArgumentFuncCallToMethodCall('back', 'Illuminate\Routing\Redirector', 'back', 'back'), + new ArgumentFuncCallToMethodCall('broadcast', 'Illuminate\Contracts\Broadcasting\Factory', 'event'), + ]), + ArgumentFuncCallToMethodCallRector::ARRAY_FUNCTIONS_TO_METHOD_CALLS => ValueObjectInliner::inline([ + new ArrayFuncCallToMethodCall('config', 'Illuminate\Contracts\Config\Repository', 'set', 'get'), + new ArrayFuncCallToMethodCall('session', 'Illuminate\Session\SessionManager', 'put', 'get'), + ]), + ]]); +}; diff --git a/rules/transform/tests/Rector/FuncCall/FuncCallToMethodCallRector/FuncCallToMethodCallRectorTest.php b/rules/transform/tests/Rector/FuncCall/FuncCallToMethodCallRector/FuncCallToMethodCallRectorTest.php index 8eea41dbe866..ccd310a52936 100644 --- a/rules/transform/tests/Rector/FuncCall/FuncCallToMethodCallRector/FuncCallToMethodCallRectorTest.php +++ b/rules/transform/tests/Rector/FuncCall/FuncCallToMethodCallRector/FuncCallToMethodCallRectorTest.php @@ -6,9 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\FuncCall\FuncCallToMethodCallRector; -use Rector\Transform\Tests\Rector\FuncCall\FuncCallToMethodCallRector\Source\SomeTranslator; -use Rector\Transform\ValueObject\FuncNameToMethodCallName; use Symplify\SmartFileSystem\SmartFileInfo; final class FuncCallToMethodCallRectorTest extends AbstractRectorTestCase @@ -26,23 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - FuncCallToMethodCallRector::class => [ - FuncCallToMethodCallRector::FUNC_CALL_TO_CLASS_METHOD_CALL => [ - new FuncNameToMethodCallName('view', 'Namespaced\SomeRenderer', 'render'), - new FuncNameToMethodCallName('translate', SomeTranslator::class, 'translateMethod'), - new FuncNameToMethodCallName( - 'Rector\Generic\Tests\Rector\Function_\FuncCallToMethodCallRector\Source\some_view_function', - 'Namespaced\SomeRenderer', - 'render' - ), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/FuncCall/FuncCallToMethodCallRector/config/configured_rule.php b/rules/transform/tests/Rector/FuncCall/FuncCallToMethodCallRector/config/configured_rule.php new file mode 100644 index 000000000000..add10f0b7fa8 --- /dev/null +++ b/rules/transform/tests/Rector/FuncCall/FuncCallToMethodCallRector/config/configured_rule.php @@ -0,0 +1,23 @@ +services(); + $services->set(FuncCallToMethodCallRector::class) + ->call('configure', [[ + FuncCallToMethodCallRector::FUNC_CALL_TO_CLASS_METHOD_CALL => ValueObjectInliner::inline([ + new FuncCallToMethodCall('view', 'Namespaced\SomeRenderer', 'render'), + new FuncCallToMethodCall('translate', SomeTranslator::class, 'translateMethod'), + new FuncCallToMethodCall( + 'Rector\Generic\Tests\Rector\Function_\FuncCallToMethodCallRector\Source\some_view_function', + 'Namespaced\SomeRenderer', + 'render' + ), + ]), + ]]); +}; diff --git a/rules/transform/tests/Rector/FuncCall/FuncCallToNewRector/FuncCallToNewRectorTest.php b/rules/transform/tests/Rector/FuncCall/FuncCallToNewRector/FuncCallToNewRectorTest.php index 8c7b51f3838c..fa69fc581ef8 100644 --- a/rules/transform/tests/Rector/FuncCall/FuncCallToNewRector/FuncCallToNewRectorTest.php +++ b/rules/transform/tests/Rector/FuncCall/FuncCallToNewRector/FuncCallToNewRectorTest.php @@ -6,7 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\FuncCall\FuncCallToNewRector; use Symplify\SmartFileSystem\SmartFileInfo; final class FuncCallToNewRectorTest extends AbstractRectorTestCase @@ -24,17 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - FuncCallToNewRector::class => [ - FuncCallToNewRector::FUNCTIONS_TO_NEWS => [ - 'collection' => ['Collection'], - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/FuncCall/FuncCallToNewRector/config/configured_rule.php b/rules/transform/tests/Rector/FuncCall/FuncCallToNewRector/config/configured_rule.php new file mode 100644 index 000000000000..d720003f3859 --- /dev/null +++ b/rules/transform/tests/Rector/FuncCall/FuncCallToNewRector/config/configured_rule.php @@ -0,0 +1,12 @@ +services(); + $services->set(\Rector\Transform\Rector\FuncCall\FuncCallToNewRector::class)->call('configure', [[ + \Rector\Transform\Rector\FuncCall\FuncCallToNewRector::FUNCTIONS_TO_NEWS => [ + 'collection' => ['Collection'], + ], + ]]); +}; diff --git a/rules/transform/tests/Rector/FuncCall/FuncCallToStaticCallRector/FuncCallToStaticCallRectorTest.php b/rules/transform/tests/Rector/FuncCall/FuncCallToStaticCallRector/FuncCallToStaticCallRectorTest.php index c1930b2b7794..d8af57a2769c 100644 --- a/rules/transform/tests/Rector/FuncCall/FuncCallToStaticCallRector/FuncCallToStaticCallRectorTest.php +++ b/rules/transform/tests/Rector/FuncCall/FuncCallToStaticCallRector/FuncCallToStaticCallRectorTest.php @@ -6,8 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\FuncCall\FuncCallToStaticCallRector; -use Rector\Transform\ValueObject\FuncCallToStaticCall; use Symplify\SmartFileSystem\SmartFileInfo; final class FuncCallToStaticCallRectorTest extends AbstractRectorTestCase @@ -25,18 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - FuncCallToStaticCallRector::class => [ - FuncCallToStaticCallRector::FUNC_CALLS_TO_STATIC_CALLS => [ - new FuncCallToStaticCall('view', 'SomeStaticClass', 'render'), - new FuncCallToStaticCall('SomeNamespaced\view', 'AnotherStaticClass', 'render'), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/FuncCall/FuncCallToStaticCallRector/config/configured_rule.php b/rules/transform/tests/Rector/FuncCall/FuncCallToStaticCallRector/config/configured_rule.php new file mode 100644 index 000000000000..3113b85a9539 --- /dev/null +++ b/rules/transform/tests/Rector/FuncCall/FuncCallToStaticCallRector/config/configured_rule.php @@ -0,0 +1,60 @@ +services(); + $services->set(\Rector\Transform\Rector\FuncCall\FuncCallToStaticCallRector::class)->call('configure', [[ + \Rector\Transform\Rector\FuncCall\FuncCallToStaticCallRector::FUNC_CALLS_TO_STATIC_CALLS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + new \Rector\Transform\ValueObject\FuncCallToStaticCall('view', 'SomeStaticClass', 'render'), + new \Rector\Transform\ValueObject\FuncCallToStaticCall( + 'SomeNamespaced\view', + 'AnotherStaticClass', + 'render' + ), + + + + + + + + + + + + + + + + + + + + + + + + + + ]), + ]]); +}; diff --git a/rules/transform/tests/Rector/Isset_/UnsetAndIssetToMethodCallRector/UnsetAndIssetToMethodCallRectorTest.php b/rules/transform/tests/Rector/Isset_/UnsetAndIssetToMethodCallRector/UnsetAndIssetToMethodCallRectorTest.php index 220afa9763bb..36c0ff3f94c5 100644 --- a/rules/transform/tests/Rector/Isset_/UnsetAndIssetToMethodCallRector/UnsetAndIssetToMethodCallRectorTest.php +++ b/rules/transform/tests/Rector/Isset_/UnsetAndIssetToMethodCallRector/UnsetAndIssetToMethodCallRectorTest.php @@ -6,9 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\Isset_\UnsetAndIssetToMethodCallRector; -use Rector\Transform\Tests\Rector\Isset_\UnsetAndIssetToMethodCallRector\Source\LocalContainer; -use Rector\Transform\ValueObject\IssetUnsetToMethodCall; use Symplify\SmartFileSystem\SmartFileInfo; final class UnsetAndIssetToMethodCallRectorTest extends AbstractRectorTestCase @@ -26,17 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - UnsetAndIssetToMethodCallRector::class => [ - UnsetAndIssetToMethodCallRector::ISSET_UNSET_TO_METHOD_CALL => [ - new IssetUnsetToMethodCall(LocalContainer::class, 'hasService', 'removeService'), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/Isset_/UnsetAndIssetToMethodCallRector/config/configured_rule.php b/rules/transform/tests/Rector/Isset_/UnsetAndIssetToMethodCallRector/config/configured_rule.php new file mode 100644 index 000000000000..47dfcb600973 --- /dev/null +++ b/rules/transform/tests/Rector/Isset_/UnsetAndIssetToMethodCallRector/config/configured_rule.php @@ -0,0 +1,20 @@ +services(); + $services->set(UnsetAndIssetToMethodCallRector::class)->call('configure', [[ + UnsetAndIssetToMethodCallRector::ISSET_UNSET_TO_METHOD_CALL => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + new UnsetAndIssetToMethodCall(LocalContainer::class, 'hasService', 'removeService'), + + + ]), + ]]); +}; diff --git a/rules/transform/tests/Rector/MethodCall/CallableInMethodCallToVariableRector/CallableInMethodCallToVariableRectorTest.php b/rules/transform/tests/Rector/MethodCall/CallableInMethodCallToVariableRector/CallableInMethodCallToVariableRectorTest.php index 92975ee0c262..63a7eeff6b8f 100644 --- a/rules/transform/tests/Rector/MethodCall/CallableInMethodCallToVariableRector/CallableInMethodCallToVariableRectorTest.php +++ b/rules/transform/tests/Rector/MethodCall/CallableInMethodCallToVariableRector/CallableInMethodCallToVariableRectorTest.php @@ -6,9 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\MethodCall\CallableInMethodCallToVariableRector; -use Rector\Transform\Tests\Rector\MethodCall\CallableInMethodCallToVariableRector\Source\DummyCache; -use Rector\Transform\ValueObject\CallableInMethodCallToVariable; use Symplify\SmartFileSystem\SmartFileInfo; final class CallableInMethodCallToVariableRectorTest extends AbstractRectorTestCase @@ -26,17 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return mixed[] - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - CallableInMethodCallToVariableRector::class => [ - CallableInMethodCallToVariableRector::CALLABLE_IN_METHOD_CALL_TO_VARIABLE => [ - new CallableInMethodCallToVariable(DummyCache::class, 'save', 1), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/MethodCall/CallableInMethodCallToVariableRector/config/configured_rule.php b/rules/transform/tests/Rector/MethodCall/CallableInMethodCallToVariableRector/config/configured_rule.php new file mode 100644 index 000000000000..17f052d9ca25 --- /dev/null +++ b/rules/transform/tests/Rector/MethodCall/CallableInMethodCallToVariableRector/config/configured_rule.php @@ -0,0 +1,69 @@ +services(); + $services->set(\Rector\Transform\Rector\MethodCall\CallableInMethodCallToVariableRector::class)->call( + 'configure', + [[ + \Rector\Transform\Rector\MethodCall\CallableInMethodCallToVariableRector::CALLABLE_IN_METHOD_CALL_TO_VARIABLE => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + + + + + + + + new \Rector\Transform\ValueObject\CallableInMethodCallToVariable( + \Rector\Transform\Tests\Rector\MethodCall\CallableInMethodCallToVariableRector\Source\DummyCache::class, + 'save', + 1 + ), + + + + + + + + + + + + + + + + + + + + + + + + + + ]), + ]] + ); +}; diff --git a/rules/transform/tests/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector/MethodCallToAnotherMethodCallWithArgumentsRectorTest.php b/rules/transform/tests/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector/MethodCallToAnotherMethodCallWithArgumentsRectorTest.php index 6d3b867891c0..4add408819fe 100644 --- a/rules/transform/tests/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector/MethodCallToAnotherMethodCallWithArgumentsRectorTest.php +++ b/rules/transform/tests/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector/MethodCallToAnotherMethodCallWithArgumentsRectorTest.php @@ -6,9 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector; -use Rector\Transform\Tests\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector\Source\NetteServiceDefinition; -use Rector\Transform\ValueObject\MethodCallToAnotherMethodCallWithArguments; use Symplify\SmartFileSystem\SmartFileInfo; final class MethodCallToAnotherMethodCallWithArgumentsRectorTest extends AbstractRectorTestCase @@ -26,22 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - MethodCallToAnotherMethodCallWithArgumentsRector::class => [ - MethodCallToAnotherMethodCallWithArgumentsRector::METHOD_CALL_RENAMES_WITH_ADDED_ARGUMENTS => [ - new MethodCallToAnotherMethodCallWithArguments( - NetteServiceDefinition::class, - 'setInject', - 'addTag', - ['inject'] - ), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector/config/configured_rule.php b/rules/transform/tests/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector/config/configured_rule.php new file mode 100644 index 000000000000..3f99f3cc3595 --- /dev/null +++ b/rules/transform/tests/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector/config/configured_rule.php @@ -0,0 +1,45 @@ +services(); + $services->set(\Rector\Transform\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector::class)->call( + 'configure', + [[ + \Rector\Transform\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector::METHOD_CALL_RENAMES_WITH_ADDED_ARGUMENTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + + + + + + + + new \Rector\Transform\ValueObject\MethodCallToAnotherMethodCallWithArguments( + \Rector\Transform\Tests\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector\Source\NetteServiceDefinition::class, + 'setInject', + 'addTag', + ['inject']), + ] + ), + ]] + ); +}; diff --git a/rules/transform/tests/Rector/MethodCall/MethodCallToPropertyFetchRector/MethodCallToPropertyFetchRectorTest.php b/rules/transform/tests/Rector/MethodCall/MethodCallToPropertyFetchRector/MethodCallToPropertyFetchRectorTest.php index 66e262d12112..4919b6f9d379 100644 --- a/rules/transform/tests/Rector/MethodCall/MethodCallToPropertyFetchRector/MethodCallToPropertyFetchRectorTest.php +++ b/rules/transform/tests/Rector/MethodCall/MethodCallToPropertyFetchRector/MethodCallToPropertyFetchRectorTest.php @@ -6,7 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\MethodCall\MethodCallToPropertyFetchRector; use Symplify\SmartFileSystem\SmartFileInfo; final class MethodCallToPropertyFetchRectorTest extends AbstractRectorTestCase @@ -24,17 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - MethodCallToPropertyFetchRector::class => [ - MethodCallToPropertyFetchRector::METHOD_CALL_TO_PROPERTY_FETCHES => [ - 'getEntityManager' => 'entityManager', - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/MethodCall/MethodCallToPropertyFetchRector/config/configured_rule.php b/rules/transform/tests/Rector/MethodCall/MethodCallToPropertyFetchRector/config/configured_rule.php new file mode 100644 index 000000000000..3f974faf4454 --- /dev/null +++ b/rules/transform/tests/Rector/MethodCall/MethodCallToPropertyFetchRector/config/configured_rule.php @@ -0,0 +1,12 @@ +services(); + $services->set(\Rector\Transform\Rector\MethodCall\MethodCallToPropertyFetchRector::class)->call('configure', [[ + \Rector\Transform\Rector\MethodCall\MethodCallToPropertyFetchRector::METHOD_CALL_TO_PROPERTY_FETCHES => [ + 'getEntityManager' => 'entityManager', + ], + ]]); +}; diff --git a/rules/transform/tests/Rector/MethodCall/MethodCallToStaticCallRector/MethodCallToStaticCallRectorTest.php b/rules/transform/tests/Rector/MethodCall/MethodCallToStaticCallRector/MethodCallToStaticCallRectorTest.php index 5b468475aec5..b49e7c32249d 100644 --- a/rules/transform/tests/Rector/MethodCall/MethodCallToStaticCallRector/MethodCallToStaticCallRectorTest.php +++ b/rules/transform/tests/Rector/MethodCall/MethodCallToStaticCallRector/MethodCallToStaticCallRectorTest.php @@ -6,9 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\MethodCall\MethodCallToStaticCallRector; -use Rector\Transform\Tests\Rector\MethodCall\MethodCallToStaticCallRector\Source\AnotherDependency; -use Rector\Transform\ValueObject\MethodCallToStaticCall; use Symplify\SmartFileSystem\SmartFileInfo; final class MethodCallToStaticCallRectorTest extends AbstractRectorTestCase @@ -26,17 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - MethodCallToStaticCallRector::class => [ - MethodCallToStaticCallRector::METHOD_CALLS_TO_STATIC_CALLS => [ - new MethodCallToStaticCall(AnotherDependency::class, 'process', 'StaticCaller', 'anotherMethod'), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/MethodCall/MethodCallToStaticCallRector/config/configured_rule.php b/rules/transform/tests/Rector/MethodCall/MethodCallToStaticCallRector/config/configured_rule.php new file mode 100644 index 000000000000..5f076b81be8d --- /dev/null +++ b/rules/transform/tests/Rector/MethodCall/MethodCallToStaticCallRector/config/configured_rule.php @@ -0,0 +1,60 @@ +services(); + $services->set(\Rector\Transform\Rector\MethodCall\MethodCallToStaticCallRector::class)->call('configure', [[ + \Rector\Transform\Rector\MethodCall\MethodCallToStaticCallRector::METHOD_CALLS_TO_STATIC_CALLS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + new \Rector\Transform\ValueObject\MethodCallToStaticCall( + \Rector\Transform\Tests\Rector\MethodCall\MethodCallToStaticCallRector\Source\AnotherDependency::class, + 'process', + 'StaticCaller', + 'anotherMethod' + ), + + + + + + + + + + + + + + + + + + + + + + + + + + ]), + ]]); +}; diff --git a/rules/transform/tests/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/ReplaceParentCallByPropertyCallRectorTest.php b/rules/transform/tests/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/ReplaceParentCallByPropertyCallRectorTest.php index 790f78ade022..3114bf5ad732 100644 --- a/rules/transform/tests/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/ReplaceParentCallByPropertyCallRectorTest.php +++ b/rules/transform/tests/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/ReplaceParentCallByPropertyCallRectorTest.php @@ -6,9 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\MethodCall\ReplaceParentCallByPropertyCallRector; -use Rector\Transform\Tests\Rector\MethodCall\ReplaceParentCallByPropertyCallRector\Source\TypeClassToReplaceMethodCallBy; -use Rector\Transform\ValueObject\ReplaceParentCallByPropertyCall; use Symplify\SmartFileSystem\SmartFileInfo; final class ReplaceParentCallByPropertyCallRectorTest extends AbstractRectorTestCase @@ -26,21 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - ReplaceParentCallByPropertyCallRector::class => [ - ReplaceParentCallByPropertyCallRector::PARENT_CALLS_TO_PROPERTIES => [ - new ReplaceParentCallByPropertyCall( - TypeClassToReplaceMethodCallBy::class, - 'someMethod', - 'someProperty' - ), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/config/configured_rule.php b/rules/transform/tests/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/config/configured_rule.php new file mode 100644 index 000000000000..18037d34255f --- /dev/null +++ b/rules/transform/tests/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/config/configured_rule.php @@ -0,0 +1,69 @@ +services(); + $services->set(\Rector\Transform\Rector\MethodCall\ReplaceParentCallByPropertyCallRector::class)->call( + 'configure', + [[ + \Rector\Transform\Rector\MethodCall\ReplaceParentCallByPropertyCallRector::PARENT_CALLS_TO_PROPERTIES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + + + + + + + + new \Rector\Transform\ValueObject\ReplaceParentCallByPropertyCall( + \Rector\Transform\Tests\Rector\MethodCall\ReplaceParentCallByPropertyCallRector\Source\TypeClassToReplaceMethodCallBy::class, + 'someMethod', + 'someProperty' + ), + + + + + + + + + + + + + + + + + + + + + + + + + + ]), + ]] + ); +}; diff --git a/rules/transform/tests/Rector/MethodCall/ServiceGetterToConstructorInjectionRector/ServiceGetterToConstructorInjectionRectorTest.php b/rules/transform/tests/Rector/MethodCall/ServiceGetterToConstructorInjectionRector/ServiceGetterToConstructorInjectionRectorTest.php index d8f39b9b262a..d076054cfb7c 100644 --- a/rules/transform/tests/Rector/MethodCall/ServiceGetterToConstructorInjectionRector/ServiceGetterToConstructorInjectionRectorTest.php +++ b/rules/transform/tests/Rector/MethodCall/ServiceGetterToConstructorInjectionRector/ServiceGetterToConstructorInjectionRectorTest.php @@ -7,10 +7,6 @@ use Iterator; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\MethodCall\ServiceGetterToConstructorInjectionRector; -use Rector\Transform\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Source\AnotherService; -use Rector\Transform\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Source\FirstService; -use Rector\Transform\ValueObject\ServiceGetterToConstructorInjection; use Symplify\SmartFileSystem\SmartFileInfo; final class ServiceGetterToConstructorInjectionRectorTest extends AbstractRectorTestCase @@ -33,21 +29,8 @@ protected function getPhpVersion(): int return PhpVersionFeature::TYPED_PROPERTIES - 1; } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - ServiceGetterToConstructorInjectionRector::class => [ - ServiceGetterToConstructorInjectionRector::METHOD_CALL_TO_SERVICES => [ - new ServiceGetterToConstructorInjection( - FirstService::class, - 'getAnotherService', - AnotherService::class - ), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/MethodCall/ServiceGetterToConstructorInjectionRector/config/configured_rule.php b/rules/transform/tests/Rector/MethodCall/ServiceGetterToConstructorInjectionRector/config/configured_rule.php new file mode 100644 index 000000000000..63358b094959 --- /dev/null +++ b/rules/transform/tests/Rector/MethodCall/ServiceGetterToConstructorInjectionRector/config/configured_rule.php @@ -0,0 +1,69 @@ +services(); + $services->set(\Rector\Transform\Rector\MethodCall\ServiceGetterToConstructorInjectionRector::class)->call( + 'configure', + [[ + \Rector\Transform\Rector\MethodCall\ServiceGetterToConstructorInjectionRector::METHOD_CALL_TO_SERVICES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + + + + + + + + new \Rector\Transform\ValueObject\ServiceGetterToConstructorInjection( + \Rector\Transform\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Source\FirstService::class, + 'getAnotherService', + \Rector\Transform\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Source\AnotherService::class + ), + + + + + + + + + + + + + + + + + + + + + + + + + + ]), + ]] + ); +}; diff --git a/rules/transform/tests/Rector/MethodCall/VariableMethodCallToServiceCallRector/VariableMethodCallToServiceCallRectorTest.php b/rules/transform/tests/Rector/MethodCall/VariableMethodCallToServiceCallRector/VariableMethodCallToServiceCallRectorTest.php index 921c5fda87fa..c9a3634dc8aa 100644 --- a/rules/transform/tests/Rector/MethodCall/VariableMethodCallToServiceCallRector/VariableMethodCallToServiceCallRectorTest.php +++ b/rules/transform/tests/Rector/MethodCall/VariableMethodCallToServiceCallRector/VariableMethodCallToServiceCallRectorTest.php @@ -6,8 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\MethodCall\VariableMethodCallToServiceCallRector; -use Rector\Transform\ValueObject\VariableMethodCallToServiceCall; use Symplify\SmartFileSystem\SmartFileInfo; final class VariableMethodCallToServiceCallRectorTest extends AbstractRectorTestCase @@ -25,23 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return mixed[] - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - VariableMethodCallToServiceCallRector::class => [ - VariableMethodCallToServiceCallRector::VARIABLE_METHOD_CALLS_TO_SERVICE_CALLS => [ - new VariableMethodCallToServiceCall( - 'PhpParser\Node', - 'getAttribute', - 'php_doc_info', - 'Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory', - 'createFromNodeOrEmpty' - ), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/MethodCall/VariableMethodCallToServiceCallRector/config/configured_rule.php b/rules/transform/tests/Rector/MethodCall/VariableMethodCallToServiceCallRector/config/configured_rule.php new file mode 100644 index 000000000000..e11ad98349b0 --- /dev/null +++ b/rules/transform/tests/Rector/MethodCall/VariableMethodCallToServiceCallRector/config/configured_rule.php @@ -0,0 +1,71 @@ +services(); + $services->set(\Rector\Transform\Rector\MethodCall\VariableMethodCallToServiceCallRector::class)->call( + 'configure', + [[ + \Rector\Transform\Rector\MethodCall\VariableMethodCallToServiceCallRector::VARIABLE_METHOD_CALLS_TO_SERVICE_CALLS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + + + + + + + + new \Rector\Transform\ValueObject\VariableMethodCallToServiceCall( + 'PhpParser\Node', + 'getAttribute', + 'php_doc_info', + 'Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory', + 'createFromNodeOrEmpty' + ), + + + + + + + + + + + + + + + + + + + + + + + + + + ]), + ]] + ); +}; diff --git a/rules/transform/tests/Rector/New_/NewArgToMethodCallRector/NewArgToMethodCallRectorTest.php b/rules/transform/tests/Rector/New_/NewArgToMethodCallRector/NewArgToMethodCallRectorTest.php index c130548a1630..6e0662478350 100644 --- a/rules/transform/tests/Rector/New_/NewArgToMethodCallRector/NewArgToMethodCallRectorTest.php +++ b/rules/transform/tests/Rector/New_/NewArgToMethodCallRector/NewArgToMethodCallRectorTest.php @@ -6,9 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\New_\NewArgToMethodCallRector; -use Rector\Transform\Tests\Rector\New_\NewArgToMethodCallRector\Source\SomeDotenv; -use Rector\Transform\ValueObject\NewArgToMethodCall; use Symplify\SmartFileSystem\SmartFileInfo; final class NewArgToMethodCallRectorTest extends AbstractRectorTestCase @@ -26,17 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return mixed[] - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - NewArgToMethodCallRector::class => [ - NewArgToMethodCallRector::NEW_ARGS_TO_METHOD_CALLS => [ - new NewArgToMethodCall(SomeDotenv::class, true, 'usePutenv'), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/New_/NewArgToMethodCallRector/config/configured_rule.php b/rules/transform/tests/Rector/New_/NewArgToMethodCallRector/config/configured_rule.php index a2e8e0dd88ba..5394bf6260fa 100644 --- a/rules/transform/tests/Rector/New_/NewArgToMethodCallRector/config/configured_rule.php +++ b/rules/transform/tests/Rector/New_/NewArgToMethodCallRector/config/configured_rule.php @@ -1,4 +1,16 @@ -return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void { +services(); - $services->set(\Rector\Transform\Rector\New_\NewArgToMethodCallRector::class)->configure('call', [[\Rector\Transform\Rector\New_\NewArgToMethodCallRector::NEW_ARGS_TO_METHOD_CALLS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Transform\ValueObject\NewArgToMethodCall(\Rector\Transform\Tests\Rector\New_\NewArgToMethodCallRector\Source\SomeDotenv::class, true, 'usePutenv')])]]); -}; \ No newline at end of file + $services->set(NewArgToMethodCallRector::class)->call('configure', [[ + NewArgToMethodCallRector::NEW_ARGS_TO_METHOD_CALLS => ValueObjectInliner::inline([ + new NewArgToMethodCall(SomeDotenv::class, true, 'usePutenv'), + ]), + ]]); +}; diff --git a/rules/transform/tests/Rector/New_/NewToConstructorInjectionRector/NewToConstructorInjectionRectorTest.php b/rules/transform/tests/Rector/New_/NewToConstructorInjectionRector/NewToConstructorInjectionRectorTest.php index e00230cd9619..e14c0fecadf0 100644 --- a/rules/transform/tests/Rector/New_/NewToConstructorInjectionRector/NewToConstructorInjectionRectorTest.php +++ b/rules/transform/tests/Rector/New_/NewToConstructorInjectionRector/NewToConstructorInjectionRectorTest.php @@ -6,8 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\New_\NewToConstructorInjectionRector; -use Rector\Transform\Tests\Rector\New_\NewToConstructorInjectionRector\Source\DummyValidator; use Symplify\SmartFileSystem\SmartFileInfo; final class NewToConstructorInjectionRectorTest extends AbstractRectorTestCase @@ -25,15 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - NewToConstructorInjectionRector::class => [ - NewToConstructorInjectionRector::TYPES_TO_CONSTRUCTOR_INJECTION => [DummyValidator::class], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/New_/NewToConstructorInjectionRector/Php80Test.php b/rules/transform/tests/Rector/New_/NewToConstructorInjectionRector/Php80Test.php index 00727ed371ab..1b7c4e5fb7ac 100644 --- a/rules/transform/tests/Rector/New_/NewToConstructorInjectionRector/Php80Test.php +++ b/rules/transform/tests/Rector/New_/NewToConstructorInjectionRector/Php80Test.php @@ -7,8 +7,6 @@ use Iterator; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\New_\NewToConstructorInjectionRector; -use Rector\Transform\Tests\Rector\New_\NewToConstructorInjectionRector\Source\DummyValidator; use Symplify\SmartFileSystem\SmartFileInfo; final class Php80Test extends AbstractRectorTestCase @@ -31,15 +29,8 @@ protected function getPhpVersion(): int return PhpVersionFeature::PROPERTY_PROMOTION; } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - NewToConstructorInjectionRector::class => [ - NewToConstructorInjectionRector::TYPES_TO_CONSTRUCTOR_INJECTION => [DummyValidator::class], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/New_/NewToConstructorInjectionRector/config/configured_rule.php b/rules/transform/tests/Rector/New_/NewToConstructorInjectionRector/config/configured_rule.php new file mode 100644 index 000000000000..458a283e6d90 --- /dev/null +++ b/rules/transform/tests/Rector/New_/NewToConstructorInjectionRector/config/configured_rule.php @@ -0,0 +1,12 @@ +services(); + $services->set(\Rector\Transform\Rector\New_\NewToConstructorInjectionRector::class)->call('configure', [[ + \Rector\Transform\Rector\New_\NewToConstructorInjectionRector::TYPES_TO_CONSTRUCTOR_INJECTION => [ + \Rector\Transform\Tests\Rector\New_\NewToConstructorInjectionRector\Source\DummyValidator::class, + ], + ]]); +}; diff --git a/rules/transform/tests/Rector/New_/NewToMethodCallRector/NewToMethodCallRectorTest.php b/rules/transform/tests/Rector/New_/NewToMethodCallRector/NewToMethodCallRectorTest.php index 0967cdaff5ff..8f4bcea62124 100644 --- a/rules/transform/tests/Rector/New_/NewToMethodCallRector/NewToMethodCallRectorTest.php +++ b/rules/transform/tests/Rector/New_/NewToMethodCallRector/NewToMethodCallRectorTest.php @@ -6,10 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\New_\NewToMethodCallRector; -use Rector\Transform\Tests\Rector\New_\NewToMethodCallRector\Source\MyClass; -use Rector\Transform\Tests\Rector\New_\NewToMethodCallRector\Source\MyClassFactory; -use Rector\Transform\ValueObject\NewToMethodCall; use Symplify\SmartFileSystem\SmartFileInfo; final class NewToMethodCallRectorTest extends AbstractRectorTestCase @@ -27,17 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - NewToMethodCallRector::class => [ - NewToMethodCallRector::NEWS_TO_METHOD_CALLS => [ - new NewToMethodCall(MyClass::class, MyClassFactory::class, 'create'), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/New_/NewToMethodCallRector/config/configured_rule.php b/rules/transform/tests/Rector/New_/NewToMethodCallRector/config/configured_rule.php new file mode 100644 index 000000000000..0b05c379297f --- /dev/null +++ b/rules/transform/tests/Rector/New_/NewToMethodCallRector/config/configured_rule.php @@ -0,0 +1,59 @@ +services(); + $services->set(\Rector\Transform\Rector\New_\NewToMethodCallRector::class)->call('configure', [[ + \Rector\Transform\Rector\New_\NewToMethodCallRector::NEWS_TO_METHOD_CALLS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + new \Rector\Transform\ValueObject\NewToMethodCall( + \Rector\Transform\Tests\Rector\New_\NewToMethodCallRector\Source\MyClass::class, + \Rector\Transform\Tests\Rector\New_\NewToMethodCallRector\Source\MyClassFactory::class, + 'create' + ), + + + + + + + + + + + + + + + + + + + + + + + + + + ]), + ]]); +}; diff --git a/rules/transform/tests/Rector/New_/NewToStaticCallRector/NewToStaticCallRectorTest.php b/rules/transform/tests/Rector/New_/NewToStaticCallRector/NewToStaticCallRectorTest.php index e56562a3ebcd..17d44402cb7b 100644 --- a/rules/transform/tests/Rector/New_/NewToStaticCallRector/NewToStaticCallRectorTest.php +++ b/rules/transform/tests/Rector/New_/NewToStaticCallRector/NewToStaticCallRectorTest.php @@ -6,10 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\New_\NewToStaticCallRector; -use Rector\Transform\Tests\Rector\New_\NewToStaticCallRector\Source\FromNewClass; -use Rector\Transform\Tests\Rector\New_\NewToStaticCallRector\Source\IntoStaticClass; -use Rector\Transform\ValueObject\NewToStaticCall; use Symplify\SmartFileSystem\SmartFileInfo; final class NewToStaticCallRectorTest extends AbstractRectorTestCase @@ -27,17 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - NewToStaticCallRector::class => [ - NewToStaticCallRector::TYPE_TO_STATIC_CALLS => [ - new NewToStaticCall(FromNewClass::class, IntoStaticClass::class, 'run'), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/New_/NewToStaticCallRector/config/configured_rule.php b/rules/transform/tests/Rector/New_/NewToStaticCallRector/config/configured_rule.php new file mode 100644 index 000000000000..0f146914a306 --- /dev/null +++ b/rules/transform/tests/Rector/New_/NewToStaticCallRector/config/configured_rule.php @@ -0,0 +1,59 @@ +services(); + $services->set(\Rector\Transform\Rector\New_\NewToStaticCallRector::class)->call('configure', [[ + \Rector\Transform\Rector\New_\NewToStaticCallRector::TYPE_TO_STATIC_CALLS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + new \Rector\Transform\ValueObject\NewToStaticCall( + \Rector\Transform\Tests\Rector\New_\NewToStaticCallRector\Source\FromNewClass::class, + \Rector\Transform\Tests\Rector\New_\NewToStaticCallRector\Source\IntoStaticClass::class, + 'run' + ), + + + + + + + + + + + + + + + + + + + + + + + + + + ]), + ]]); +}; diff --git a/rules/transform/tests/Rector/StaticCall/StaticCallToFuncCallRector/StaticCallToFuncCallRectorTest.php b/rules/transform/tests/Rector/StaticCall/StaticCallToFuncCallRector/StaticCallToFuncCallRectorTest.php index 3e3f1f3551ed..0a4739e99f1b 100644 --- a/rules/transform/tests/Rector/StaticCall/StaticCallToFuncCallRector/StaticCallToFuncCallRectorTest.php +++ b/rules/transform/tests/Rector/StaticCall/StaticCallToFuncCallRector/StaticCallToFuncCallRectorTest.php @@ -6,9 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector; -use Rector\Transform\Tests\Rector\StaticCall\StaticCallToFuncCallRector\Source\SomeOldStaticClass; -use Rector\Transform\ValueObject\StaticCallToFuncCall; use Symplify\SmartFileSystem\SmartFileInfo; final class StaticCallToFuncCallRectorTest extends AbstractRectorTestCase @@ -26,17 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - StaticCallToFuncCallRector::class => [ - StaticCallToFuncCallRector::STATIC_CALLS_TO_FUNCTIONS => [ - new StaticCallToFuncCall(SomeOldStaticClass::class, 'render', 'view'), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/StaticCall/StaticCallToFuncCallRector/config/configured_rule.php b/rules/transform/tests/Rector/StaticCall/StaticCallToFuncCallRector/config/configured_rule.php new file mode 100644 index 000000000000..499a076b38db --- /dev/null +++ b/rules/transform/tests/Rector/StaticCall/StaticCallToFuncCallRector/config/configured_rule.php @@ -0,0 +1,59 @@ +services(); + $services->set(\Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector::class)->call('configure', [[ + \Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector::STATIC_CALLS_TO_FUNCTIONS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + new \Rector\Transform\ValueObject\StaticCallToFuncCall( + \Rector\Transform\Tests\Rector\StaticCall\StaticCallToFuncCallRector\Source\SomeOldStaticClass::class, + 'render', + 'view' + ), + + + + + + + + + + + + + + + + + + + + + + + + + + ]), + ]]); +}; diff --git a/rules/transform/tests/Rector/StaticCall/StaticCallToMethodCallRector/InvalidConfigurationTest.php b/rules/transform/tests/Rector/StaticCall/StaticCallToMethodCallRector/InvalidConfigurationTest.php deleted file mode 100644 index 821635688840..000000000000 --- a/rules/transform/tests/Rector/StaticCall/StaticCallToMethodCallRector/InvalidConfigurationTest.php +++ /dev/null @@ -1,47 +0,0 @@ -expectException(InvalidArgumentException::class); - $this->doTestFileInfo($fileInfo); - } - - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array - { - return [ - StaticCallToMethodCallRector::class => [ - StaticCallToMethodCallRector::STATIC_CALLS_TO_METHOD_CALLS => self::CONFIGURATION, - ], - ]; - } -} diff --git a/rules/transform/tests/Rector/StaticCall/StaticCallToMethodCallRector/StaticCallToMethodCallRectorTest.php b/rules/transform/tests/Rector/StaticCall/StaticCallToMethodCallRector/StaticCallToMethodCallRectorTest.php index 8aade52926fa..a0be6746fa80 100644 --- a/rules/transform/tests/Rector/StaticCall/StaticCallToMethodCallRector/StaticCallToMethodCallRectorTest.php +++ b/rules/transform/tests/Rector/StaticCall/StaticCallToMethodCallRector/StaticCallToMethodCallRectorTest.php @@ -6,8 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\StaticCall\StaticCallToMethodCallRector; -use Rector\Transform\ValueObject\StaticCallToMethodCall; use Symplify\SmartFileSystem\SmartFileInfo; final class StaticCallToMethodCallRectorTest extends AbstractRectorTestCase @@ -25,28 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - StaticCallToMethodCallRector::class => [ - StaticCallToMethodCallRector::STATIC_CALLS_TO_METHOD_CALLS => [ - new StaticCallToMethodCall( - 'Nette\Utils\FileSystem', - 'write', - 'Symplify\SmartFileSystem\SmartFileSystem', - 'dumpFile' - ), - new StaticCallToMethodCall( - 'Illuminate\Support\Facades\Response', - '*', - 'Illuminate\Contracts\Routing\ResponseFactory', - '*' - ), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/StaticCall/StaticCallToMethodCallRector/config/configured_rule.php b/rules/transform/tests/Rector/StaticCall/StaticCallToMethodCallRector/config/configured_rule.php new file mode 100644 index 000000000000..edeee3fe20be --- /dev/null +++ b/rules/transform/tests/Rector/StaticCall/StaticCallToMethodCallRector/config/configured_rule.php @@ -0,0 +1,30 @@ +services(); + + $services->set(StaticCallToMethodCallRector::class) + ->call('configure', [[ + StaticCallToMethodCallRector::STATIC_CALLS_TO_METHOD_CALLS => ValueObjectInliner::inline([ + new StaticCallToMethodCall( + 'Nette\Utils\FileSystem', + 'write', + 'Symplify\SmartFileSystem\SmartFileSystem', + 'dumpFile' + ), + new StaticCallToMethodCall( + 'Illuminate\Support\Facades\Response', + '*', + 'Illuminate\Contracts\Routing\ResponseFactory', + '*' + ), + ]), + ]]); +}; diff --git a/rules/transform/tests/Rector/StaticCall/StaticCallToNewRector/StaticCallToNewRectorTest.php b/rules/transform/tests/Rector/StaticCall/StaticCallToNewRector/StaticCallToNewRectorTest.php index 15eae2ba5815..48fe4984480f 100644 --- a/rules/transform/tests/Rector/StaticCall/StaticCallToNewRector/StaticCallToNewRectorTest.php +++ b/rules/transform/tests/Rector/StaticCall/StaticCallToNewRector/StaticCallToNewRectorTest.php @@ -6,9 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\StaticCall\StaticCallToNewRector; -use Rector\Transform\Tests\Rector\StaticCall\StaticCallToNewRector\Source\SomeJsonResponse; -use Rector\Transform\ValueObject\StaticCallToNew; use Symplify\SmartFileSystem\SmartFileInfo; final class StaticCallToNewRectorTest extends AbstractRectorTestCase @@ -26,18 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return mixed[] - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - StaticCallToNewRector::class => - [ - StaticCallToNewRector::STATIC_CALLS_TO_NEWS => [ - new StaticCallToNew(SomeJsonResponse::class, 'create'), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/StaticCall/StaticCallToNewRector/config/configured_rule.php b/rules/transform/tests/Rector/StaticCall/StaticCallToNewRector/config/configured_rule.php new file mode 100644 index 000000000000..d90fa8ffbe86 --- /dev/null +++ b/rules/transform/tests/Rector/StaticCall/StaticCallToNewRector/config/configured_rule.php @@ -0,0 +1,58 @@ +services(); + $services->set(\Rector\Transform\Rector\StaticCall\StaticCallToNewRector::class)->call('configure', [[ + \Rector\Transform\Rector\StaticCall\StaticCallToNewRector::STATIC_CALLS_TO_NEWS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + new \Rector\Transform\ValueObject\StaticCallToNew( + \Rector\Transform\Tests\Rector\StaticCall\StaticCallToNewRector\Source\SomeJsonResponse::class, + 'create' + ), + + + + + + + + + + + + + + + + + + + + + + + + + + ]), + ]]); +}; diff --git a/rules/transform/tests/Rector/String_/StringToClassConstantRector/StringToClassConstantRectorTest.php b/rules/transform/tests/Rector/String_/StringToClassConstantRector/StringToClassConstantRectorTest.php index be54c23f537c..f625d835d3af 100644 --- a/rules/transform/tests/Rector/String_/StringToClassConstantRector/StringToClassConstantRectorTest.php +++ b/rules/transform/tests/Rector/String_/StringToClassConstantRector/StringToClassConstantRectorTest.php @@ -6,8 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\String_\StringToClassConstantRector; -use Rector\Transform\ValueObject\StringToClassConstant; use Symplify\SmartFileSystem\SmartFileInfo; final class StringToClassConstantRectorTest extends AbstractRectorTestCase @@ -25,18 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - StringToClassConstantRector::class => [ - StringToClassConstantRector::STRINGS_TO_CLASS_CONSTANTS => [ - new StringToClassConstant('compiler.post_dump', 'Yet\AnotherClass', 'CONSTANT'), - new StringToClassConstant('compiler.to_class', 'Yet\AnotherClass', 'class'), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/String_/StringToClassConstantRector/config/configured_rule.php b/rules/transform/tests/Rector/String_/StringToClassConstantRector/config/configured_rule.php new file mode 100644 index 000000000000..1ae7b5ece1c9 --- /dev/null +++ b/rules/transform/tests/Rector/String_/StringToClassConstantRector/config/configured_rule.php @@ -0,0 +1,60 @@ +services(); + $services->set(\Rector\Transform\Rector\String_\StringToClassConstantRector::class)->call('configure', [[ + \Rector\Transform\Rector\String_\StringToClassConstantRector::STRINGS_TO_CLASS_CONSTANTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + new \Rector\Transform\ValueObject\StringToClassConstant( + 'compiler.post_dump', + 'Yet\AnotherClass', + 'CONSTANT' + ), + new \Rector\Transform\ValueObject\StringToClassConstant('compiler.to_class', 'Yet\AnotherClass', 'class'), + + + + + + + + + + + + + + + + + + + + + + + + + + ]), + ]]); +}; diff --git a/rules/transform/tests/Rector/String_/ToStringToMethodCallRector/ToStringToMethodCallRectorTest.php b/rules/transform/tests/Rector/String_/ToStringToMethodCallRector/ToStringToMethodCallRectorTest.php index 7fb18696e127..ccd186c54d38 100644 --- a/rules/transform/tests/Rector/String_/ToStringToMethodCallRector/ToStringToMethodCallRectorTest.php +++ b/rules/transform/tests/Rector/String_/ToStringToMethodCallRector/ToStringToMethodCallRectorTest.php @@ -6,8 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Transform\Rector\String_\ToStringToMethodCallRector; -use Symfony\Component\Config\ConfigCache; use Symplify\SmartFileSystem\SmartFileInfo; final class ToStringToMethodCallRectorTest extends AbstractRectorTestCase @@ -25,17 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - ToStringToMethodCallRector::class => [ - ToStringToMethodCallRector::METHOD_NAMES_BY_TYPE => [ - ConfigCache::class => 'getPath', - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/transform/tests/Rector/String_/ToStringToMethodCallRector/config/configured_rule.php b/rules/transform/tests/Rector/String_/ToStringToMethodCallRector/config/configured_rule.php new file mode 100644 index 000000000000..ef81924a561b --- /dev/null +++ b/rules/transform/tests/Rector/String_/ToStringToMethodCallRector/config/configured_rule.php @@ -0,0 +1,12 @@ +services(); + $services->set(\Rector\Transform\Rector\String_\ToStringToMethodCallRector::class)->call('configure', [[ + \Rector\Transform\Rector\String_\ToStringToMethodCallRector::METHOD_NAMES_BY_TYPE => [ + \Symfony\Component\Config\ConfigCache::class => 'getPath', + ], + ]]); +}; diff --git a/rules/type-declaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/AddParamTypeDeclarationRectorTest.php b/rules/type-declaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/AddParamTypeDeclarationRectorTest.php index 11b425f3752a..a5e251845c96 100644 --- a/rules/type-declaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/AddParamTypeDeclarationRectorTest.php +++ b/rules/type-declaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/AddParamTypeDeclarationRectorTest.php @@ -5,14 +5,7 @@ namespace Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddParamTypeDeclarationRector; use Iterator; -use PHPStan\Type\ObjectType; -use PHPStan\Type\StringType; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector; -use Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddParamTypeDeclarationRector\Contract\ParentInterfaceWithChangeTypeInterface; -use Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddParamTypeDeclarationRector\Source\ClassMetadataFactory; -use Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddParamTypeDeclarationRector\Source\ParserInterface; -use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration; use Symplify\SmartFileSystem\SmartFileInfo; final class AddParamTypeDeclarationRectorTest extends AbstractRectorTestCase @@ -30,29 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - AddParamTypeDeclarationRector::class => [ - AddParamTypeDeclarationRector::PARAMETER_TYPEHINTS => [ - new AddParamTypeDeclaration( - ParentInterfaceWithChangeTypeInterface::class, - 'process', - 0, - new StringType() - ), - new AddParamTypeDeclaration(ParserInterface::class, 'parse', 0, new StringType()), - new AddParamTypeDeclaration( - ClassMetadataFactory::class, - 'setEntityManager', - 0, - new ObjectType('Doctrine\ORM\EntityManagerInterface') - ), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/type-declaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/config/configured_rule.php b/rules/type-declaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/config/configured_rule.php new file mode 100644 index 000000000000..dcf908f9ec96 --- /dev/null +++ b/rules/type-declaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/config/configured_rule.php @@ -0,0 +1,82 @@ +services(); + $services->set(\Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector::class)->call( + 'configure', + [[ + \Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector::PARAMETER_TYPEHINTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + + + + + + + + + + + + + + + + + + + + + + + + + new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration( + \Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddParamTypeDeclarationRector\Contract\ParentInterfaceWithChangeTypeInterface::class, + 'process', + 0, + new \PHPStan\Type\StringType() + ), + new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration( + \Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddParamTypeDeclarationRector\Source\ParserInterface::class, + 'parse', + 0, + new \PHPStan\Type\StringType() + ), + new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration( + \Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddParamTypeDeclarationRector\Source\ClassMetadataFactory::class, + 'setEntityManager', + 0, + new \PHPStan\Type\ObjectType('Doctrine\ORM\EntityManagerInterface') + ), + + + + + + + + + + + + + + + + + + + + + + + + + + ]), + ]] + ); +}; diff --git a/rules/type-declaration/tests/Rector/ClassMethod/AddReturnTypeDeclarationRector/AddReturnTypeDeclarationRectorTest.php b/rules/type-declaration/tests/Rector/ClassMethod/AddReturnTypeDeclarationRector/AddReturnTypeDeclarationRectorTest.php index b039d9a9908f..f3bc3aea87a1 100644 --- a/rules/type-declaration/tests/Rector/ClassMethod/AddReturnTypeDeclarationRector/AddReturnTypeDeclarationRectorTest.php +++ b/rules/type-declaration/tests/Rector/ClassMethod/AddReturnTypeDeclarationRector/AddReturnTypeDeclarationRectorTest.php @@ -5,16 +5,7 @@ namespace Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddReturnTypeDeclarationRector; use Iterator; -use PHPStan\Type\ArrayType; -use PHPStan\Type\MixedType; -use PHPStan\Type\NullType; -use PHPStan\Type\ObjectType; -use PHPStan\Type\UnionType; -use PHPStan\Type\VoidType; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector; -use Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddReturnTypeDeclarationRector\Source\PHPUnitTestCase; -use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration; use Symplify\SmartFileSystem\SmartFileInfo; final class AddReturnTypeDeclarationRectorTest extends AbstractRectorTestCase @@ -32,41 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - $arrayType = new ArrayType(new MixedType(), new MixedType()); - - $nullableObjectUnionType = new UnionType([new ObjectType('SomeType'), new NullType()]); - - return [ - AddReturnTypeDeclarationRector::class => [ - AddReturnTypeDeclarationRector::METHOD_RETURN_TYPES => [ - new AddReturnTypeDeclaration( - 'Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddReturnTypeDeclarationRector\Fixture\Fixture', - 'parse', - $arrayType - ), - new AddReturnTypeDeclaration( - 'Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddReturnTypeDeclarationRector\Fixture\Fixture', - 'resolve', - new ObjectType('SomeType') - ), - new AddReturnTypeDeclaration( - 'Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddReturnTypeDeclarationRector\Fixture\Fixture', - 'nullable', - $nullableObjectUnionType - ), - new AddReturnTypeDeclaration( - 'Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddReturnTypeDeclarationRector\Fixture\RemoveReturnType', - 'clear', - new MixedType() - ), - new AddReturnTypeDeclaration(PHPUnitTestCase::class, 'tearDown', new VoidType()), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/type-declaration/tests/Rector/ClassMethod/AddReturnTypeDeclarationRector/config/configured_rule.php b/rules/type-declaration/tests/Rector/ClassMethod/AddReturnTypeDeclarationRector/config/configured_rule.php new file mode 100644 index 000000000000..0cc7e343d65f --- /dev/null +++ b/rules/type-declaration/tests/Rector/ClassMethod/AddReturnTypeDeclarationRector/config/configured_rule.php @@ -0,0 +1,49 @@ +services(); + + $services->set(AddReturnTypeDeclarationRector::class) + ->call('configure', [[ + AddReturnTypeDeclarationRector::METHOD_RETURN_TYPES => ValueObjectInliner::inline([ + new AddReturnTypeDeclaration( + 'Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddReturnTypeDeclarationRector\Fixture\Fixture', + 'parse', + $arrayType + ), + new AddReturnTypeDeclaration( + 'Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddReturnTypeDeclarationRector\Fixture\Fixture', + 'resolve', + new ObjectType('SomeType') + ), + new AddReturnTypeDeclaration( + 'Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddReturnTypeDeclarationRector\Fixture\Fixture', + 'nullable', + $nullableObjectUnionType + ), + new AddReturnTypeDeclaration( + 'Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddReturnTypeDeclarationRector\Fixture\RemoveReturnType', + 'clear', + new MixedType() + ), + new AddReturnTypeDeclaration(PHPUnitTestCase::class, 'tearDown', new VoidType()), + ]), + ]]); +}; diff --git a/rules/visibility/src/Rector/ClassConst/ChangeConstantVisibilityRector.php b/rules/visibility/src/Rector/ClassConst/ChangeConstantVisibilityRector.php index 245e78d51879..26e7e2b25bc9 100644 --- a/rules/visibility/src/Rector/ClassConst/ChangeConstantVisibilityRector.php +++ b/rules/visibility/src/Rector/ClassConst/ChangeConstantVisibilityRector.php @@ -9,7 +9,7 @@ use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\Visibility; -use Rector\Visibility\ValueObject\ClassConstantVisibilityChange; +use Rector\Visibility\ValueObject\ChangeConstantVisibility; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use Webmozart\Assert\Assert; @@ -25,7 +25,7 @@ final class ChangeConstantVisibilityRector extends AbstractRector implements Con public const CLASS_CONSTANT_VISIBILITY_CHANGES = 'class_constant_visibility_changes'; /** - * @var ClassConstantVisibilityChange[] + * @var ChangeConstantVisibility[] */ private $classConstantVisibilityChanges = []; @@ -61,7 +61,7 @@ class MyClass extends FrameworkClass , [ self::CLASS_CONSTANT_VISIBILITY_CHANGES => [ - new ClassConstantVisibilityChange( + new ChangeConstantVisibility( 'ParentObject', 'SOME_CONSTANT', Visibility::PROTECTED @@ -106,7 +106,7 @@ public function refactor(Node $node): ?Node public function configure(array $configuration): void { $classConstantVisibilityChanges = $configuration[self::CLASS_CONSTANT_VISIBILITY_CHANGES] ?? []; - Assert::allIsInstanceOf($classConstantVisibilityChanges, ClassConstantVisibilityChange::class); + Assert::allIsInstanceOf($classConstantVisibilityChanges, ChangeConstantVisibility::class); $this->classConstantVisibilityChanges = $classConstantVisibilityChanges; } } diff --git a/rules/visibility/src/ValueObject/ClassConstantVisibilityChange.php b/rules/visibility/src/ValueObject/ChangeConstantVisibility.php similarity index 94% rename from rules/visibility/src/ValueObject/ClassConstantVisibilityChange.php rename to rules/visibility/src/ValueObject/ChangeConstantVisibility.php index 74623d73d0cf..0f73ce6b5763 100644 --- a/rules/visibility/src/ValueObject/ClassConstantVisibilityChange.php +++ b/rules/visibility/src/ValueObject/ChangeConstantVisibility.php @@ -4,7 +4,7 @@ namespace Rector\Visibility\ValueObject; -final class ClassConstantVisibilityChange +final class ChangeConstantVisibility { /** * @var string diff --git a/rules/visibility/tests/Rector/ClassConst/ChangeConstantVisibilityRector/ChangeConstantVisibilityRectorTest.php b/rules/visibility/tests/Rector/ClassConst/ChangeConstantVisibilityRector/ChangeConstantVisibilityRectorTest.php index bf403510a1fe..8f1e2277e9c7 100644 --- a/rules/visibility/tests/Rector/ClassConst/ChangeConstantVisibilityRector/ChangeConstantVisibilityRectorTest.php +++ b/rules/visibility/tests/Rector/ClassConst/ChangeConstantVisibilityRector/ChangeConstantVisibilityRectorTest.php @@ -5,11 +5,7 @@ namespace Rector\Visibility\Tests\Rector\ClassConst\ChangeConstantVisibilityRector; use Iterator; -use Rector\Core\ValueObject\Visibility; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Visibility\Rector\ClassConst\ChangeConstantVisibilityRector; -use Rector\Visibility\Tests\Rector\ClassConst\ChangeConstantVisibilityRector\Source\ParentObject; -use Rector\Visibility\ValueObject\ClassConstantVisibilityChange; use Symplify\SmartFileSystem\SmartFileInfo; final class ChangeConstantVisibilityRectorTest extends AbstractRectorTestCase @@ -27,32 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - ChangeConstantVisibilityRector::class => [ - ChangeConstantVisibilityRector::CLASS_CONSTANT_VISIBILITY_CHANGES => [ - new ClassConstantVisibilityChange(ParentObject::class, 'TO_BE_PUBLIC_CONSTANT', Visibility::PUBLIC), - new ClassConstantVisibilityChange( - ParentObject::class, - 'TO_BE_PROTECTED_CONSTANT', - Visibility::PROTECTED - ), - new ClassConstantVisibilityChange( - ParentObject::class, - 'TO_BE_PRIVATE_CONSTANT', - Visibility::PRIVATE - ), - new ClassConstantVisibilityChange( - 'Rector\Visibility\Tests\Rector\ClassConst\ChangeConstantVisibilityRector\Fixture\Fixture2', - 'TO_BE_PRIVATE_CONSTANT', - Visibility::PRIVATE - ), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/visibility/tests/Rector/ClassConst/ChangeConstantVisibilityRector/config/configured_rule.php b/rules/visibility/tests/Rector/ClassConst/ChangeConstantVisibilityRector/config/configured_rule.php new file mode 100644 index 000000000000..e2dbb93a7424 --- /dev/null +++ b/rules/visibility/tests/Rector/ClassConst/ChangeConstantVisibilityRector/config/configured_rule.php @@ -0,0 +1,30 @@ +services(); + + $services->set(ChangeConstantVisibilityRector::class) + ->call('configure', [[ + ChangeConstantVisibilityRector::CLASS_CONSTANT_VISIBILITY_CHANGES => ValueObjectInliner::inline([ + new ChangeConstantVisibility(ParentObject::class, 'TO_BE_PUBLIC_CONSTANT', Visibility::PUBLIC), + new ChangeConstantVisibility( + ParentObject::class, + 'TO_BE_PROTECTED_CONSTANT', + Visibility::PROTECTED + ), + new ChangeConstantVisibility(ParentObject::class, 'TO_BE_PRIVATE_CONSTANT', Visibility::PRIVATE), + new ChangeConstantVisibility( + 'Rector\Visibility\Tests\Rector\ClassConst\ChangeConstantVisibilityRector\Fixture\Fixture2', + 'TO_BE_PRIVATE_CONSTANT', + Visibility::PRIVATE + ), + ]), + ]]); +}; diff --git a/rules/visibility/tests/Rector/ClassMethod/ChangeMethodVisibilityRector/ChangeMethodVisibilityRectorTest.php b/rules/visibility/tests/Rector/ClassMethod/ChangeMethodVisibilityRector/ChangeMethodVisibilityRectorTest.php index 065cef7b0589..5ca4272f6d22 100644 --- a/rules/visibility/tests/Rector/ClassMethod/ChangeMethodVisibilityRector/ChangeMethodVisibilityRectorTest.php +++ b/rules/visibility/tests/Rector/ClassMethod/ChangeMethodVisibilityRector/ChangeMethodVisibilityRectorTest.php @@ -5,11 +5,7 @@ namespace Rector\Visibility\Tests\Rector\ClassMethod\ChangeMethodVisibilityRector; use Iterator; -use Rector\Core\ValueObject\Visibility; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector; -use Rector\Visibility\Tests\Rector\ClassMethod\ChangeMethodVisibilityRector\Source\ParentObject; -use Rector\Visibility\ValueObject\ChangeMethodVisibility; use Symplify\SmartFileSystem\SmartFileInfo; final class ChangeMethodVisibilityRectorTest extends AbstractRectorTestCase @@ -27,20 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - ChangeMethodVisibilityRector::class => [ - ChangeMethodVisibilityRector::METHOD_VISIBILITIES => [ - new ChangeMethodVisibility(ParentObject::class, 'toBePublicMethod', Visibility::PUBLIC), - new ChangeMethodVisibility(ParentObject::class, 'toBeProtectedMethod', Visibility::PROTECTED), - new ChangeMethodVisibility(ParentObject::class, 'toBePrivateMethod', Visibility::PRIVATE), - new ChangeMethodVisibility(ParentObject::class, 'toBePublicStaticMethod', Visibility::PUBLIC), - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/visibility/tests/Rector/ClassMethod/ChangeMethodVisibilityRector/config/configured_rule.php b/rules/visibility/tests/Rector/ClassMethod/ChangeMethodVisibilityRector/config/configured_rule.php new file mode 100644 index 000000000000..a17bbb466b2c --- /dev/null +++ b/rules/visibility/tests/Rector/ClassMethod/ChangeMethodVisibilityRector/config/configured_rule.php @@ -0,0 +1,42 @@ +services(); + $services->set(ChangeMethodVisibilityRector::class)->call('configure', [[ + ChangeMethodVisibilityRector::METHOD_VISIBILITIES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + + new \Rector\Visibility\ValueObject\ChangeMethodVisibility( + \Rector\Visibility\Tests\Rector\ClassMethod\ChangeMethodVisibilityRector\Source\ParentObject::class, + 'toBePublicMethod', + \Rector\Core\ValueObject\Visibility::PUBLIC + ), + new \Rector\Visibility\ValueObject\ChangeMethodVisibility( + \Rector\Visibility\Tests\Rector\ClassMethod\ChangeMethodVisibilityRector\Source\ParentObject::class, + 'toBeProtectedMethod', + \Rector\Core\ValueObject\Visibility::PROTECTED + ), + new \Rector\Visibility\ValueObject\ChangeMethodVisibility( + \Rector\Visibility\Tests\Rector\ClassMethod\ChangeMethodVisibilityRector\Source\ParentObject::class, + 'toBePrivateMethod', + \Rector\Core\ValueObject\Visibility::PRIVATE + ), + new \Rector\Visibility\ValueObject\ChangeMethodVisibility( + \Rector\Visibility\Tests\Rector\ClassMethod\ChangeMethodVisibilityRector\Source\ParentObject::class, + 'toBePublicStaticMethod', + \Rector\Core\ValueObject\Visibility::PUBLIC + ), + + + + + + + + + ]), + ]]); +}; diff --git a/rules/visibility/tests/Rector/Property/ChangePropertyVisibilityRector/ChangePropertyVisibilityRectorTest.php b/rules/visibility/tests/Rector/Property/ChangePropertyVisibilityRector/ChangePropertyVisibilityRectorTest.php index 82871984f527..2e823d789d04 100644 --- a/rules/visibility/tests/Rector/Property/ChangePropertyVisibilityRector/ChangePropertyVisibilityRectorTest.php +++ b/rules/visibility/tests/Rector/Property/ChangePropertyVisibilityRector/ChangePropertyVisibilityRectorTest.php @@ -5,10 +5,7 @@ namespace Rector\Visibility\Tests\Rector\Property\ChangePropertyVisibilityRector; use Iterator; -use Rector\Core\ValueObject\Visibility; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Rector\Visibility\Rector\Property\ChangePropertyVisibilityRector; -use Rector\Visibility\Tests\Rector\Property\ChangePropertyVisibilityRector\Source\ParentObject; use Symplify\SmartFileSystem\SmartFileInfo; final class ChangePropertyVisibilityRectorTest extends AbstractRectorTestCase @@ -26,25 +23,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - ChangePropertyVisibilityRector::class => [ - ChangePropertyVisibilityRector::PROPERTY_TO_VISIBILITY_BY_CLASS => [ - ParentObject::class => [ - 'toBePublicProperty' => Visibility::PUBLIC, - 'toBeProtectedProperty' => Visibility::PROTECTED, - 'toBePrivateProperty' => Visibility::PRIVATE, - 'toBePublicStaticProperty' => Visibility::PUBLIC, - ], - 'Rector\Visibility\Tests\Rector\Property\ChangePropertyVisibilityRector\Fixture\Fixture3' => [ - 'toBePublicStaticProperty' => Visibility::PUBLIC, - ], - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/rules/visibility/tests/Rector/Property/ChangePropertyVisibilityRector/config/configured_rule.php b/rules/visibility/tests/Rector/Property/ChangePropertyVisibilityRector/config/configured_rule.php new file mode 100644 index 000000000000..5f7385ccb41b --- /dev/null +++ b/rules/visibility/tests/Rector/Property/ChangePropertyVisibilityRector/config/configured_rule.php @@ -0,0 +1,20 @@ +services(); + $services->set(\Rector\Visibility\Rector\Property\ChangePropertyVisibilityRector::class)->call('configure', [[ + \Rector\Visibility\Rector\Property\ChangePropertyVisibilityRector::PROPERTY_TO_VISIBILITY_BY_CLASS => [ + \Rector\Visibility\Tests\Rector\Property\ChangePropertyVisibilityRector\Source\ParentObject::class => [ + 'toBePublicProperty' => \Rector\Core\ValueObject\Visibility::PUBLIC, + 'toBeProtectedProperty' => \Rector\Core\ValueObject\Visibility::PROTECTED, + 'toBePrivateProperty' => \Rector\Core\ValueObject\Visibility::PRIVATE, + 'toBePublicStaticProperty' => \Rector\Core\ValueObject\Visibility::PUBLIC, + ], + 'Rector\Visibility\Tests\Rector\Property\ChangePropertyVisibilityRector\Fixture\Fixture3' => [ + 'toBePublicStaticProperty' => \Rector\Core\ValueObject\Visibility::PUBLIC, + ], + ], + ]]); +}; From 681c5206a4e16fd0448219bf52f8d2f1961178a9 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 9 Feb 2021 06:25:55 +0100 Subject: [PATCH 05/12] Delete Abc\FqnizeNamespaced, --- "Abc\\FqnizeNamespaced," | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 "Abc\\FqnizeNamespaced," diff --git "a/Abc\\FqnizeNamespaced," "b/Abc\\FqnizeNamespaced," deleted file mode 100644 index 4089590f3d48..000000000000 --- "a/Abc\\FqnizeNamespaced," +++ /dev/null @@ -1,3 +0,0 @@ -PHPUnit 9.5.2 by Sebastian Bergmann and contributors. - -Cannot open file "FqnizeNamespaced". From 11bb74b455cd9e022f29f9502ae657d051dd71d8 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 9 Feb 2021 06:26:29 +0100 Subject: [PATCH 06/12] Delete MyNamespace\MyNewClass, --- "MyNamespace\\MyNewClass," | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 "MyNamespace\\MyNewClass," diff --git "a/MyNamespace\\MyNewClass," "b/MyNamespace\\MyNewClass," deleted file mode 100644 index e69de29bb2d1..000000000000 From ec477834c629ba1d4a109e67e5ac2b563c1dfd4b Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 9 Feb 2021 06:27:09 +0100 Subject: [PATCH 07/12] Delete MyNewNamespace\MyNewClass, --- "MyNewNamespace\\MyNewClass," | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 "MyNewNamespace\\MyNewClass," diff --git "a/MyNewNamespace\\MyNewClass," "b/MyNewNamespace\\MyNewClass," deleted file mode 100644 index e69de29bb2d1..000000000000 From b1ba25849ef34d37198e6756f0f39c29b16f789c Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 9 Feb 2021 06:27:10 +0100 Subject: [PATCH 08/12] Delete MyNewNamespace\MyNewInterface, --- "MyNewNamespace\\MyNewInterface," | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 "MyNewNamespace\\MyNewInterface," diff --git "a/MyNewNamespace\\MyNewInterface," "b/MyNewNamespace\\MyNewInterface," deleted file mode 100644 index e69de29bb2d1..000000000000 From 3c512ff40e170f41c36875202fe4a6ad6e58e037 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 9 Feb 2021 06:27:11 +0100 Subject: [PATCH 09/12] Delete MyNewNamespace\MyNewTrait, --- "MyNewNamespace\\MyNewTrait," | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 "MyNewNamespace\\MyNewTrait," diff --git "a/MyNewNamespace\\MyNewTrait," "b/MyNewNamespace\\MyNewTrait," deleted file mode 100644 index e69de29bb2d1..000000000000 From b875b1d6dd6d26b71ceaefb24fe0f8e41a81ada7 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 9 Feb 2021 06:27:12 +0100 Subject: [PATCH 10/12] Delete Twig\Extension\SandboxExtension, --- "Twig\\Extension\\SandboxExtension," | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 "Twig\\Extension\\SandboxExtension," diff --git "a/Twig\\Extension\\SandboxExtension," "b/Twig\\Extension\\SandboxExtension," deleted file mode 100644 index e69de29bb2d1..000000000000 From f3c48dc942f297969efa4c00b24e8c80ae712e02 Mon Sep 17 00:00:00 2001 From: kaizen-ci Date: Tue, 9 Feb 2021 05:27:21 +0000 Subject: [PATCH 11/12] [ci-review] Rector Rectify --- packages/testing/src/PHPUnit/AbstractRectorTestCase.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/testing/src/PHPUnit/AbstractRectorTestCase.php b/packages/testing/src/PHPUnit/AbstractRectorTestCase.php index e617c8c6fbc0..c991e4a97689 100644 --- a/packages/testing/src/PHPUnit/AbstractRectorTestCase.php +++ b/packages/testing/src/PHPUnit/AbstractRectorTestCase.php @@ -195,6 +195,9 @@ protected function provideConfigFileInfo(): ?SmartFileInfo return null; } + /** + * @return array + */ protected function getCurrentTestRectorClassesWithConfiguration(): array { $rectorClass = $this->getRectorClass(); From 26d78e8bdf59a6cf4ff4355371d40b2b3df5f12a Mon Sep 17 00:00:00 2001 From: kaizen-ci Date: Tue, 9 Feb 2021 05:31:20 +0000 Subject: [PATCH 12/12] [ci-review] Rector Rectify --- .../config/configured_rule.php | 11 +-- .../config/configured_rule.php | 32 ++++---- .../config/configured_rule.php | 5 +- .../config/configured_rule.php | 41 ++++------ .../config/configured_rule.php | 30 +++----- .../config/configured_rule.php | 61 ++++----------- .../config/configured_rule.php | 16 ++-- .../config/configured_rule.php | 11 +-- .../config/configured_rule.php | 20 +++-- .../config/configured_rule.php | 15 ++-- .../config/configured_rule.php | 15 ++-- .../config/configured_rule.php | 14 ++-- .../config/configured_rule.php | 11 +-- .../config/configured_rule.php | 14 ++-- .../config/configured_rule.php | 49 ++++++------ .../config/configured_rule.php | 74 ++++--------------- .../config/configured_rule.php | 20 +++-- .../config/configured_rule.php | 24 +++--- .../config/configured_rule.php | 24 +++--- .../config/configured_rule.php | 15 ++-- .../config/configured_rule.php | 22 +++--- .../config/configured_rule.php | 15 ++-- .../config/configured_rule.php | 17 +++-- .../config/configured_rule.php | 15 ++-- .../RectorOrder/config/configured_rule.php | 15 ++-- .../config/configured_rule.php | 11 +-- .../config/configured_rule.php | 12 +-- .../config/configured_rule.php | 24 +++--- .../config/configured_rule.php | 11 +-- .../config/configured_rule.php | 11 +-- .../config/configured_rule.php | 11 +-- .../config/class_types_only.php | 11 +-- .../config/configured_rule.php | 11 +-- .../config/configured_rule.php | 14 ++-- .../config/configured_rule.php | 17 +++-- .../config/configured_rule.php | 28 ++++--- .../config/configured_rule.php | 14 ++-- .../config/configured_rule.php | 14 ++-- .../config/configured_rule.php | 14 ++-- .../config/configured_rule.php | 19 +++-- .../config/configured_rule.php | 19 +++-- .../config/configured_rule.php | 42 +++++------ .../config/configured_rule.php | 23 +++--- .../config/configured_rule.php | 11 +-- .../config/configured_rule.php | 23 +++--- .../config/configured_rule.php | 11 +-- .../config/configured_rule.php | 35 ++++----- .../config/auto_import_names.php | 4 +- .../config/configured_rule.php | 3 +- .../config/non_php_config.php | 3 +- .../config/configured_rule.php | 11 +-- .../config/configured_rule.php | 28 +++---- .../config/configured_rule.php | 30 ++++---- .../config/configured_rule.php | 11 +-- ...mpleteImportForPartialAnnotationRector.php | 16 ++-- .../config/configured_rule.php | 14 ++-- .../config/configured_rule.php | 15 ++-- .../UnsetAndIssetToMethodCallRector.php | 16 ++-- .../config/configured_rule.php | 19 +++-- .../config/configured_rule.php | 17 +++-- .../config/configured_rule.php | 22 +++--- .../config/configured_rule.php | 22 +++--- .../config/configured_rule.php | 29 ++++---- .../config/configured_rule.php | 23 +++--- .../config/configured_rule.php | 11 +-- .../config/configured_rule.php | 25 +++---- .../config/configured_rule.php | 12 +-- .../config/configured_rule.php | 22 +++--- .../config/configured_rule.php | 19 +++-- .../config/configured_rule.php | 11 +-- .../config/configured_rule.php | 22 +++--- .../config/configured_rule.php | 22 +++--- .../config/configured_rule.php | 25 ++++--- .../config/configured_rule.php | 17 +++-- .../config/configured_rule.php | 14 ++-- .../config/configured_rule.php | 25 ++++--- .../config/configured_rule.php | 25 ++++--- .../config/configured_rule.php | 24 +++--- .../config/configured_rule.php | 23 +++--- .../config/configured_rule.php | 21 +++--- .../config/configured_rule.php | 14 ++-- .../config/configured_rule.php | 41 +++++----- .../config/configured_rule.php | 37 +++------- .../config/configured_rule.php | 25 ++++--- 84 files changed, 845 insertions(+), 845 deletions(-) diff --git a/rules/autodiscovery/tests/Rector/FileNode/MoveServicesBySuffixToDirectoryRector/config/configured_rule.php b/rules/autodiscovery/tests/Rector/FileNode/MoveServicesBySuffixToDirectoryRector/config/configured_rule.php index d47f835e5c8d..351809fa1d08 100644 --- a/rules/autodiscovery/tests/Rector/FileNode/MoveServicesBySuffixToDirectoryRector/config/configured_rule.php +++ b/rules/autodiscovery/tests/Rector/FileNode/MoveServicesBySuffixToDirectoryRector/config/configured_rule.php @@ -1,13 +1,14 @@ services(); - $services->set(\Rector\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector::class)->call( + $services->set(MoveServicesBySuffixToDirectoryRector::class)->call( 'configure', [[ - \Rector\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector::GROUP_NAMES_BY_SUFFIX => [ + MoveServicesBySuffixToDirectoryRector::GROUP_NAMES_BY_SUFFIX => [ 'Repository', 'Command', 'Mapper', diff --git a/rules/autodiscovery/tests/Rector/FileNode/MoveValueObjectsToValueObjectDirectoryRector/config/configured_rule.php b/rules/autodiscovery/tests/Rector/FileNode/MoveValueObjectsToValueObjectDirectoryRector/config/configured_rule.php index 98043c21f9bd..853f8ab643b1 100644 --- a/rules/autodiscovery/tests/Rector/FileNode/MoveValueObjectsToValueObjectDirectoryRector/config/configured_rule.php +++ b/rules/autodiscovery/tests/Rector/FileNode/MoveValueObjectsToValueObjectDirectoryRector/config/configured_rule.php @@ -1,37 +1,33 @@ services(); - $services->set(\Rector\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector::class)->call( + $services->set(MoveValueObjectsToValueObjectDirectoryRector::class)->call( 'configure', [[ - \Rector\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector::TYPES => [ - \Rector\Autodiscovery\Tests\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector\Source\ObviousValueObjectInterface::class, - ], + MoveValueObjectsToValueObjectDirectoryRector::TYPES => [ObviousValueObjectInterface::class], ]] ); - $services->set(\Rector\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector::class)->call( + $services->set(MoveValueObjectsToValueObjectDirectoryRector::class)->call( 'configure', [[ - \Rector\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector::TYPES => [ - \Rector\Autodiscovery\Tests\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector\Source\ObviousValueObjectInterface::class, - ], + MoveValueObjectsToValueObjectDirectoryRector::TYPES => [ObviousValueObjectInterface::class], ]] )->call('configure', [[ - \Rector\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector::SUFFIXES => ['Search'], + MoveValueObjectsToValueObjectDirectoryRector::SUFFIXES => ['Search'], ]]); - $services->set(\Rector\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector::class)->call( + $services->set(MoveValueObjectsToValueObjectDirectoryRector::class)->call( 'configure', [[ - \Rector\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector::TYPES => [ - \Rector\Autodiscovery\Tests\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector\Source\ObviousValueObjectInterface::class, - ], + MoveValueObjectsToValueObjectDirectoryRector::TYPES => [ObviousValueObjectInterface::class], ]] )->call('configure', [[ - \Rector\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector::SUFFIXES => ['Search'], + MoveValueObjectsToValueObjectDirectoryRector::SUFFIXES => ['Search'], ]])->call('configure', [[ - \Rector\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector::ENABLE_VALUE_OBJECT_GUESSING => true, + MoveValueObjectsToValueObjectDirectoryRector::ENABLE_VALUE_OBJECT_GUESSING => true, ]]); }; diff --git a/rules/cakephp/tests/Rector/MethodCall/ArrayToFluentCallRector/config/configured_rule.php b/rules/cakephp/tests/Rector/MethodCall/ArrayToFluentCallRector/config/configured_rule.php index bd27eb9925eb..acf607617d38 100644 --- a/rules/cakephp/tests/Rector/MethodCall/ArrayToFluentCallRector/config/configured_rule.php +++ b/rules/cakephp/tests/Rector/MethodCall/ArrayToFluentCallRector/config/configured_rule.php @@ -5,11 +5,10 @@ use Rector\CakePHP\Tests\Rector\MethodCall\ArrayToFluentCallRector\Source\FactoryClass; use Rector\CakePHP\ValueObject\ArrayToFluentCall; use Rector\CakePHP\ValueObject\FactoryMethod; +use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symplify\SymfonyPhpConfig\ValueObjectInliner; -return static function ( - \Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator -): void { +return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(ArrayToFluentCallRector::class) ->call('configure', [[ diff --git a/rules/cakephp/tests/Rector/MethodCall/ModalToGetSetRector/config/configured_rule.php b/rules/cakephp/tests/Rector/MethodCall/ModalToGetSetRector/config/configured_rule.php index 9002d6283e76..8dc373a51a56 100644 --- a/rules/cakephp/tests/Rector/MethodCall/ModalToGetSetRector/config/configured_rule.php +++ b/rules/cakephp/tests/Rector/MethodCall/ModalToGetSetRector/config/configured_rule.php @@ -1,41 +1,28 @@ services(); - $services->set(\Rector\CakePHP\Rector\MethodCall\ModalToGetSetRector::class)->call('configure', [[ - \Rector\CakePHP\Rector\MethodCall\ModalToGetSetRector::UNPREFIXED_METHODS_TO_GET_SET => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + $services->set(ModalToGetSetRector::class)->call('configure', [[ + ModalToGetSetRector::UNPREFIXED_METHODS_TO_GET_SET => ValueObjectInliner::inline([ - new \Rector\CakePHP\ValueObject\ModalToGetSet( - \Rector\CakePHP\Tests\Rector\MethodCall\ModalToGetSetRector\Source\SomeModelType::class, - 'config', - null, - null, - 2, - 'array' - ), - new \Rector\CakePHP\ValueObject\ModalToGetSet( - \Rector\CakePHP\Tests\Rector\MethodCall\ModalToGetSetRector\Source\SomeModelType::class, + new ModalToGetSet(SomeModelType::class, 'config', null, null, 2, 'array'), + new ModalToGetSet( + SomeModelType::class, 'customMethod', 'customMethodGetName', 'customMethodSetName', 2, 'array' ), - new \Rector\CakePHP\ValueObject\ModalToGetSet( - \Rector\CakePHP\Tests\Rector\MethodCall\ModalToGetSetRector\Source\SomeModelType::class, - 'makeEntity', - 'createEntity', - 'generateEntity' - ), - new \Rector\CakePHP\ValueObject\ModalToGetSet( - \Rector\CakePHP\Tests\Rector\MethodCall\ModalToGetSetRector\Source\SomeModelType::class, - 'method' - ), + new ModalToGetSet(SomeModelType::class, 'makeEntity', 'createEntity', 'generateEntity'), + new ModalToGetSet(SomeModelType::class, 'method'), - ]), ]]); }; diff --git a/rules/cakephp/tests/Rector/MethodCall/RenameMethodCallBasedOnParameterRector/config/configured_rule.php b/rules/cakephp/tests/Rector/MethodCall/RenameMethodCallBasedOnParameterRector/config/configured_rule.php index 6ede46a18c67..4c13a1cbe808 100644 --- a/rules/cakephp/tests/Rector/MethodCall/RenameMethodCallBasedOnParameterRector/config/configured_rule.php +++ b/rules/cakephp/tests/Rector/MethodCall/RenameMethodCallBasedOnParameterRector/config/configured_rule.php @@ -1,29 +1,21 @@ services(); - $services->set(\Rector\CakePHP\Rector\MethodCall\RenameMethodCallBasedOnParameterRector::class)->call( + $services->set(RenameMethodCallBasedOnParameterRector::class)->call( 'configure', [[ - \Rector\CakePHP\Rector\MethodCall\RenameMethodCallBasedOnParameterRector::CALLS_WITH_PARAM_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + RenameMethodCallBasedOnParameterRector::CALLS_WITH_PARAM_RENAMES => ValueObjectInliner::inline([ - new \Rector\CakePHP\ValueObject\RenameMethodCallBasedOnParameter( - \Rector\CakePHP\Tests\Rector\MethodCall\RenameMethodCallBasedOnParameterRector\Source\SomeModelType::class, - 'getParam', - 'paging', - 'getAttribute' - ), - new \Rector\CakePHP\ValueObject\RenameMethodCallBasedOnParameter( - \Rector\CakePHP\Tests\Rector\MethodCall\RenameMethodCallBasedOnParameterRector\Source\SomeModelType::class, - 'withParam', - 'paging', - 'withAttribute' - ), + new RenameMethodCallBasedOnParameter(SomeModelType::class, 'getParam', 'paging', 'getAttribute'), + new RenameMethodCallBasedOnParameter(SomeModelType::class, 'withParam', 'paging', 'withAttribute'), - ]), ]] ); diff --git a/rules/coding-style/tests/Rector/ClassMethod/ReturnArrayClassMethodToYieldRector/config/configured_rule.php b/rules/coding-style/tests/Rector/ClassMethod/ReturnArrayClassMethodToYieldRector/config/configured_rule.php index d697321031e5..72bf13e70e4c 100644 --- a/rules/coding-style/tests/Rector/ClassMethod/ReturnArrayClassMethodToYieldRector/config/configured_rule.php +++ b/rules/coding-style/tests/Rector/ClassMethod/ReturnArrayClassMethodToYieldRector/config/configured_rule.php @@ -1,56 +1,25 @@ services(); - $services->set(\Rector\CodingStyle\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector::class)->call( + $services->set(ReturnArrayClassMethodToYieldRector::class)->call( 'configure', [[ - \Rector\CodingStyle\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector::METHODS_TO_YIELDS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + ReturnArrayClassMethodToYieldRector::METHODS_TO_YIELDS => ValueObjectInliner::inline([ + new ReturnArrayClassMethodToYield(EventSubscriberInterface::class, 'getSubscribedEvents'), + new ReturnArrayClassMethodToYield(ParentTestCase::class, 'provide*'), + new ReturnArrayClassMethodToYield(ParentTestCase::class, 'dataProvider*'), + new ReturnArrayClassMethodToYield(TestCase::class, 'provideData'), - - - - - - - - - - - - - - - - - - - - - - - new \Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield( - \Rector\CodingStyle\Tests\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector\Source\EventSubscriberInterface::class, - 'getSubscribedEvents' - ), - new \Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield( - \Rector\CodingStyle\Tests\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector\Source\ParentTestCase::class, - 'provide*' - ), - new \Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield( - \Rector\CodingStyle\Tests\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector\Source\ParentTestCase::class, - 'dataProvider*' - ), - new \Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield( - \PHPUnit\Framework\TestCase::class, - 'provideData' - ), - - ]), ]] ); diff --git a/rules/coding-style/tests/Rector/ClassMethod/YieldClassMethodToArrayClassMethodRector/config/configured_rule.php b/rules/coding-style/tests/Rector/ClassMethod/YieldClassMethodToArrayClassMethodRector/config/configured_rule.php index 4b9a4f3be254..d8d1e710b6fa 100644 --- a/rules/coding-style/tests/Rector/ClassMethod/YieldClassMethodToArrayClassMethodRector/config/configured_rule.php +++ b/rules/coding-style/tests/Rector/ClassMethod/YieldClassMethodToArrayClassMethodRector/config/configured_rule.php @@ -1,16 +1,16 @@ services(); - $services->set(\Rector\CodingStyle\Rector\ClassMethod\YieldClassMethodToArrayClassMethodRector::class)->call( + $services->set(YieldClassMethodToArrayClassMethodRector::class)->call( 'configure', [[ - \Rector\CodingStyle\Rector\ClassMethod\YieldClassMethodToArrayClassMethodRector::METHODS_BY_TYPE => [ - \Rector\CodingStyle\Tests\Rector\ClassMethod\YieldClassMethodToArrayClassMethodRector\Source\EventSubscriberInterface::class => [ - 'getSubscribedEvents', - ], + YieldClassMethodToArrayClassMethodRector::METHODS_BY_TYPE => [ + EventSubscriberInterface::class => ['getSubscribedEvents'], ], ]] ); diff --git a/rules/coding-style/tests/Rector/FuncCall/FunctionCallToConstantRector/config/configured_rule.php b/rules/coding-style/tests/Rector/FuncCall/FunctionCallToConstantRector/config/configured_rule.php index 55d14f0375c2..0298428b2dda 100644 --- a/rules/coding-style/tests/Rector/FuncCall/FunctionCallToConstantRector/config/configured_rule.php +++ b/rules/coding-style/tests/Rector/FuncCall/FunctionCallToConstantRector/config/configured_rule.php @@ -1,11 +1,12 @@ services(); - $services->set(\Rector\CodingStyle\Rector\FuncCall\FunctionCallToConstantRector::class)->call('configure', [[ - \Rector\CodingStyle\Rector\FuncCall\FunctionCallToConstantRector::FUNCTIONS_TO_CONSTANTS => [ + $services->set(FunctionCallToConstantRector::class)->call('configure', [[ + FunctionCallToConstantRector::FUNCTIONS_TO_CONSTANTS => [ 'php_sapi_name' => 'PHP_SAPI', 'pi' => 'M_PI', ], diff --git a/rules/coding-style/tests/Rector/MethodCall/PreferThisOrSelfMethodCallRector/config/configured_rule.php b/rules/coding-style/tests/Rector/MethodCall/PreferThisOrSelfMethodCallRector/config/configured_rule.php index 422c8759938b..ffafda770a72 100644 --- a/rules/coding-style/tests/Rector/MethodCall/PreferThisOrSelfMethodCallRector/config/configured_rule.php +++ b/rules/coding-style/tests/Rector/MethodCall/PreferThisOrSelfMethodCallRector/config/configured_rule.php @@ -1,14 +1,18 @@ services(); - $services->set(\Rector\CodingStyle\Rector\MethodCall\PreferThisOrSelfMethodCallRector::class)->call('configure', [[ - \Rector\CodingStyle\Rector\MethodCall\PreferThisOrSelfMethodCallRector::TYPE_TO_PREFERENCE => [ - \Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source\AbstractTestCase::class => 'self', - \Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source\BeLocalClass::class => 'this', - \PHPUnit\Framework\TestCase::class => 'self', + $services->set(PreferThisOrSelfMethodCallRector::class)->call('configure', [[ + PreferThisOrSelfMethodCallRector::TYPE_TO_PREFERENCE => [ + AbstractTestCase::class => 'self', + BeLocalClass::class => 'this', + TestCase::class => 'self', ], ]]); }; diff --git a/rules/dead-doc-block/tests/Rector/ClassLike/RemoveAnnotationRector/config/configured_rule.php b/rules/dead-doc-block/tests/Rector/ClassLike/RemoveAnnotationRector/config/configured_rule.php index da21ce844ef5..a6399bd64087 100644 --- a/rules/dead-doc-block/tests/Rector/ClassLike/RemoveAnnotationRector/config/configured_rule.php +++ b/rules/dead-doc-block/tests/Rector/ClassLike/RemoveAnnotationRector/config/configured_rule.php @@ -1,13 +1,12 @@ services(); - $services->set(\Rector\DeadDocBlock\Rector\ClassLike\RemoveAnnotationRector::class)->call('configure', [[ - \Rector\DeadDocBlock\Rector\ClassLike\RemoveAnnotationRector::ANNOTATIONS_TO_REMOVE => [ - 'method', - \Rector\BetterPhpDocParser\ValueObject\PhpDocNode\JMS\JMSInjectParamsTagValueNode::class, - ], + $services->set(RemoveAnnotationRector::class)->call('configure', [[ + RemoveAnnotationRector::ANNOTATIONS_TO_REMOVE => ['method', JMSInjectParamsTagValueNode::class], ]]); }; diff --git a/rules/doctrine-code-quality/tests/Rector/DoctrineRepositoryAsService/config/configured_rule.php b/rules/doctrine-code-quality/tests/Rector/DoctrineRepositoryAsService/config/configured_rule.php index 6826b1259b51..39aa2b9b6f60 100644 --- a/rules/doctrine-code-quality/tests/Rector/DoctrineRepositoryAsService/config/configured_rule.php +++ b/rules/doctrine-code-quality/tests/Rector/DoctrineRepositoryAsService/config/configured_rule.php @@ -1,13 +1,16 @@ services(); $services->set( # order matters, this needs to be first to correctly detect parent repository - \Rector\DoctrineCodeQuality\Rector\Class_\MoveRepositoryFromParentToConstructorRector::class + MoveRepositoryFromParentToConstructorRector::class ); - $services->set(\Rector\Doctrine\Rector\MethodCall\ReplaceParentRepositoryCallsByRepositoryPropertyRector::class); - $services->set(\Rector\Doctrine\Rector\Class_\RemoveRepositoryFromEntityAnnotationRector::class); + $services->set(ReplaceParentRepositoryCallsByRepositoryPropertyRector::class); + $services->set(RemoveRepositoryFromEntityAnnotationRector::class); }; diff --git a/rules/doctrine/tests/Rector/Class_/AddEntityIdByConditionRector/config/configured_rule.php b/rules/doctrine/tests/Rector/Class_/AddEntityIdByConditionRector/config/configured_rule.php index ac28b3cfb653..87226342954b 100644 --- a/rules/doctrine/tests/Rector/Class_/AddEntityIdByConditionRector/config/configured_rule.php +++ b/rules/doctrine/tests/Rector/Class_/AddEntityIdByConditionRector/config/configured_rule.php @@ -1,12 +1,12 @@ services(); - $services->set(\Rector\Doctrine\Rector\Class_\AddEntityIdByConditionRector::class)->call('configure', [[ - \Rector\Doctrine\Rector\Class_\AddEntityIdByConditionRector::DETECTED_TRAITS => [ - \Rector\Doctrine\Tests\Rector\Class_\AddEntityIdByConditionRector\Source\SomeTrait::class, - ], + $services->set(AddEntityIdByConditionRector::class)->call('configure', [[ + AddEntityIdByConditionRector::DETECTED_TRAITS => [SomeTrait::class], ]]); }; diff --git a/rules/doctrine/tests/Rector/MethodCall/EntityAliasToClassConstantReferenceRector/config/configured_rule.php b/rules/doctrine/tests/Rector/MethodCall/EntityAliasToClassConstantReferenceRector/config/configured_rule.php index d6931d563490..d8561b6ad74f 100644 --- a/rules/doctrine/tests/Rector/MethodCall/EntityAliasToClassConstantReferenceRector/config/configured_rule.php +++ b/rules/doctrine/tests/Rector/MethodCall/EntityAliasToClassConstantReferenceRector/config/configured_rule.php @@ -1,13 +1,14 @@ services(); - $services->set(\Rector\Doctrine\Rector\MethodCall\EntityAliasToClassConstantReferenceRector::class)->call( + $services->set(EntityAliasToClassConstantReferenceRector::class)->call( 'configure', [[ - \Rector\Doctrine\Rector\MethodCall\EntityAliasToClassConstantReferenceRector::ALIASES_TO_NAMESPACES => [ + EntityAliasToClassConstantReferenceRector::ALIASES_TO_NAMESPACES => [ 'App' => 'App\Entity', ], ]] diff --git a/rules/generic/tests/Rector/ClassMethod/AddMethodParentCallRector/config/configured_rule.php b/rules/generic/tests/Rector/ClassMethod/AddMethodParentCallRector/config/configured_rule.php index b0239fbdf712..8647789a5621 100644 --- a/rules/generic/tests/Rector/ClassMethod/AddMethodParentCallRector/config/configured_rule.php +++ b/rules/generic/tests/Rector/ClassMethod/AddMethodParentCallRector/config/configured_rule.php @@ -1,12 +1,14 @@ services(); - $services->set(\Rector\Generic\Rector\ClassMethod\AddMethodParentCallRector::class)->call('configure', [[ - \Rector\Generic\Rector\ClassMethod\AddMethodParentCallRector::METHODS_BY_PARENT_TYPES => [ - \Rector\Generic\Tests\Rector\ClassMethod\AddMethodParentCallRector\Source\ParentClassWithNewConstructor::class => '__construct', + $services->set(AddMethodParentCallRector::class)->call('configure', [[ + AddMethodParentCallRector::METHODS_BY_PARENT_TYPES => [ + ParentClassWithNewConstructor::class => '__construct', ], ]]); }; diff --git a/rules/generic/tests/Rector/ClassMethod/ArgumentAdderRector/config/configured_rule.php b/rules/generic/tests/Rector/ClassMethod/ArgumentAdderRector/config/configured_rule.php index 4222885b1879..f087e2c84717 100644 --- a/rules/generic/tests/Rector/ClassMethod/ArgumentAdderRector/config/configured_rule.php +++ b/rules/generic/tests/Rector/ClassMethod/ArgumentAdderRector/config/configured_rule.php @@ -1,53 +1,46 @@ services(); - $services->set(\Rector\Generic\Rector\ClassMethod\ArgumentAdderRector::class)->call('configure', [[ - \Rector\Generic\Rector\ClassMethod\ArgumentAdderRector::ADDED_ARGUMENTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + $services->set(ArgumentAdderRector::class)->call('configure', [[ + ArgumentAdderRector::ADDED_ARGUMENTS => ValueObjectInliner::inline([ // covers https://github.com/rectorphp/rector/issues/4267 - new \Rector\Generic\ValueObject\ArgumentAdder( - \Rector\Generic\Tests\Rector\ClassMethod\ArgumentAdderRector\Source\SomeContainerBuilder::class, + new ArgumentAdder( + SomeContainerBuilder::class, 'sendResetLinkResponse', 0, 'request', null, 'Illuminate\Http\Illuminate\Http' ), - new \Rector\Generic\ValueObject\ArgumentAdder( - \Rector\Generic\Tests\Rector\ClassMethod\ArgumentAdderRector\Source\SomeContainerBuilder::class, - 'compile', - 0, - 'isCompiled', - false - ), - new \Rector\Generic\ValueObject\ArgumentAdder( - \Rector\Generic\Tests\Rector\ClassMethod\ArgumentAdderRector\Source\SomeContainerBuilder::class, - 'addCompilerPass', - 2, - 'priority', - 0, - 'int' - ), + new ArgumentAdder(SomeContainerBuilder::class, 'compile', 0, 'isCompiled', false), + new ArgumentAdder(SomeContainerBuilder::class, 'addCompilerPass', 2, 'priority', 0, 'int'), // scoped - new \Rector\Generic\ValueObject\ArgumentAdder( - \Rector\Generic\Tests\Rector\ClassMethod\ArgumentAdderRector\Source\SomeParentClient::class, + new ArgumentAdder( + SomeParentClient::class, 'submit', 2, 'serverParameters', [], 'array', - \Rector\Generic\NodeAnalyzer\ArgumentAddingScope::SCOPE_PARENT_CALL + ArgumentAddingScope::SCOPE_PARENT_CALL ), - new \Rector\Generic\ValueObject\ArgumentAdder( - \Rector\Generic\Tests\Rector\ClassMethod\ArgumentAdderRector\Source\SomeParentClient::class, + new ArgumentAdder( + SomeParentClient::class, 'submit', 2, 'serverParameters', [], 'array', - \Rector\Generic\NodeAnalyzer\ArgumentAddingScope::SCOPE_CLASS_METHOD + ArgumentAddingScope::SCOPE_CLASS_METHOD ), ]), ]]); diff --git a/rules/generic/tests/Rector/ClassMethod/ArgumentDefaultValueReplacerRector/config/configured_rule.php b/rules/generic/tests/Rector/ClassMethod/ArgumentDefaultValueReplacerRector/config/configured_rule.php index 5f812e159f5d..0d4ef73e9bc2 100644 --- a/rules/generic/tests/Rector/ClassMethod/ArgumentDefaultValueReplacerRector/config/configured_rule.php +++ b/rules/generic/tests/Rector/ClassMethod/ArgumentDefaultValueReplacerRector/config/configured_rule.php @@ -1,64 +1,44 @@ services(); - $services->set(\Rector\Generic\Rector\ClassMethod\ArgumentDefaultValueReplacerRector::class)->call('configure', [[ - \Rector\Generic\Rector\ClassMethod\ArgumentDefaultValueReplacerRector::REPLACED_ARGUMENTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - - - - - - - - - - - - - - - - +use Rector\Generic\Rector\ClassMethod\ArgumentDefaultValueReplacerRector; +use Rector\Generic\ValueObject\ArgumentDefaultValueReplacer; +use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use Symplify\SymfonyPhpConfig\ValueObjectInliner; +return static function (ContainerConfigurator $containerConfigurator): void { + $services = $containerConfigurator->services(); + $services->set(ArgumentDefaultValueReplacerRector::class)->call('configure', [[ + ArgumentDefaultValueReplacerRector::REPLACED_ARGUMENTS => ValueObjectInliner::inline([ - new \Rector\Generic\ValueObject\ArgumentDefaultValueReplacer( + new ArgumentDefaultValueReplacer( 'Symfony\Component\DependencyInjection\Definition', 'setScope', 0, 'Symfony\Component\DependencyInjection\ContainerBuilder::SCOPE_PROTOTYPE', false ), - new \Rector\Generic\ValueObject\ArgumentDefaultValueReplacer('Symfony\Component\Yaml\Yaml', 'parse', 1, [ + new ArgumentDefaultValueReplacer('Symfony\Component\Yaml\Yaml', 'parse', 1, [ false, false, true, ], 'Symfony\Component\Yaml\Yaml::PARSE_OBJECT_FOR_MAP'), - new \Rector\Generic\ValueObject\ArgumentDefaultValueReplacer('Symfony\Component\Yaml\Yaml', 'parse', 1, [ + new ArgumentDefaultValueReplacer('Symfony\Component\Yaml\Yaml', 'parse', 1, [ false, true, ], 'Symfony\Component\Yaml\Yaml::PARSE_OBJECT'), - new \Rector\Generic\ValueObject\ArgumentDefaultValueReplacer( - 'Symfony\Component\Yaml\Yaml', - 'parse', - 1, - false, - 0 - ), - new \Rector\Generic\ValueObject\ArgumentDefaultValueReplacer( + new ArgumentDefaultValueReplacer('Symfony\Component\Yaml\Yaml', 'parse', 1, false, 0), + new ArgumentDefaultValueReplacer( 'Symfony\Component\Yaml\Yaml', 'parse', 1, true, 'Symfony\Component\Yaml\Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE' ), - new \Rector\Generic\ValueObject\ArgumentDefaultValueReplacer('Symfony\Component\Yaml\Yaml', 'dump', 3, [ + new ArgumentDefaultValueReplacer('Symfony\Component\Yaml\Yaml', 'dump', 3, [ false, true, ], 'Symfony\Component\Yaml\Yaml::DUMP_OBJECT'), - new \Rector\Generic\ValueObject\ArgumentDefaultValueReplacer( + new ArgumentDefaultValueReplacer( 'Symfony\Component\Yaml\Yaml', 'dump', 3, @@ -66,30 +46,6 @@ 'Symfony\Component\Yaml\Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE' ), - - - - - - - - - - - - - - - - - - - - - - - - ]), ]]); }; diff --git a/rules/generic/tests/Rector/ClassMethod/NormalToFluentRector/config/configured_rule.php b/rules/generic/tests/Rector/ClassMethod/NormalToFluentRector/config/configured_rule.php index 7cac6da6d122..dca13bf2c93b 100644 --- a/rules/generic/tests/Rector/ClassMethod/NormalToFluentRector/config/configured_rule.php +++ b/rules/generic/tests/Rector/ClassMethod/NormalToFluentRector/config/configured_rule.php @@ -1,12 +1,16 @@ services(); - $services->set(\Rector\Generic\Rector\ClassMethod\NormalToFluentRector::class)->call('configure', [[ - \Rector\Generic\Rector\ClassMethod\NormalToFluentRector::CALLS_TO_FLUENT => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + $services->set(NormalToFluentRector::class)->call('configure', [[ + NormalToFluentRector::CALLS_TO_FLUENT => ValueObjectInliner::inline([ + @@ -24,8 +28,8 @@ - new \Rector\Generic\ValueObject\NormalToFluent( - \Rector\Generic\Tests\Rector\ClassMethod\NormalToFluentRector\Source\FluentInterfaceClass::class, + new NormalToFluent( + FluentInterfaceClass::class, ['someFunction', 'otherFunction', 'joinThisAsWell']), ] ), diff --git a/rules/generic/tests/Rector/ClassMethod/SingleToManyMethodRector/config/configured_rule.php b/rules/generic/tests/Rector/ClassMethod/SingleToManyMethodRector/config/configured_rule.php index 535f77387071..865fbb627d20 100644 --- a/rules/generic/tests/Rector/ClassMethod/SingleToManyMethodRector/config/configured_rule.php +++ b/rules/generic/tests/Rector/ClassMethod/SingleToManyMethodRector/config/configured_rule.php @@ -1,12 +1,17 @@ services(); - $services->set(\Rector\Generic\Rector\ClassMethod\SingleToManyMethodRector::class)->call('configure', [[ - \Rector\Generic\Rector\ClassMethod\SingleToManyMethodRector::SINGLES_TO_MANY_METHODS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + $services->set(SingleToManyMethodRector::class)->call('configure', [[ + SingleToManyMethodRector::SINGLES_TO_MANY_METHODS => ValueObjectInliner::inline([ + + @@ -23,12 +28,8 @@ + new SingleToManyMethod(OneToManyInterface::class, 'getNode', 'getNodes'), - new \Rector\Generic\ValueObject\SingleToManyMethod( - \Rector\Generic\Tests\Rector\ClassMethod\SingleToManyMethodRector\Source\OneToManyInterface::class, - 'getNode', - 'getNodes' - ), @@ -53,7 +54,6 @@ - ]), ]]); }; diff --git a/rules/generic/tests/Rector/ClassMethod/WrapReturnRector/config/configured_rule.php b/rules/generic/tests/Rector/ClassMethod/WrapReturnRector/config/configured_rule.php index 8e0156edae06..838d44764b3d 100644 --- a/rules/generic/tests/Rector/ClassMethod/WrapReturnRector/config/configured_rule.php +++ b/rules/generic/tests/Rector/ClassMethod/WrapReturnRector/config/configured_rule.php @@ -1,12 +1,17 @@ services(); - $services->set(\Rector\Generic\Rector\ClassMethod\WrapReturnRector::class)->call('configure', [[ - \Rector\Generic\Rector\ClassMethod\WrapReturnRector::TYPE_METHOD_WRAPS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + $services->set(WrapReturnRector::class)->call('configure', [[ + WrapReturnRector::TYPE_METHOD_WRAPS => ValueObjectInliner::inline([ + + @@ -23,12 +28,8 @@ + new WrapReturn(SomeReturnClass::class, 'getItem', true), - new \Rector\Generic\ValueObject\WrapReturn( - \Rector\Generic\Tests\Rector\ClassMethod\WrapReturnRector\Source\SomeReturnClass::class, - 'getItem', - true - ), @@ -53,7 +54,6 @@ - ]), ]]); }; diff --git a/rules/generic/tests/Rector/Class_/AddInterfaceByTraitRector/config/configured_rule.php b/rules/generic/tests/Rector/Class_/AddInterfaceByTraitRector/config/configured_rule.php index 7d10e096b144..8391fc9ca849 100644 --- a/rules/generic/tests/Rector/Class_/AddInterfaceByTraitRector/config/configured_rule.php +++ b/rules/generic/tests/Rector/Class_/AddInterfaceByTraitRector/config/configured_rule.php @@ -1,12 +1,15 @@ services(); - $services->set(\Rector\Generic\Rector\Class_\AddInterfaceByTraitRector::class)->call('configure', [[ - \Rector\Generic\Rector\Class_\AddInterfaceByTraitRector::INTERFACE_BY_TRAIT => [ - \Rector\Generic\Tests\Rector\Class_\AddInterfaceByTraitRector\Source\SomeTrait::class => \Rector\Generic\Tests\Rector\Class_\AddInterfaceByTraitRector\Source\SomeInterface::class, + $services->set(AddInterfaceByTraitRector::class)->call('configure', [[ + AddInterfaceByTraitRector::INTERFACE_BY_TRAIT => [ + SomeTrait::class => SomeInterface::class, ], ]]); }; diff --git a/rules/generic/tests/Rector/Class_/AddPropertyByParentRector/config/configured_rule.php b/rules/generic/tests/Rector/Class_/AddPropertyByParentRector/config/configured_rule.php index f8060794da5c..4927aea22c39 100644 --- a/rules/generic/tests/Rector/Class_/AddPropertyByParentRector/config/configured_rule.php +++ b/rules/generic/tests/Rector/Class_/AddPropertyByParentRector/config/configured_rule.php @@ -1,12 +1,16 @@ services(); - $services->set(\Rector\Generic\Rector\Class_\AddPropertyByParentRector::class)->call('configure', [[ - \Rector\Generic\Rector\Class_\AddPropertyByParentRector::PARENT_DEPENDENCIES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + $services->set(AddPropertyByParentRector::class)->call('configure', [[ + AddPropertyByParentRector::PARENT_DEPENDENCIES => ValueObjectInliner::inline([ + @@ -24,8 +28,8 @@ - new \Rector\Generic\ValueObject\AddPropertyByParent( - \Rector\Generic\Tests\Rector\Class_\AddPropertyByParentRector\Source\SomeParentClassToAddDependencyBy::class, + new AddPropertyByParent( + SomeParentClassToAddDependencyBy::class, 'SomeDependency' ), @@ -52,7 +56,7 @@ - + ]), ]]); }; diff --git a/rules/generic/tests/Rector/Class_/MergeInterfacesRector/config/configured_rule.php b/rules/generic/tests/Rector/Class_/MergeInterfacesRector/config/configured_rule.php index 3ba2d3f19ff0..6cb89039a3a1 100644 --- a/rules/generic/tests/Rector/Class_/MergeInterfacesRector/config/configured_rule.php +++ b/rules/generic/tests/Rector/Class_/MergeInterfacesRector/config/configured_rule.php @@ -1,12 +1,15 @@ services(); - $services->set(\Rector\Generic\Rector\Class_\MergeInterfacesRector::class)->call('configure', [[ - \Rector\Generic\Rector\Class_\MergeInterfacesRector::OLD_TO_NEW_INTERFACES => [ - \Rector\Generic\Tests\Rector\Class_\MergeInterfacesRector\Source\SomeOldInterface::class => \Rector\Generic\Tests\Rector\Class_\MergeInterfacesRector\Source\SomeInterface::class, + $services->set(MergeInterfacesRector::class)->call('configure', [[ + MergeInterfacesRector::OLD_TO_NEW_INTERFACES => [ + SomeOldInterface::class => SomeInterface::class, ], ]]); }; diff --git a/rules/generic/tests/Rector/FuncCall/SwapFuncCallArgumentsRector/config/configured_rule.php b/rules/generic/tests/Rector/FuncCall/SwapFuncCallArgumentsRector/config/configured_rule.php index 8a1ceacd18d6..a683d3cb8927 100644 --- a/rules/generic/tests/Rector/FuncCall/SwapFuncCallArgumentsRector/config/configured_rule.php +++ b/rules/generic/tests/Rector/FuncCall/SwapFuncCallArgumentsRector/config/configured_rule.php @@ -1,12 +1,15 @@ services(); - $services->set(\Rector\Generic\Rector\FuncCall\SwapFuncCallArgumentsRector::class)->call('configure', [[ - \Rector\Generic\Rector\FuncCall\SwapFuncCallArgumentsRector::FUNCTION_ARGUMENT_SWAPS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + $services->set(SwapFuncCallArgumentsRector::class)->call('configure', [[ + SwapFuncCallArgumentsRector::FUNCTION_ARGUMENT_SWAPS => ValueObjectInliner::inline([ + @@ -24,7 +27,7 @@ - new \Rector\Generic\ValueObject\SwapFuncCallArguments('some_function', [1, 0]), + new SwapFuncCallArguments('some_function', [1, 0]), ] ), ]]); diff --git a/rules/generic/tests/Rector/Property/InjectAnnotationClassRector/config/configured_rule.php b/rules/generic/tests/Rector/Property/InjectAnnotationClassRector/config/configured_rule.php index b48ceb599d19..f8a076da9ed6 100644 --- a/rules/generic/tests/Rector/Property/InjectAnnotationClassRector/config/configured_rule.php +++ b/rules/generic/tests/Rector/Property/InjectAnnotationClassRector/config/configured_rule.php @@ -1,13 +1,12 @@ services(); - $services->set(\Rector\Generic\Rector\Property\InjectAnnotationClassRector::class)->call('configure', [[ - \Rector\Generic\Rector\Property\InjectAnnotationClassRector::ANNOTATION_CLASSES => [ - \JMS\DiExtraBundle\Annotation\Inject::class, - \DI\Annotation\Inject::class, - ], + $services->set(InjectAnnotationClassRector::class)->call('configure', [[ + InjectAnnotationClassRector::ANNOTATION_CLASSES => [Inject::class, \DI\Annotation\Inject::class], ]]); }; diff --git a/rules/generic/tests/Rector/RectorOrder/config/configured_rule.php b/rules/generic/tests/Rector/RectorOrder/config/configured_rule.php index b4c9c2915edd..827847d3be27 100644 --- a/rules/generic/tests/Rector/RectorOrder/config/configured_rule.php +++ b/rules/generic/tests/Rector/RectorOrder/config/configured_rule.php @@ -1,10 +1,13 @@ services(); - $services->set(\Rector\PHPUnit\Rector\MethodCall\AssertComparisonToSpecificMethodRector::class); - $services->set(\Rector\PHPUnit\Rector\MethodCall\AssertSameBoolNullToSpecificMethodRector::class); - $services->set(\Rector\PHPUnit\Rector\MethodCall\AssertFalseStrposToContainsRector::class); + $services->set(AssertComparisonToSpecificMethodRector::class); + $services->set(AssertSameBoolNullToSpecificMethodRector::class); + $services->set(AssertFalseStrposToContainsRector::class); }; diff --git a/rules/legacy/tests/Rector/FileWithoutNamespace/AddTopIncludeRector/config/configured_rule.php b/rules/legacy/tests/Rector/FileWithoutNamespace/AddTopIncludeRector/config/configured_rule.php index 9dac980ee24d..a9a1bb54010a 100644 --- a/rules/legacy/tests/Rector/FileWithoutNamespace/AddTopIncludeRector/config/configured_rule.php +++ b/rules/legacy/tests/Rector/FileWithoutNamespace/AddTopIncludeRector/config/configured_rule.php @@ -1,10 +1,11 @@ services(); - $services->set(\Rector\Legacy\Rector\FileWithoutNamespace\AddTopIncludeRector::class)->call('configure', [[ - \Rector\Legacy\Rector\FileWithoutNamespace\AddTopIncludeRector::AUTOLOAD_FILE_PATH => '/../autoloader.php', + $services->set(AddTopIncludeRector::class)->call('configure', [[ + AddTopIncludeRector::AUTOLOAD_FILE_PATH => '/../autoloader.php', ]]); }; diff --git a/rules/nette-tester-to-phpunit/tests/Rector/Class_/NetteTesterClassToPHPUnitClassRector/config/configured_rule.php b/rules/nette-tester-to-phpunit/tests/Rector/Class_/NetteTesterClassToPHPUnitClassRector/config/configured_rule.php index 450e83b4478f..c479a65f6ae0 100644 --- a/rules/nette-tester-to-phpunit/tests/Rector/Class_/NetteTesterClassToPHPUnitClassRector/config/configured_rule.php +++ b/rules/nette-tester-to-phpunit/tests/Rector/Class_/NetteTesterClassToPHPUnitClassRector/config/configured_rule.php @@ -1,9 +1,11 @@ services(); - $services->set(\Rector\NetteTesterToPHPUnit\Rector\StaticCall\NetteAssertToPHPUnitAssertRector::class); - $services->set(\Rector\NetteTesterToPHPUnit\Rector\Class_\NetteTesterClassToPHPUnitClassRector::class); + $services->set(NetteAssertToPHPUnitAssertRector::class); + $services->set(NetteTesterClassToPHPUnitClassRector::class); }; diff --git a/rules/php-spec-to-phpunit/tests/Rector/Variable/PhpSpecToPHPUnitRector/config/configured_rule.php b/rules/php-spec-to-phpunit/tests/Rector/Variable/PhpSpecToPHPUnitRector/config/configured_rule.php index 045eb993ac05..6a5284c9d327 100644 --- a/rules/php-spec-to-phpunit/tests/Rector/Variable/PhpSpecToPHPUnitRector/config/configured_rule.php +++ b/rules/php-spec-to-phpunit/tests/Rector/Variable/PhpSpecToPHPUnitRector/config/configured_rule.php @@ -1,16 +1,22 @@ services(); $services->set( # 1. first convert mocks - \Rector\PhpSpecToPHPUnit\Rector\MethodCall\PhpSpecMocksToPHPUnitMocksRector::class + PhpSpecMocksToPHPUnitMocksRector::class ); - $services->set(\Rector\PhpSpecToPHPUnit\Rector\MethodCall\PhpSpecPromisesToPHPUnitAssertRector::class); - $services->set(\Rector\PhpSpecToPHPUnit\Rector\ClassMethod\PhpSpecMethodToPHPUnitMethodRector::class); - $services->set(\Rector\PhpSpecToPHPUnit\Rector\Class_\PhpSpecClassToPHPUnitClassRector::class); - $services->set(\Rector\PhpSpecToPHPUnit\Rector\Class_\AddMockPropertiesRector::class); - $services->set(\Rector\PhpSpecToPHPUnit\Rector\Variable\MockVariableToPropertyFetchRector::class); + $services->set(PhpSpecPromisesToPHPUnitAssertRector::class); + $services->set(PhpSpecMethodToPHPUnitMethodRector::class); + $services->set(PhpSpecClassToPHPUnitClassRector::class); + $services->set(AddMockPropertiesRector::class); + $services->set(MockVariableToPropertyFetchRector::class); }; diff --git a/rules/php71/tests/Rector/Name/ReservedObjectRector/config/configured_rule.php b/rules/php71/tests/Rector/Name/ReservedObjectRector/config/configured_rule.php index 11dd63a5920f..4ca4af93f906 100644 --- a/rules/php71/tests/Rector/Name/ReservedObjectRector/config/configured_rule.php +++ b/rules/php71/tests/Rector/Name/ReservedObjectRector/config/configured_rule.php @@ -1,11 +1,12 @@ services(); - $services->set(\Rector\Php71\Rector\Name\ReservedObjectRector::class)->call('configure', [[ - \Rector\Php71\Rector\Name\ReservedObjectRector::RESERVED_KEYWORDS_TO_REPLACEMENTS => [ + $services->set(ReservedObjectRector::class)->call('configure', [[ + ReservedObjectRector::RESERVED_KEYWORDS_TO_REPLACEMENTS => [ 'ReservedObject' => 'SmartObject', 'Object' => 'AnotherSmartObject', ], diff --git a/rules/php74/tests/Rector/Function_/ReservedFnFunctionRector/config/configured_rule.php b/rules/php74/tests/Rector/Function_/ReservedFnFunctionRector/config/configured_rule.php index 01ad0c2d5c90..30ac06a8da8b 100644 --- a/rules/php74/tests/Rector/Function_/ReservedFnFunctionRector/config/configured_rule.php +++ b/rules/php74/tests/Rector/Function_/ReservedFnFunctionRector/config/configured_rule.php @@ -1,11 +1,12 @@ services(); - $services->set(\Rector\Php74\Rector\Function_\ReservedFnFunctionRector::class)->call('configure', [[ - \Rector\Php74\Rector\Function_\ReservedFnFunctionRector::RESERVED_NAMES_TO_NEW_ONES => [ + $services->set(ReservedFnFunctionRector::class)->call('configure', [[ + ReservedFnFunctionRector::RESERVED_NAMES_TO_NEW_ONES => [ // for testing purposes of "fn" even on PHP 7.3- 'reservedFn' => 'f', ], diff --git a/rules/php74/tests/Rector/LNumber/AddLiteralSeparatorToNumberRector/config/configured_rule.php b/rules/php74/tests/Rector/LNumber/AddLiteralSeparatorToNumberRector/config/configured_rule.php index b2c4d976eb8a..ec0df7f00943 100644 --- a/rules/php74/tests/Rector/LNumber/AddLiteralSeparatorToNumberRector/config/configured_rule.php +++ b/rules/php74/tests/Rector/LNumber/AddLiteralSeparatorToNumberRector/config/configured_rule.php @@ -1,10 +1,11 @@ services(); - $services->set(\Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector::class)->call('configure', [[ - \Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector::LIMIT_VALUE => 1000000, + $services->set(AddLiteralSeparatorToNumberRector::class)->call('configure', [[ + AddLiteralSeparatorToNumberRector::LIMIT_VALUE => 1000000, ]]); }; diff --git a/rules/php74/tests/Rector/Property/TypedPropertyRector/config/class_types_only.php b/rules/php74/tests/Rector/Property/TypedPropertyRector/config/class_types_only.php index a6bdcff520ee..6dde1f382c5d 100644 --- a/rules/php74/tests/Rector/Property/TypedPropertyRector/config/class_types_only.php +++ b/rules/php74/tests/Rector/Property/TypedPropertyRector/config/class_types_only.php @@ -1,10 +1,11 @@ services(); - $services->set(\Rector\Php74\Rector\Property\TypedPropertyRector::class)->call('configure', [[ - \Rector\Php74\Rector\Property\TypedPropertyRector::CLASS_LIKE_TYPE_ONLY => true, + $services->set(TypedPropertyRector::class)->call('configure', [[ + TypedPropertyRector::CLASS_LIKE_TYPE_ONLY => true, ]]); }; diff --git a/rules/php74/tests/Rector/Property/TypedPropertyRector/config/configured_rule.php b/rules/php74/tests/Rector/Property/TypedPropertyRector/config/configured_rule.php index f857d064ee24..2f5b961cce06 100644 --- a/rules/php74/tests/Rector/Property/TypedPropertyRector/config/configured_rule.php +++ b/rules/php74/tests/Rector/Property/TypedPropertyRector/config/configured_rule.php @@ -1,10 +1,11 @@ services(); - $services->set(\Rector\Php74\Rector\Property\TypedPropertyRector::class)->call('configure', [[ - \Rector\Php74\Rector\Property\TypedPropertyRector::CLASS_LIKE_TYPE_ONLY => false, + $services->set(TypedPropertyRector::class)->call('configure', [[ + TypedPropertyRector::CLASS_LIKE_TYPE_ONLY => false, ]]); }; diff --git a/rules/removing-static/tests/Rector/Class_/PHPUnitStaticToKernelTestCaseGetRector/config/configured_rule.php b/rules/removing-static/tests/Rector/Class_/PHPUnitStaticToKernelTestCaseGetRector/config/configured_rule.php index bcbb47e6b7a1..ce39e64877e8 100644 --- a/rules/removing-static/tests/Rector/Class_/PHPUnitStaticToKernelTestCaseGetRector/config/configured_rule.php +++ b/rules/removing-static/tests/Rector/Class_/PHPUnitStaticToKernelTestCaseGetRector/config/configured_rule.php @@ -1,15 +1,15 @@ services(); - $services->set(\Rector\RemovingStatic\Rector\Class_\PHPUnitStaticToKernelTestCaseGetRector::class)->call( + $services->set(PHPUnitStaticToKernelTestCaseGetRector::class)->call( 'configure', [[ - \Rector\RemovingStatic\Rector\Class_\PHPUnitStaticToKernelTestCaseGetRector::STATIC_CLASS_TYPES => [ - \Rector\RemovingStatic\Tests\Rector\Class_\PHPUnitStaticToKernelTestCaseGetRector\Source\ClassWithStaticMethods::class, - ], + PHPUnitStaticToKernelTestCaseGetRector::STATIC_CLASS_TYPES => [ClassWithStaticMethods::class], ]] ); }; diff --git a/rules/removing-static/tests/Rector/Class_/StaticTypeToSetterInjectionRector/config/configured_rule.php b/rules/removing-static/tests/Rector/Class_/StaticTypeToSetterInjectionRector/config/configured_rule.php index 8e65151424e0..e4056ae6473a 100644 --- a/rules/removing-static/tests/Rector/Class_/StaticTypeToSetterInjectionRector/config/configured_rule.php +++ b/rules/removing-static/tests/Rector/Class_/StaticTypeToSetterInjectionRector/config/configured_rule.php @@ -1,14 +1,17 @@ services(); - $services->set(\Rector\RemovingStatic\Rector\Class_\StaticTypeToSetterInjectionRector::class)->call('configure', [[ - \Rector\RemovingStatic\Rector\Class_\StaticTypeToSetterInjectionRector::STATIC_TYPES => [ - \Rector\RemovingStatic\Tests\Rector\Class_\StaticTypeToSetterInjectionRector\Source\GenericEntityFactory::class, + $services->set(StaticTypeToSetterInjectionRector::class)->call('configure', [[ + StaticTypeToSetterInjectionRector::STATIC_TYPES => [ + GenericEntityFactory::class, // with adding a parent interface to the class - 'ParentSetterEnforcingInterface' => \Rector\RemovingStatic\Tests\Rector\Class_\StaticTypeToSetterInjectionRector\Source\GenericEntityFactoryWithInterface::class, + 'ParentSetterEnforcingInterface' => GenericEntityFactoryWithInterface::class, ], ]]); }; diff --git a/rules/removing/tests/Rector/ClassMethod/ArgumentRemoverRector/config/configured_rule.php b/rules/removing/tests/Rector/ClassMethod/ArgumentRemoverRector/config/configured_rule.php index f8f15b17ac6b..0fa32674889a 100644 --- a/rules/removing/tests/Rector/ClassMethod/ArgumentRemoverRector/config/configured_rule.php +++ b/rules/removing/tests/Rector/ClassMethod/ArgumentRemoverRector/config/configured_rule.php @@ -1,12 +1,17 @@ services(); - $services->set(\Rector\Removing\Rector\ClassMethod\ArgumentRemoverRector::class)->call('configure', [[ - \Rector\Removing\Rector\ClassMethod\ArgumentRemoverRector::REMOVED_ARGUMENTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + $services->set(ArgumentRemoverRector::class)->call('configure', [[ + ArgumentRemoverRector::REMOVED_ARGUMENTS => ValueObjectInliner::inline([ @@ -24,13 +29,14 @@ - new \Rector\Removing\ValueObject\ArgumentRemover( - \Rector\Removing\Tests\Rector\ClassMethod\ArgumentRemoverRector\Source\Persister::class, + + new ArgumentRemover( + Persister::class, 'getSelectJoinColumnSQL', 4, null - ), new \Rector\Removing\ValueObject\ArgumentRemover( - \Symfony\Component\Yaml\Yaml::class, + ), new ArgumentRemover( + Yaml::class, 'parse', 1, [ @@ -39,7 +45,7 @@ 55, 5.5, - ]), new \Rector\Removing\ValueObject\ArgumentRemover(\Rector\Removing\Tests\Rector\ClassMethod\ArgumentRemoverRector\Source\RemoveInTheMiddle::class, 'run', 1, [ + ]), new ArgumentRemover(RemoveInTheMiddle::class, 'run', 1, [ 'name' => 'second', ]), ] ), diff --git a/rules/removing/tests/Rector/Class_/RemoveInterfacesRector/config/configured_rule.php b/rules/removing/tests/Rector/Class_/RemoveInterfacesRector/config/configured_rule.php index 0dbf9909ca3e..07bc48bfbe25 100644 --- a/rules/removing/tests/Rector/Class_/RemoveInterfacesRector/config/configured_rule.php +++ b/rules/removing/tests/Rector/Class_/RemoveInterfacesRector/config/configured_rule.php @@ -1,12 +1,12 @@ services(); - $services->set(\Rector\Removing\Rector\Class_\RemoveInterfacesRector::class)->call('configure', [[ - \Rector\Removing\Rector\Class_\RemoveInterfacesRector::INTERFACES_TO_REMOVE => [ - \Rector\Removing\Tests\Rector\Class_\RemoveInterfacesRector\Source\SomeInterface::class, - ], + $services->set(RemoveInterfacesRector::class)->call('configure', [[ + RemoveInterfacesRector::INTERFACES_TO_REMOVE => [SomeInterface::class], ]]); }; diff --git a/rules/removing/tests/Rector/Class_/RemoveParentRector/config/configured_rule.php b/rules/removing/tests/Rector/Class_/RemoveParentRector/config/configured_rule.php index 83ecc72bcdda..499918c25886 100644 --- a/rules/removing/tests/Rector/Class_/RemoveParentRector/config/configured_rule.php +++ b/rules/removing/tests/Rector/Class_/RemoveParentRector/config/configured_rule.php @@ -1,12 +1,12 @@ services(); - $services->set(\Rector\Removing\Rector\Class_\RemoveParentRector::class)->call('configure', [[ - \Rector\Removing\Rector\Class_\RemoveParentRector::PARENT_TYPES_TO_REMOVE => [ - \Rector\Removing\Tests\Rector\Class_\RemoveParentRector\Source\ParentTypeToBeRemoved::class, - ], + $services->set(RemoveParentRector::class)->call('configure', [[ + RemoveParentRector::PARENT_TYPES_TO_REMOVE => [ParentTypeToBeRemoved::class], ]]); }; diff --git a/rules/removing/tests/Rector/Class_/RemoveTraitRector/config/configured_rule.php b/rules/removing/tests/Rector/Class_/RemoveTraitRector/config/configured_rule.php index 2cb3ef1c2166..1e62d84a74da 100644 --- a/rules/removing/tests/Rector/Class_/RemoveTraitRector/config/configured_rule.php +++ b/rules/removing/tests/Rector/Class_/RemoveTraitRector/config/configured_rule.php @@ -1,12 +1,12 @@ services(); - $services->set(\Rector\Removing\Rector\Class_\RemoveTraitRector::class)->call('configure', [[ - \Rector\Removing\Rector\Class_\RemoveTraitRector::TRAITS_TO_REMOVE => [ - \Rector\Removing\Tests\Rector\Class_\RemoveTraitRector\Source\TraitToBeRemoved::class, - ], + $services->set(RemoveTraitRector::class)->call('configure', [[ + RemoveTraitRector::TRAITS_TO_REMOVE => [TraitToBeRemoved::class], ]]); }; diff --git a/rules/removing/tests/Rector/FuncCall/RemoveFuncCallArgRector/config/configured_rule.php b/rules/removing/tests/Rector/FuncCall/RemoveFuncCallArgRector/config/configured_rule.php index 325c50c4e0f9..28a9cd5815d8 100644 --- a/rules/removing/tests/Rector/FuncCall/RemoveFuncCallArgRector/config/configured_rule.php +++ b/rules/removing/tests/Rector/FuncCall/RemoveFuncCallArgRector/config/configured_rule.php @@ -1,12 +1,16 @@ services(); - $services->set(\Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::class)->call('configure', [[ - \Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::REMOVED_FUNCTION_ARGUMENTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + $services->set(RemoveFuncCallArgRector::class)->call('configure', [[ + RemoveFuncCallArgRector::REMOVED_FUNCTION_ARGUMENTS => ValueObjectInliner::inline([ + + @@ -23,8 +27,8 @@ + new RemoveFuncCallArg('ldap_first_attribute', 2), - new \Rector\Removing\ValueObject\RemoveFuncCallArg('ldap_first_attribute', 2), @@ -49,7 +53,6 @@ - ]), ]]); }; diff --git a/rules/removing/tests/Rector/FuncCall/RemoveFuncCallRector/config/configured_rule.php b/rules/removing/tests/Rector/FuncCall/RemoveFuncCallRector/config/configured_rule.php index 49d89e227c9e..784325f85627 100644 --- a/rules/removing/tests/Rector/FuncCall/RemoveFuncCallRector/config/configured_rule.php +++ b/rules/removing/tests/Rector/FuncCall/RemoveFuncCallRector/config/configured_rule.php @@ -1,12 +1,15 @@ services(); - $services->set(\Rector\Removing\Rector\FuncCall\RemoveFuncCallRector::class)->call('configure', [[ - \Rector\Removing\Rector\FuncCall\RemoveFuncCallRector::REMOVE_FUNC_CALLS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + $services->set(RemoveFuncCallRector::class)->call('configure', [[ + RemoveFuncCallRector::REMOVE_FUNC_CALLS => ValueObjectInliner::inline([ + @@ -24,9 +27,9 @@ - new \Rector\Removing\ValueObject\RemoveFuncCall('ini_get', [ + new RemoveFuncCall('ini_get', [ 0 => ['y2k_compliance', 'safe_mode', 'magic_quotes_runtime'], - ]), new \Rector\Removing\ValueObject\RemoveFuncCall('ini_set', [ + ]), new RemoveFuncCall('ini_set', [ 0 => ['y2k_compliance', 'safe_mode', 'magic_quotes_runtime'], ]), ] ), diff --git a/rules/renaming/tests/Rector/ClassConstFetch/RenameClassConstFetchRector/config/configured_rule.php b/rules/renaming/tests/Rector/ClassConstFetch/RenameClassConstFetchRector/config/configured_rule.php index ddd7b2bdbc46..290241a822f7 100644 --- a/rules/renaming/tests/Rector/ClassConstFetch/RenameClassConstFetchRector/config/configured_rule.php +++ b/rules/renaming/tests/Rector/ClassConstFetch/RenameClassConstFetchRector/config/configured_rule.php @@ -1,12 +1,17 @@ services(); - $services->set(\Rector\Renaming\Rector\ClassConstFetch\RenameClassConstFetchRector::class)->call('configure', [[ - \Rector\Renaming\Rector\ClassConstFetch\RenameClassConstFetchRector::CLASS_CONSTANT_RENAME => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + $services->set(RenameClassConstFetchRector::class)->call('configure', [[ + RenameClassConstFetchRector::CLASS_CONSTANT_RENAME => ValueObjectInliner::inline([ @@ -24,25 +29,18 @@ - new \Rector\Renaming\ValueObject\RenameClassConstFetch( - \Rector\Renaming\Tests\Rector\ClassConstFetch\RenameClassConstFetchRector\Source\LocalFormEvents::class, + + new RenameClassConstFetch( + LocalFormEvents::class, 'PRE_BIND', 'PRE_SUBMIT' ), - new \Rector\Renaming\ValueObject\RenameClassConstFetch( - \Rector\Renaming\Tests\Rector\ClassConstFetch\RenameClassConstFetchRector\Source\LocalFormEvents::class, - 'BIND', - 'SUBMIT' - ), - new \Rector\Renaming\ValueObject\RenameClassConstFetch( - \Rector\Renaming\Tests\Rector\ClassConstFetch\RenameClassConstFetchRector\Source\LocalFormEvents::class, - 'POST_BIND', - 'POST_SUBMIT' - ), - new \Rector\Renaming\ValueObject\RenameClassAndConstFetch( - \Rector\Renaming\Tests\Rector\ClassConstFetch\RenameClassConstFetchRector\Source\LocalFormEvents::class, + new RenameClassConstFetch(LocalFormEvents::class, 'BIND', 'SUBMIT'), + new RenameClassConstFetch(LocalFormEvents::class, 'POST_BIND', 'POST_SUBMIT'), + new RenameClassAndConstFetch( + LocalFormEvents::class, 'OLD_CONSTANT', - \Rector\Renaming\Tests\Rector\ClassConstFetch\RenameClassConstFetchRector\Source\DifferentClass::class, + DifferentClass::class, 'NEW_CONSTANT' ), @@ -69,7 +67,7 @@ - + ]), ]]); }; diff --git a/rules/renaming/tests/Rector/ClassMethod/RenameAnnotationRector/config/configured_rule.php b/rules/renaming/tests/Rector/ClassMethod/RenameAnnotationRector/config/configured_rule.php index d51d6eb1a8f3..6cfc9a002c18 100644 --- a/rules/renaming/tests/Rector/ClassMethod/RenameAnnotationRector/config/configured_rule.php +++ b/rules/renaming/tests/Rector/ClassMethod/RenameAnnotationRector/config/configured_rule.php @@ -1,12 +1,16 @@ services(); - $services->set(\Rector\Renaming\Rector\ClassMethod\RenameAnnotationRector::class)->call('configure', [[ - \Rector\Renaming\Rector\ClassMethod\RenameAnnotationRector::RENAMED_ANNOTATIONS_IN_TYPES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + $services->set(RenameAnnotationRector::class)->call('configure', [[ + RenameAnnotationRector::RENAMED_ANNOTATIONS_IN_TYPES => ValueObjectInliner::inline([ + + @@ -23,12 +27,8 @@ + new RenameAnnotation('PHPUnit\Framework\TestCase', 'scenario', 'test'), - new \Rector\Renaming\ValueObject\RenameAnnotation( - 'PHPUnit\Framework\TestCase', - 'scenario', - 'test' - ), @@ -53,7 +53,6 @@ - ]), ]]); }; diff --git a/rules/renaming/tests/Rector/ConstFetch/RenameConstantRector/config/configured_rule.php b/rules/renaming/tests/Rector/ConstFetch/RenameConstantRector/config/configured_rule.php index cd44afbcf6d7..0a282722c257 100644 --- a/rules/renaming/tests/Rector/ConstFetch/RenameConstantRector/config/configured_rule.php +++ b/rules/renaming/tests/Rector/ConstFetch/RenameConstantRector/config/configured_rule.php @@ -1,11 +1,12 @@ services(); - $services->set(\Rector\Renaming\Rector\ConstFetch\RenameConstantRector::class)->call('configure', [[ - \Rector\Renaming\Rector\ConstFetch\RenameConstantRector::OLD_TO_NEW_CONSTANTS => [ + $services->set(RenameConstantRector::class)->call('configure', [[ + RenameConstantRector::OLD_TO_NEW_CONSTANTS => [ 'MYSQL_ASSOC' => 'MYSQLI_ASSOC', 'OLD_CONSTANT' => 'NEW_CONSTANT', ], diff --git a/rules/renaming/tests/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/config/configured_rule.php b/rules/renaming/tests/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/config/configured_rule.php index a873271a977e..aed3a67919af 100644 --- a/rules/renaming/tests/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/config/configured_rule.php +++ b/rules/renaming/tests/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/config/configured_rule.php @@ -1,14 +1,17 @@ services(); - $services->set(\Rector\Renaming\Rector\FileWithoutNamespace\PseudoNamespaceToNamespaceRector::class)->call( + $services->set(PseudoNamespaceToNamespaceRector::class)->call( 'configure', [[ - \Rector\Renaming\Rector\FileWithoutNamespace\PseudoNamespaceToNamespaceRector::NAMESPACE_PREFIXES_WITH_EXCLUDED_CLASSES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + PseudoNamespaceToNamespaceRector::NAMESPACE_PREFIXES_WITH_EXCLUDED_CLASSES => ValueObjectInliner::inline([ + @@ -33,11 +36,11 @@ - new \Rector\Renaming\ValueObject\PseudoNamespaceToNamespace('PHPUnit_', [ + new PseudoNamespaceToNamespace('PHPUnit_', [ 'PHPUnit_Framework_MockObject_MockObject', ]), - new \Rector\Renaming\ValueObject\PseudoNamespaceToNamespace('ChangeMe_', ['KeepMe_']), - new \Rector\Renaming\ValueObject\PseudoNamespaceToNamespace( + new PseudoNamespaceToNamespace('ChangeMe_', ['KeepMe_']), + new PseudoNamespaceToNamespace( 'Rector_Renaming_Tests_Rector_FileWithoutNamespace_PseudoNamespaceToNamespaceRector_Fixture_' ), @@ -64,7 +67,7 @@ - + ]), ]] ); diff --git a/rules/renaming/tests/Rector/FuncCall/RenameFunctionRector/config/configured_rule.php b/rules/renaming/tests/Rector/FuncCall/RenameFunctionRector/config/configured_rule.php index 1dd8ecb7730f..f087efbdde08 100644 --- a/rules/renaming/tests/Rector/FuncCall/RenameFunctionRector/config/configured_rule.php +++ b/rules/renaming/tests/Rector/FuncCall/RenameFunctionRector/config/configured_rule.php @@ -1,11 +1,12 @@ services(); - $services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[ - \Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [ + $services->set(RenameFunctionRector::class)->call('configure', [[ + RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [ 'view' => 'Laravel\Templating\render', 'sprintf' => 'Safe\sprintf', ], diff --git a/rules/renaming/tests/Rector/MethodCall/RenameMethodRector/config/configured_rule.php b/rules/renaming/tests/Rector/MethodCall/RenameMethodRector/config/configured_rule.php index 3311289415d7..e8dcd34331c0 100644 --- a/rules/renaming/tests/Rector/MethodCall/RenameMethodRector/config/configured_rule.php +++ b/rules/renaming/tests/Rector/MethodCall/RenameMethodRector/config/configured_rule.php @@ -1,30 +1,27 @@ services(); - $services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->call('configure', [[ - \Rector\Renaming\Rector\MethodCall\RenameMethodRector::METHOD_CALL_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - new \Rector\Renaming\ValueObject\MethodCallRename( - \Rector\Renaming\Tests\Rector\MethodCall\RenameMethodRector\Source\AbstractType::class, - 'setDefaultOptions', - 'configureOptions' - ), - new \Rector\Renaming\ValueObject\MethodCallRename(\Nette\Utils\Html::class, 'add', 'addHtml'), - new \Rector\Renaming\ValueObject\MethodCallRename('*Presenter', 'run', '__invoke'), - new \Rector\Renaming\ValueObject\MethodCallRename( + $services->set(RenameMethodRector::class)->call('configure', [[ + RenameMethodRector::METHOD_CALL_RENAMES => ValueObjectInliner::inline([ + new MethodCallRename(AbstractType::class, 'setDefaultOptions', 'configureOptions'), + new MethodCallRename(Html::class, 'add', 'addHtml'), + new MethodCallRename('*Presenter', 'run', '__invoke'), + new MethodCallRename( \Rector\Renaming\Tests\Rector\MethodCall\RenameMethodRector\Fixture\SkipSelfMethodRename::class, 'preventPHPStormRefactoring', 'gone' ), // with array key - new \Rector\Renaming\ValueObject\MethodCallRenameWithArrayKey( - \Nette\Utils\Html::class, - 'addToArray', - 'addToHtmlArray', - 'hey' - ), + new MethodCallRenameWithArrayKey(Html::class, 'addToArray', 'addToHtmlArray', 'hey'), ]), ]]); }; diff --git a/rules/renaming/tests/Rector/Name/RenameClassRector/config/auto_import_names.php b/rules/renaming/tests/Rector/Name/RenameClassRector/config/auto_import_names.php index 2348cb2715d5..70cd044223ac 100644 --- a/rules/renaming/tests/Rector/Name/RenameClassRector/config/auto_import_names.php +++ b/rules/renaming/tests/Rector/Name/RenameClassRector/config/auto_import_names.php @@ -3,9 +3,11 @@ declare(strict_types=1); use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector; + use Rector\Core\Configuration\Option; use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\NewClass; +use Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\OldClass; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; return static function (ContainerConfigurator $containerConfigurator): void { @@ -19,7 +21,7 @@ $services->set(RenameClassRector::class) ->call('configure', [[ RenameClassRector::OLD_TO_NEW_CLASSES => [ - \Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\OldClass::class => NewClass::class, + OldClass::class => NewClass::class, ], ]]); }; diff --git a/rules/renaming/tests/Rector/Name/RenameClassRector/config/configured_rule.php b/rules/renaming/tests/Rector/Name/RenameClassRector/config/configured_rule.php index 7702febfa6e1..46ee7cb3ac47 100644 --- a/rules/renaming/tests/Rector/Name/RenameClassRector/config/configured_rule.php +++ b/rules/renaming/tests/Rector/Name/RenameClassRector/config/configured_rule.php @@ -7,6 +7,7 @@ use Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\AbstractManualExtension; use Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\NewClass; use Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\NewClassWithoutTypo; +use Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\OldClass; use Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\OldClassWithTypo; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; @@ -17,7 +18,7 @@ ->call('configure', [[ RenameClassRector::OLD_TO_NEW_CLASSES => [ 'FqnizeNamespaced' => 'Abc\FqnizeNamespaced', - \Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\OldClass::class => NewClass::class, + OldClass::class => NewClass::class, OldClassWithTypo::class => NewClassWithoutTypo::class, 'DateTime' => 'DateTimeInterface', 'Countable' => 'stdClass', diff --git a/rules/renaming/tests/Rector/Name/RenameClassRector/config/non_php_config.php b/rules/renaming/tests/Rector/Name/RenameClassRector/config/non_php_config.php index 11f384718ffd..eea2d780a7b2 100644 --- a/rules/renaming/tests/Rector/Name/RenameClassRector/config/non_php_config.php +++ b/rules/renaming/tests/Rector/Name/RenameClassRector/config/non_php_config.php @@ -2,6 +2,7 @@ use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\NewClass; +use Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\OldClass; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; return static function (ContainerConfigurator $containerConfigurator): void { @@ -10,7 +11,7 @@ $services->set(RenameClassRector::class) ->call('configure', [[ RenameClassRector::OLD_TO_NEW_CLASSES => [ - \Rector\Renaming\Tests\Rector\Name\RenameClassRector\Source\OldClass::class => NewClass::class, + OldClass::class => NewClass::class, // Laravel 'Session' => 'Illuminate\Support\Facades\Session', 'Form' => 'Collective\Html\FormFacade', diff --git a/rules/renaming/tests/Rector/Namespace_/RenameNamespaceRector/config/configured_rule.php b/rules/renaming/tests/Rector/Namespace_/RenameNamespaceRector/config/configured_rule.php index d6cfb01c9efb..d19c4239900b 100644 --- a/rules/renaming/tests/Rector/Namespace_/RenameNamespaceRector/config/configured_rule.php +++ b/rules/renaming/tests/Rector/Namespace_/RenameNamespaceRector/config/configured_rule.php @@ -1,11 +1,12 @@ services(); - $services->set(\Rector\Renaming\Rector\Namespace_\RenameNamespaceRector::class)->call('configure', [[ - \Rector\Renaming\Rector\Namespace_\RenameNamespaceRector::OLD_TO_NEW_NAMESPACES => [ + $services->set(RenameNamespaceRector::class)->call('configure', [[ + RenameNamespaceRector::OLD_TO_NEW_NAMESPACES => [ 'OldNamespace' => 'NewNamespace', 'OldNamespaceWith\OldSplitNamespace' => 'NewNamespaceWith\NewSplitNamespace', 'Old\Long\AnyNamespace' => 'Short\AnyNamespace', diff --git a/rules/renaming/tests/Rector/PropertyFetch/RenamePropertyRector/config/configured_rule.php b/rules/renaming/tests/Rector/PropertyFetch/RenamePropertyRector/config/configured_rule.php index 513cd703e95e..48cee180a8c3 100644 --- a/rules/renaming/tests/Rector/PropertyFetch/RenamePropertyRector/config/configured_rule.php +++ b/rules/renaming/tests/Rector/PropertyFetch/RenamePropertyRector/config/configured_rule.php @@ -1,12 +1,16 @@ services(); - $services->set(\Rector\Renaming\Rector\PropertyFetch\RenamePropertyRector::class)->call('configure', [[ - \Rector\Renaming\Rector\PropertyFetch\RenamePropertyRector::RENAMED_PROPERTIES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + $services->set(RenamePropertyRector::class)->call('configure', [[ + RenamePropertyRector::RENAMED_PROPERTIES => ValueObjectInliner::inline([ + @@ -24,16 +28,13 @@ - new \Rector\Renaming\ValueObject\RenameProperty( - \Rector\Renaming\Tests\Rector\PropertyFetch\RenamePropertyRector\Source\ClassWithProperties::class, + new RenameProperty( + ClassWithProperties::class, 'oldProperty', 'newProperty' ), - new \Rector\Renaming\ValueObject\RenameProperty( - \Rector\Renaming\Tests\Rector\PropertyFetch\RenamePropertyRector\Source\ClassWithProperties::class, - 'anotherOldProperty', - 'anotherNewProperty' - ), + new RenameProperty(ClassWithProperties::class, 'anotherOldProperty', 'anotherNewProperty'), + @@ -58,7 +59,6 @@ - ]), ]]); }; diff --git a/rules/renaming/tests/Rector/StaticCall/RenameStaticMethodRector/config/configured_rule.php b/rules/renaming/tests/Rector/StaticCall/RenameStaticMethodRector/config/configured_rule.php index e2726342a428..b7837940fb13 100644 --- a/rules/renaming/tests/Rector/StaticCall/RenameStaticMethodRector/config/configured_rule.php +++ b/rules/renaming/tests/Rector/StaticCall/RenameStaticMethodRector/config/configured_rule.php @@ -1,12 +1,16 @@ services(); - $services->set(\Rector\Renaming\Rector\StaticCall\RenameStaticMethodRector::class)->call('configure', [[ - \Rector\Renaming\Rector\StaticCall\RenameStaticMethodRector::OLD_TO_NEW_METHODS_BY_CLASSES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + $services->set(RenameStaticMethodRector::class)->call('configure', [[ + RenameStaticMethodRector::OLD_TO_NEW_METHODS_BY_CLASSES => ValueObjectInliner::inline([ @@ -24,14 +28,10 @@ - new \Rector\Renaming\ValueObject\RenameStaticMethod( - \Nette\Utils\Html::class, - 'add', - \Nette\Utils\Html::class, - 'addHtml' - ), - new \Rector\Renaming\ValueObject\RenameStaticMethod( - \Rector\Renaming\Tests\Rector\StaticCall\RenameStaticMethodRector\Source\FormMacros::class, + + new RenameStaticMethod(Html::class, 'add', Html::class, 'addHtml'), + new RenameStaticMethod( + FormMacros::class, 'renderFormBegin', 'Nette\Bridges\FormsLatte\Runtime', 'renderFormBegin' @@ -60,7 +60,7 @@ - + ]), ]]); }; diff --git a/rules/renaming/tests/Rector/String_/RenameStringRector/config/configured_rule.php b/rules/renaming/tests/Rector/String_/RenameStringRector/config/configured_rule.php index 843e32fbf1cd..cfd58d64dfda 100644 --- a/rules/renaming/tests/Rector/String_/RenameStringRector/config/configured_rule.php +++ b/rules/renaming/tests/Rector/String_/RenameStringRector/config/configured_rule.php @@ -1,11 +1,12 @@ services(); - $services->set(\Rector\Renaming\Rector\String_\RenameStringRector::class)->call('configure', [[ - \Rector\Renaming\Rector\String_\RenameStringRector::STRING_CHANGES => [ + $services->set(RenameStringRector::class)->call('configure', [[ + RenameStringRector::STRING_CHANGES => [ 'ROLE_PREVIOUS_ADMIN' => 'IS_IMPERSONATOR', ], ]]); diff --git a/rules/restoration/src/Rector/Namespace_/CompleteImportForPartialAnnotationRector.php b/rules/restoration/src/Rector/Namespace_/CompleteImportForPartialAnnotationRector.php index 0900b4667824..3332efdcfa7b 100644 --- a/rules/restoration/src/Rector/Namespace_/CompleteImportForPartialAnnotationRector.php +++ b/rules/restoration/src/Rector/Namespace_/CompleteImportForPartialAnnotationRector.php @@ -114,7 +114,7 @@ public function configure(array $configuration): void private function addImportToNamespaceIfMissing( Namespace_ $namespace, - CompleteImportForPartialAnnotation $useWithAlias + CompleteImportForPartialAnnotation $completeImportForPartialAnnotation ): Namespace_ { foreach ($namespace->stmts as $stmt) { if (! $stmt instanceof Use_) { @@ -126,22 +126,22 @@ private function addImportToNamespaceIfMissing( // already there if ($this->isName( $useUse->name, - $useWithAlias->getUse() - ) && (string) $useUse->alias === $useWithAlias->getAlias()) { + $completeImportForPartialAnnotation->getUse() + ) && (string) $useUse->alias === $completeImportForPartialAnnotation->getAlias()) { return $namespace; } } - return $this->addImportToNamespace($namespace, $useWithAlias); + return $this->addImportToNamespace($namespace, $completeImportForPartialAnnotation); } private function addImportToNamespace( Namespace_ $namespace, - CompleteImportForPartialAnnotation $useWithAlias + CompleteImportForPartialAnnotation $completeImportForPartialAnnotation ): Namespace_ { - $useBuilder = new UseBuilder($useWithAlias->getUse()); - if ($useWithAlias->getAlias() !== '') { - $useBuilder->as($useWithAlias->getAlias()); + $useBuilder = new UseBuilder($completeImportForPartialAnnotation->getUse()); + if ($completeImportForPartialAnnotation->getAlias() !== '') { + $useBuilder->as($completeImportForPartialAnnotation->getAlias()); } /** @var Stmt $use */ diff --git a/rules/restoration/tests/Rector/New_/CompleteMissingDependencyInNewRector/config/configured_rule.php b/rules/restoration/tests/Rector/New_/CompleteMissingDependencyInNewRector/config/configured_rule.php index 36776ac4b3a3..9b15f5b0ff92 100644 --- a/rules/restoration/tests/Rector/New_/CompleteMissingDependencyInNewRector/config/configured_rule.php +++ b/rules/restoration/tests/Rector/New_/CompleteMissingDependencyInNewRector/config/configured_rule.php @@ -1,12 +1,14 @@ services(); - $services->set(\Rector\Restoration\Rector\New_\CompleteMissingDependencyInNewRector::class)->call('configure', [[ - \Rector\Restoration\Rector\New_\CompleteMissingDependencyInNewRector::CLASS_TO_INSTANTIATE_BY_TYPE => [ - \Rector\Restoration\Tests\Rector\New_\CompleteMissingDependencyInNewRector\Source\RandomDependency::class => \Rector\Restoration\Tests\Rector\New_\CompleteMissingDependencyInNewRector\Source\RandomDependency::class, + $services->set(CompleteMissingDependencyInNewRector::class)->call('configure', [[ + CompleteMissingDependencyInNewRector::CLASS_TO_INSTANTIATE_BY_TYPE => [ + RandomDependency::class => RandomDependency::class, ], ]]); }; diff --git a/rules/symfony/tests/Rector/MethodCall/GetToConstructorInjectionRector/config/configured_rule.php b/rules/symfony/tests/Rector/MethodCall/GetToConstructorInjectionRector/config/configured_rule.php index 78931038b8b9..5eb5054e202d 100644 --- a/rules/symfony/tests/Rector/MethodCall/GetToConstructorInjectionRector/config/configured_rule.php +++ b/rules/symfony/tests/Rector/MethodCall/GetToConstructorInjectionRector/config/configured_rule.php @@ -1,18 +1,17 @@ parameters(); $parameters->set(Option::SYMFONY_CONTAINER_XML_PATH_PARAMETER, __DIR__ . '/../xml/services.xml'); $services = $containerConfigurator->services(); - $services->set(\Rector\Symfony\Rector\MethodCall\GetToConstructorInjectionRector::class)->call('configure', [[ - \Rector\Symfony\Rector\MethodCall\GetToConstructorInjectionRector::GET_METHOD_AWARE_TYPES => [ - \Rector\Symfony\Tests\Rector\Source\SymfonyController::class, - \Rector\Symfony\Tests\Rector\MethodCall\GetToConstructorInjectionRector\Source\GetTrait::class, - ], + $services->set(GetToConstructorInjectionRector::class)->call('configure', [[ + GetToConstructorInjectionRector::GET_METHOD_AWARE_TYPES => [SymfonyController::class, GetTrait::class], ]]); }; diff --git a/rules/transform/src/Rector/Isset_/UnsetAndIssetToMethodCallRector.php b/rules/transform/src/Rector/Isset_/UnsetAndIssetToMethodCallRector.php index 6ef79c7e0495..e5e497f1fd9b 100644 --- a/rules/transform/src/Rector/Isset_/UnsetAndIssetToMethodCallRector.php +++ b/rules/transform/src/Rector/Isset_/UnsetAndIssetToMethodCallRector.php @@ -32,7 +32,7 @@ final class UnsetAndIssetToMethodCallRector extends AbstractRector implements Co public function getRuleDefinition(): RuleDefinition { - $issetUnsetToMethodCall = new UnsetAndIssetToMethodCall('SomeContainer', 'hasService', 'removeService'); + $unsetAndIssetToMethodCall = new UnsetAndIssetToMethodCall('SomeContainer', 'hasService', 'removeService'); return new RuleDefinition('Turns defined `__isset`/`__unset` calls to specific method calls.', [ new ConfiguredCodeSample( @@ -47,7 +47,7 @@ public function getRuleDefinition(): RuleDefinition CODE_SAMPLE , [ - self::ISSET_UNSET_TO_METHOD_CALL => [$issetUnsetToMethodCall], + self::ISSET_UNSET_TO_METHOD_CALL => [$unsetAndIssetToMethodCall], ] ), new ConfiguredCodeSample( @@ -62,7 +62,7 @@ public function getRuleDefinition(): RuleDefinition CODE_SAMPLE , [ - self::ISSET_UNSET_TO_METHOD_CALL => [$issetUnsetToMethodCall], + self::ISSET_UNSET_TO_METHOD_CALL => [$unsetAndIssetToMethodCall], ] ), ]); @@ -112,28 +112,28 @@ public function configure(array $configuration): void private function processArrayDimFetchNode( Node $node, ArrayDimFetch $arrayDimFetch, - UnsetAndIssetToMethodCall $issetUnsetToMethodCall + UnsetAndIssetToMethodCall $unsetAndIssetToMethodCall ): ?Node { if ($node instanceof Isset_) { - if ($issetUnsetToMethodCall->getIssetMethodCall() === '') { + if ($unsetAndIssetToMethodCall->getIssetMethodCall() === '') { return null; } return $this->nodeFactory->createMethodCall( $arrayDimFetch->var, - $issetUnsetToMethodCall->getIssetMethodCall(), + $unsetAndIssetToMethodCall->getIssetMethodCall(), [$arrayDimFetch->dim] ); } if ($node instanceof Unset_) { - if ($issetUnsetToMethodCall->getUnsedMethodCall() === '') { + if ($unsetAndIssetToMethodCall->getUnsedMethodCall() === '') { return null; } return $this->nodeFactory->createMethodCall( $arrayDimFetch->var, - $issetUnsetToMethodCall->getUnsedMethodCall(), + $unsetAndIssetToMethodCall->getUnsedMethodCall(), [$arrayDimFetch->dim] ); } diff --git a/rules/transform/tests/Rector/Assign/DimFetchAssignToMethodCallRector/config/configured_rule.php b/rules/transform/tests/Rector/Assign/DimFetchAssignToMethodCallRector/config/configured_rule.php index c1cb1823d577..839474059226 100644 --- a/rules/transform/tests/Rector/Assign/DimFetchAssignToMethodCallRector/config/configured_rule.php +++ b/rules/transform/tests/Rector/Assign/DimFetchAssignToMethodCallRector/config/configured_rule.php @@ -1,12 +1,15 @@ services(); - $services->set(\Rector\Transform\Rector\Assign\DimFetchAssignToMethodCallRector::class)->call('configure', [[ - \Rector\Transform\Rector\Assign\DimFetchAssignToMethodCallRector::DIM_FETCH_ASSIGN_TO_METHOD_CALL => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + $services->set(DimFetchAssignToMethodCallRector::class)->call('configure', [[ + DimFetchAssignToMethodCallRector::DIM_FETCH_ASSIGN_TO_METHOD_CALL => ValueObjectInliner::inline([ + @@ -24,7 +27,7 @@ - new \Rector\Transform\ValueObject\DimFetchAssignToMethodCall( + new DimFetchAssignToMethodCall( 'Nette\Application\Routers\RouteList', 'Nette\Application\Routers\Route', 'addRoute' @@ -53,7 +56,7 @@ - + ]), ]]); }; diff --git a/rules/transform/tests/Rector/Assign/GetAndSetToMethodCallRector/config/configured_rule.php b/rules/transform/tests/Rector/Assign/GetAndSetToMethodCallRector/config/configured_rule.php index dd1e1ed4a5c3..67e9e2f0734c 100644 --- a/rules/transform/tests/Rector/Assign/GetAndSetToMethodCallRector/config/configured_rule.php +++ b/rules/transform/tests/Rector/Assign/GetAndSetToMethodCallRector/config/configured_rule.php @@ -1,16 +1,19 @@ services(); - $services->set(\Rector\Transform\Rector\Assign\GetAndSetToMethodCallRector::class)->call('configure', [[ - \Rector\Transform\Rector\Assign\GetAndSetToMethodCallRector::TYPE_TO_METHOD_CALLS => [ - \Rector\Transform\Tests\Rector\Assign\GetAndSetToMethodCallRector\Source\SomeContainer::class => [ + $services->set(GetAndSetToMethodCallRector::class)->call('configure', [[ + GetAndSetToMethodCallRector::TYPE_TO_METHOD_CALLS => [ + SomeContainer::class => [ 'get' => 'getService', 'set' => 'addService', ], - \Rector\Transform\Tests\Rector\Assign\GetAndSetToMethodCallRector\Source\Klarka::class => [ + Klarka::class => [ 'get' => 'get', ], ], diff --git a/rules/transform/tests/Rector/Assign/PropertyAssignToMethodCallRector/config/configured_rule.php b/rules/transform/tests/Rector/Assign/PropertyAssignToMethodCallRector/config/configured_rule.php index 62a7453845eb..5dd0528b410e 100644 --- a/rules/transform/tests/Rector/Assign/PropertyAssignToMethodCallRector/config/configured_rule.php +++ b/rules/transform/tests/Rector/Assign/PropertyAssignToMethodCallRector/config/configured_rule.php @@ -1,12 +1,16 @@ services(); - $services->set(\Rector\Transform\Rector\Assign\PropertyAssignToMethodCallRector::class)->call('configure', [[ - \Rector\Transform\Rector\Assign\PropertyAssignToMethodCallRector::PROPERTY_ASSIGNS_TO_METHODS_CALLS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + $services->set(PropertyAssignToMethodCallRector::class)->call('configure', [[ + PropertyAssignToMethodCallRector::PROPERTY_ASSIGNS_TO_METHODS_CALLS => ValueObjectInliner::inline([ + @@ -24,8 +28,8 @@ - new \Rector\Transform\ValueObject\PropertyAssignToMethodCall( - \Rector\Transform\Tests\Rector\Assign\PropertyAssignToMethodCallRector\Source\ChoiceControl::class, + new PropertyAssignToMethodCall( + ChoiceControl::class, 'checkAllowedValues', 'checkDefaultValue' ), @@ -53,7 +57,7 @@ - + ]), ]]); }; diff --git a/rules/transform/tests/Rector/Assign/PropertyFetchToMethodCallRector/config/configured_rule.php b/rules/transform/tests/Rector/Assign/PropertyFetchToMethodCallRector/config/configured_rule.php index 695d2e1939ca..6c57d0e37715 100644 --- a/rules/transform/tests/Rector/Assign/PropertyFetchToMethodCallRector/config/configured_rule.php +++ b/rules/transform/tests/Rector/Assign/PropertyFetchToMethodCallRector/config/configured_rule.php @@ -1,12 +1,16 @@ services(); - $services->set(\Rector\Transform\Rector\Assign\PropertyFetchToMethodCallRector::class)->call('configure', [[ - \Rector\Transform\Rector\Assign\PropertyFetchToMethodCallRector::PROPERTIES_TO_METHOD_CALLS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + $services->set(PropertyFetchToMethodCallRector::class)->call('configure', [[ + PropertyFetchToMethodCallRector::PROPERTIES_TO_METHOD_CALLS => ValueObjectInliner::inline([ + @@ -24,13 +28,13 @@ - new \Rector\Transform\ValueObject\PropertyFetchToMethodCall( - \Rector\Transform\Tests\Rector\Assign\PropertyFetchToMethodCallRector\Source\Translator::class, + new PropertyFetchToMethodCall( + Translator::class, 'locale', 'getLocale', 'setLocale' ), - new \Rector\Transform\ValueObject\PropertyFetchToMethodCall( + new PropertyFetchToMethodCall( 'Rector\Transform\Tests\Rector\Assign\PropertyFetchToMethodCallRector\Fixture\Fixture2', 'parameter', 'getConfig', diff --git a/rules/transform/tests/Rector/Class_/ParentClassToTraitsRector/config/configured_rule.php b/rules/transform/tests/Rector/Class_/ParentClassToTraitsRector/config/configured_rule.php index f3fc99c77815..da7f38d49456 100644 --- a/rules/transform/tests/Rector/Class_/ParentClassToTraitsRector/config/configured_rule.php +++ b/rules/transform/tests/Rector/Class_/ParentClassToTraitsRector/config/configured_rule.php @@ -1,12 +1,18 @@ services(); - $services->set(\Rector\Transform\Rector\Class_\ParentClassToTraitsRector::class)->call('configure', [[ - \Rector\Transform\Rector\Class_\ParentClassToTraitsRector::PARENT_CLASS_TO_TRAITS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + $services->set(ParentClassToTraitsRector::class)->call('configure', [[ + ParentClassToTraitsRector::PARENT_CLASS_TO_TRAITS => ValueObjectInliner::inline([ @@ -24,16 +30,9 @@ - new \Rector\Transform\ValueObject\ParentClassToTraits( - \Rector\Transform\Tests\Rector\Class_\ParentClassToTraitsRector\Source\ParentObject::class, - [\Rector\Transform\Tests\Rector\Class_\ParentClassToTraitsRector\Source\SomeTrait::class]), - new \Rector\Transform\ValueObject\ParentClassToTraits( - \Rector\Transform\Tests\Rector\Class_\ParentClassToTraitsRector\Source\AnotherParentObject::class, - [ - \Rector\Transform\Tests\Rector\Class_\ParentClassToTraitsRector\Source\SomeTrait::class, - \Rector\Transform\Tests\Rector\Class_\ParentClassToTraitsRector\Source\SecondTrait::class, - ]), + new ParentClassToTraits(ParentObject::class, [SomeTrait::class]), + new ParentClassToTraits(AnotherParentObject::class, [SomeTrait::class, SecondTrait::class]), ] ), ]]); diff --git a/rules/transform/tests/Rector/Expression/MethodCallToReturnRector/config/configured_rule.php b/rules/transform/tests/Rector/Expression/MethodCallToReturnRector/config/configured_rule.php index 3ece9443df45..ee5e34433e30 100644 --- a/rules/transform/tests/Rector/Expression/MethodCallToReturnRector/config/configured_rule.php +++ b/rules/transform/tests/Rector/Expression/MethodCallToReturnRector/config/configured_rule.php @@ -1,12 +1,17 @@ services(); - $services->set(\Rector\Transform\Rector\Expression\MethodCallToReturnRector::class)->call('configure', [[ - \Rector\Transform\Rector\Expression\MethodCallToReturnRector::METHOD_CALL_WRAPS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + $services->set(MethodCallToReturnRector::class)->call('configure', [[ + MethodCallToReturnRector::METHOD_CALL_WRAPS => ValueObjectInliner::inline([ + + @@ -23,11 +28,8 @@ + new MethodCallToReturn(ReturnDeny::class, 'deny'), - new \Rector\Transform\ValueObject\MethodCallToReturn( - \Rector\Transform\Tests\Rector\Expression\MethodCallToReturnRector\Source\ReturnDeny::class, - 'deny' - ), @@ -52,7 +54,6 @@ - ]), ]]); }; diff --git a/rules/transform/tests/Rector/FuncCall/FuncCallToNewRector/config/configured_rule.php b/rules/transform/tests/Rector/FuncCall/FuncCallToNewRector/config/configured_rule.php index d720003f3859..995bfdbf00a1 100644 --- a/rules/transform/tests/Rector/FuncCall/FuncCallToNewRector/config/configured_rule.php +++ b/rules/transform/tests/Rector/FuncCall/FuncCallToNewRector/config/configured_rule.php @@ -1,11 +1,12 @@ services(); - $services->set(\Rector\Transform\Rector\FuncCall\FuncCallToNewRector::class)->call('configure', [[ - \Rector\Transform\Rector\FuncCall\FuncCallToNewRector::FUNCTIONS_TO_NEWS => [ + $services->set(FuncCallToNewRector::class)->call('configure', [[ + FuncCallToNewRector::FUNCTIONS_TO_NEWS => [ 'collection' => ['Collection'], ], ]]); diff --git a/rules/transform/tests/Rector/FuncCall/FuncCallToStaticCallRector/config/configured_rule.php b/rules/transform/tests/Rector/FuncCall/FuncCallToStaticCallRector/config/configured_rule.php index 3113b85a9539..a534f709bfc3 100644 --- a/rules/transform/tests/Rector/FuncCall/FuncCallToStaticCallRector/config/configured_rule.php +++ b/rules/transform/tests/Rector/FuncCall/FuncCallToStaticCallRector/config/configured_rule.php @@ -1,12 +1,16 @@ services(); - $services->set(\Rector\Transform\Rector\FuncCall\FuncCallToStaticCallRector::class)->call('configure', [[ - \Rector\Transform\Rector\FuncCall\FuncCallToStaticCallRector::FUNC_CALLS_TO_STATIC_CALLS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + $services->set(FuncCallToStaticCallRector::class)->call('configure', [[ + FuncCallToStaticCallRector::FUNC_CALLS_TO_STATIC_CALLS => ValueObjectInliner::inline([ + + @@ -23,13 +27,9 @@ + new FuncCallToStaticCall('view', 'SomeStaticClass', 'render'), + new FuncCallToStaticCall('SomeNamespaced\view', 'AnotherStaticClass', 'render'), - new \Rector\Transform\ValueObject\FuncCallToStaticCall('view', 'SomeStaticClass', 'render'), - new \Rector\Transform\ValueObject\FuncCallToStaticCall( - 'SomeNamespaced\view', - 'AnotherStaticClass', - 'render' - ), @@ -54,7 +54,6 @@ - ]), ]]); }; diff --git a/rules/transform/tests/Rector/Isset_/UnsetAndIssetToMethodCallRector/config/configured_rule.php b/rules/transform/tests/Rector/Isset_/UnsetAndIssetToMethodCallRector/config/configured_rule.php index 47dfcb600973..8e8d3d1bebf9 100644 --- a/rules/transform/tests/Rector/Isset_/UnsetAndIssetToMethodCallRector/config/configured_rule.php +++ b/rules/transform/tests/Rector/Isset_/UnsetAndIssetToMethodCallRector/config/configured_rule.php @@ -3,18 +3,18 @@ use Rector\Transform\Rector\Isset_\UnsetAndIssetToMethodCallRector; use Rector\Transform\Tests\Rector\Isset_\UnsetAndIssetToMethodCallRector\Source\LocalContainer; use Rector\Transform\ValueObject\UnsetAndIssetToMethodCall; +use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use Symplify\SymfonyPhpConfig\ValueObjectInliner; -return static function ( - \Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator -): void { +return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(UnsetAndIssetToMethodCallRector::class)->call('configure', [[ - UnsetAndIssetToMethodCallRector::ISSET_UNSET_TO_METHOD_CALL => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + UnsetAndIssetToMethodCallRector::ISSET_UNSET_TO_METHOD_CALL => ValueObjectInliner::inline([ + new UnsetAndIssetToMethodCall(LocalContainer::class, 'hasService', 'removeService'), - + ]), ]]); }; diff --git a/rules/transform/tests/Rector/MethodCall/CallableInMethodCallToVariableRector/config/configured_rule.php b/rules/transform/tests/Rector/MethodCall/CallableInMethodCallToVariableRector/config/configured_rule.php index 17f052d9ca25..70c4f6919bba 100644 --- a/rules/transform/tests/Rector/MethodCall/CallableInMethodCallToVariableRector/config/configured_rule.php +++ b/rules/transform/tests/Rector/MethodCall/CallableInMethodCallToVariableRector/config/configured_rule.php @@ -1,14 +1,18 @@ services(); - $services->set(\Rector\Transform\Rector\MethodCall\CallableInMethodCallToVariableRector::class)->call( + $services->set(CallableInMethodCallToVariableRector::class)->call( 'configure', [[ - \Rector\Transform\Rector\MethodCall\CallableInMethodCallToVariableRector::CALLABLE_IN_METHOD_CALL_TO_VARIABLE => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + CallableInMethodCallToVariableRector::CALLABLE_IN_METHOD_CALL_TO_VARIABLE => ValueObjectInliner::inline([ + @@ -33,8 +37,8 @@ - new \Rector\Transform\ValueObject\CallableInMethodCallToVariable( - \Rector\Transform\Tests\Rector\MethodCall\CallableInMethodCallToVariableRector\Source\DummyCache::class, + new CallableInMethodCallToVariable( + DummyCache::class, 'save', 1 ), @@ -62,7 +66,7 @@ - + ]), ]] ); diff --git a/rules/transform/tests/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector/config/configured_rule.php b/rules/transform/tests/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector/config/configured_rule.php index 3f99f3cc3595..c58a8f12d62c 100644 --- a/rules/transform/tests/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector/config/configured_rule.php +++ b/rules/transform/tests/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector/config/configured_rule.php @@ -1,13 +1,17 @@ services(); - $services->set(\Rector\Transform\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector::class)->call( + $services->set(MethodCallToAnotherMethodCallWithArgumentsRector::class)->call( 'configure', [[ - \Rector\Transform\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector::METHOD_CALL_RENAMES_WITH_ADDED_ARGUMENTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + MethodCallToAnotherMethodCallWithArgumentsRector::METHOD_CALL_RENAMES_WITH_ADDED_ARGUMENTS => ValueObjectInliner::inline([ @@ -33,8 +37,9 @@ - new \Rector\Transform\ValueObject\MethodCallToAnotherMethodCallWithArguments( - \Rector\Transform\Tests\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector\Source\NetteServiceDefinition::class, + + new MethodCallToAnotherMethodCallWithArguments( + NetteServiceDefinition::class, 'setInject', 'addTag', ['inject']), diff --git a/rules/transform/tests/Rector/MethodCall/MethodCallToPropertyFetchRector/config/configured_rule.php b/rules/transform/tests/Rector/MethodCall/MethodCallToPropertyFetchRector/config/configured_rule.php index 3f974faf4454..8e5f4b1fd9fa 100644 --- a/rules/transform/tests/Rector/MethodCall/MethodCallToPropertyFetchRector/config/configured_rule.php +++ b/rules/transform/tests/Rector/MethodCall/MethodCallToPropertyFetchRector/config/configured_rule.php @@ -1,11 +1,12 @@ services(); - $services->set(\Rector\Transform\Rector\MethodCall\MethodCallToPropertyFetchRector::class)->call('configure', [[ - \Rector\Transform\Rector\MethodCall\MethodCallToPropertyFetchRector::METHOD_CALL_TO_PROPERTY_FETCHES => [ + $services->set(MethodCallToPropertyFetchRector::class)->call('configure', [[ + MethodCallToPropertyFetchRector::METHOD_CALL_TO_PROPERTY_FETCHES => [ 'getEntityManager' => 'entityManager', ], ]]); diff --git a/rules/transform/tests/Rector/MethodCall/MethodCallToStaticCallRector/config/configured_rule.php b/rules/transform/tests/Rector/MethodCall/MethodCallToStaticCallRector/config/configured_rule.php index 5f076b81be8d..61893f1a9b84 100644 --- a/rules/transform/tests/Rector/MethodCall/MethodCallToStaticCallRector/config/configured_rule.php +++ b/rules/transform/tests/Rector/MethodCall/MethodCallToStaticCallRector/config/configured_rule.php @@ -1,12 +1,16 @@ services(); - $services->set(\Rector\Transform\Rector\MethodCall\MethodCallToStaticCallRector::class)->call('configure', [[ - \Rector\Transform\Rector\MethodCall\MethodCallToStaticCallRector::METHOD_CALLS_TO_STATIC_CALLS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + $services->set(MethodCallToStaticCallRector::class)->call('configure', [[ + MethodCallToStaticCallRector::METHOD_CALLS_TO_STATIC_CALLS => ValueObjectInliner::inline([ + @@ -24,8 +28,8 @@ - new \Rector\Transform\ValueObject\MethodCallToStaticCall( - \Rector\Transform\Tests\Rector\MethodCall\MethodCallToStaticCallRector\Source\AnotherDependency::class, + new MethodCallToStaticCall( + AnotherDependency::class, 'process', 'StaticCaller', 'anotherMethod' @@ -54,7 +58,7 @@ - + ]), ]]); }; diff --git a/rules/transform/tests/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/config/configured_rule.php b/rules/transform/tests/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/config/configured_rule.php index 18037d34255f..a01515dccef7 100644 --- a/rules/transform/tests/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/config/configured_rule.php +++ b/rules/transform/tests/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/config/configured_rule.php @@ -1,14 +1,18 @@ services(); - $services->set(\Rector\Transform\Rector\MethodCall\ReplaceParentCallByPropertyCallRector::class)->call( + $services->set(ReplaceParentCallByPropertyCallRector::class)->call( 'configure', [[ - \Rector\Transform\Rector\MethodCall\ReplaceParentCallByPropertyCallRector::PARENT_CALLS_TO_PROPERTIES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + ReplaceParentCallByPropertyCallRector::PARENT_CALLS_TO_PROPERTIES => ValueObjectInliner::inline([ + @@ -33,8 +37,8 @@ - new \Rector\Transform\ValueObject\ReplaceParentCallByPropertyCall( - \Rector\Transform\Tests\Rector\MethodCall\ReplaceParentCallByPropertyCallRector\Source\TypeClassToReplaceMethodCallBy::class, + new ReplaceParentCallByPropertyCall( + TypeClassToReplaceMethodCallBy::class, 'someMethod', 'someProperty' ), @@ -62,7 +66,7 @@ - + ]), ]] ); diff --git a/rules/transform/tests/Rector/MethodCall/ServiceGetterToConstructorInjectionRector/config/configured_rule.php b/rules/transform/tests/Rector/MethodCall/ServiceGetterToConstructorInjectionRector/config/configured_rule.php index 63358b094959..5a81752ebab9 100644 --- a/rules/transform/tests/Rector/MethodCall/ServiceGetterToConstructorInjectionRector/config/configured_rule.php +++ b/rules/transform/tests/Rector/MethodCall/ServiceGetterToConstructorInjectionRector/config/configured_rule.php @@ -1,14 +1,18 @@ services(); - $services->set(\Rector\Transform\Rector\MethodCall\ServiceGetterToConstructorInjectionRector::class)->call( + $services->set(ServiceGetterToConstructorInjectionRector::class)->call( 'configure', [[ - \Rector\Transform\Rector\MethodCall\ServiceGetterToConstructorInjectionRector::METHOD_CALL_TO_SERVICES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + ServiceGetterToConstructorInjectionRector::METHOD_CALL_TO_SERVICES => ValueObjectInliner::inline([ @@ -33,10 +37,11 @@ - new \Rector\Transform\ValueObject\ServiceGetterToConstructorInjection( - \Rector\Transform\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Source\FirstService::class, + + new ServiceGetterToConstructorInjection( + FirstService::class, 'getAnotherService', - \Rector\Transform\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Source\AnotherService::class + AnotherService::class ), @@ -62,7 +67,7 @@ - + ]), ]] ); diff --git a/rules/transform/tests/Rector/MethodCall/VariableMethodCallToServiceCallRector/config/configured_rule.php b/rules/transform/tests/Rector/MethodCall/VariableMethodCallToServiceCallRector/config/configured_rule.php index e11ad98349b0..b0344740a3c4 100644 --- a/rules/transform/tests/Rector/MethodCall/VariableMethodCallToServiceCallRector/config/configured_rule.php +++ b/rules/transform/tests/Rector/MethodCall/VariableMethodCallToServiceCallRector/config/configured_rule.php @@ -1,13 +1,16 @@ services(); - $services->set(\Rector\Transform\Rector\MethodCall\VariableMethodCallToServiceCallRector::class)->call( + $services->set(VariableMethodCallToServiceCallRector::class)->call( 'configure', [[ - \Rector\Transform\Rector\MethodCall\VariableMethodCallToServiceCallRector::VARIABLE_METHOD_CALLS_TO_SERVICE_CALLS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ + VariableMethodCallToServiceCallRector::VARIABLE_METHOD_CALLS_TO_SERVICE_CALLS => ValueObjectInliner::inline([ @@ -33,7 +36,8 @@ - new \Rector\Transform\ValueObject\VariableMethodCallToServiceCall( + + new VariableMethodCallToServiceCall( 'PhpParser\Node', 'getAttribute', 'php_doc_info', @@ -62,6 +66,7 @@ + diff --git a/rules/transform/tests/Rector/New_/NewToConstructorInjectionRector/config/configured_rule.php b/rules/transform/tests/Rector/New_/NewToConstructorInjectionRector/config/configured_rule.php index 458a283e6d90..7f08ca278fad 100644 --- a/rules/transform/tests/Rector/New_/NewToConstructorInjectionRector/config/configured_rule.php +++ b/rules/transform/tests/Rector/New_/NewToConstructorInjectionRector/config/configured_rule.php @@ -1,12 +1,12 @@ services(); - $services->set(\Rector\Transform\Rector\New_\NewToConstructorInjectionRector::class)->call('configure', [[ - \Rector\Transform\Rector\New_\NewToConstructorInjectionRector::TYPES_TO_CONSTRUCTOR_INJECTION => [ - \Rector\Transform\Tests\Rector\New_\NewToConstructorInjectionRector\Source\DummyValidator::class, - ], + $services->set(NewToConstructorInjectionRector::class)->call('configure', [[ + NewToConstructorInjectionRector::TYPES_TO_CONSTRUCTOR_INJECTION => [DummyValidator::class], ]]); }; diff --git a/rules/transform/tests/Rector/New_/NewToMethodCallRector/config/configured_rule.php b/rules/transform/tests/Rector/New_/NewToMethodCallRector/config/configured_rule.php index 0b05c379297f..bcf9abc48500 100644 --- a/rules/transform/tests/Rector/New_/NewToMethodCallRector/config/configured_rule.php +++ b/rules/transform/tests/Rector/New_/NewToMethodCallRector/config/configured_rule.php @@ -1,12 +1,16 @@ services(); - $services->set(\Rector\Transform\Rector\New_\NewToMethodCallRector::class)->call('configure', [[ - \Rector\Transform\Rector\New_\NewToMethodCallRector::NEWS_TO_METHOD_CALLS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + $services->set(NewToMethodCallRector::class)->call('configure', [[ + NewToMethodCallRector::NEWS_TO_METHOD_CALLS => ValueObjectInliner::inline([ @@ -24,11 +28,9 @@ - new \Rector\Transform\ValueObject\NewToMethodCall( - \Rector\Transform\Tests\Rector\New_\NewToMethodCallRector\Source\MyClass::class, - \Rector\Transform\Tests\Rector\New_\NewToMethodCallRector\Source\MyClassFactory::class, - 'create' - ), + + new NewToMethodCall(MyClass::class, MyClassFactory::class, 'create'), + @@ -53,7 +55,6 @@ - ]), ]]); }; diff --git a/rules/transform/tests/Rector/New_/NewToStaticCallRector/config/configured_rule.php b/rules/transform/tests/Rector/New_/NewToStaticCallRector/config/configured_rule.php index 0f146914a306..b775113c6bc3 100644 --- a/rules/transform/tests/Rector/New_/NewToStaticCallRector/config/configured_rule.php +++ b/rules/transform/tests/Rector/New_/NewToStaticCallRector/config/configured_rule.php @@ -1,12 +1,16 @@ services(); - $services->set(\Rector\Transform\Rector\New_\NewToStaticCallRector::class)->call('configure', [[ - \Rector\Transform\Rector\New_\NewToStaticCallRector::TYPE_TO_STATIC_CALLS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + $services->set(NewToStaticCallRector::class)->call('configure', [[ + NewToStaticCallRector::TYPE_TO_STATIC_CALLS => ValueObjectInliner::inline([ @@ -24,11 +28,9 @@ - new \Rector\Transform\ValueObject\NewToStaticCall( - \Rector\Transform\Tests\Rector\New_\NewToStaticCallRector\Source\FromNewClass::class, - \Rector\Transform\Tests\Rector\New_\NewToStaticCallRector\Source\IntoStaticClass::class, - 'run' - ), + + new NewToStaticCall(FromNewClass::class, IntoStaticClass::class, 'run'), + @@ -53,7 +55,6 @@ - ]), ]]); }; diff --git a/rules/transform/tests/Rector/StaticCall/StaticCallToFuncCallRector/config/configured_rule.php b/rules/transform/tests/Rector/StaticCall/StaticCallToFuncCallRector/config/configured_rule.php index 499a076b38db..b12888484fb8 100644 --- a/rules/transform/tests/Rector/StaticCall/StaticCallToFuncCallRector/config/configured_rule.php +++ b/rules/transform/tests/Rector/StaticCall/StaticCallToFuncCallRector/config/configured_rule.php @@ -1,12 +1,17 @@ services(); - $services->set(\Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector::class)->call('configure', [[ - \Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector::STATIC_CALLS_TO_FUNCTIONS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + $services->set(StaticCallToFuncCallRector::class)->call('configure', [[ + StaticCallToFuncCallRector::STATIC_CALLS_TO_FUNCTIONS => ValueObjectInliner::inline([ + + @@ -23,12 +28,8 @@ + new StaticCallToFuncCall(SomeOldStaticClass::class, 'render', 'view'), - new \Rector\Transform\ValueObject\StaticCallToFuncCall( - \Rector\Transform\Tests\Rector\StaticCall\StaticCallToFuncCallRector\Source\SomeOldStaticClass::class, - 'render', - 'view' - ), @@ -53,7 +54,6 @@ - ]), ]]); }; diff --git a/rules/transform/tests/Rector/StaticCall/StaticCallToNewRector/config/configured_rule.php b/rules/transform/tests/Rector/StaticCall/StaticCallToNewRector/config/configured_rule.php index d90fa8ffbe86..831fbc403758 100644 --- a/rules/transform/tests/Rector/StaticCall/StaticCallToNewRector/config/configured_rule.php +++ b/rules/transform/tests/Rector/StaticCall/StaticCallToNewRector/config/configured_rule.php @@ -1,12 +1,17 @@ services(); - $services->set(\Rector\Transform\Rector\StaticCall\StaticCallToNewRector::class)->call('configure', [[ - \Rector\Transform\Rector\StaticCall\StaticCallToNewRector::STATIC_CALLS_TO_NEWS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + $services->set(StaticCallToNewRector::class)->call('configure', [[ + StaticCallToNewRector::STATIC_CALLS_TO_NEWS => ValueObjectInliner::inline([ + + @@ -23,11 +28,8 @@ + new StaticCallToNew(SomeJsonResponse::class, 'create'), - new \Rector\Transform\ValueObject\StaticCallToNew( - \Rector\Transform\Tests\Rector\StaticCall\StaticCallToNewRector\Source\SomeJsonResponse::class, - 'create' - ), @@ -52,7 +54,6 @@ - ]), ]]); }; diff --git a/rules/transform/tests/Rector/String_/StringToClassConstantRector/config/configured_rule.php b/rules/transform/tests/Rector/String_/StringToClassConstantRector/config/configured_rule.php index 1ae7b5ece1c9..e8e477e83299 100644 --- a/rules/transform/tests/Rector/String_/StringToClassConstantRector/config/configured_rule.php +++ b/rules/transform/tests/Rector/String_/StringToClassConstantRector/config/configured_rule.php @@ -1,12 +1,15 @@ services(); - $services->set(\Rector\Transform\Rector\String_\StringToClassConstantRector::class)->call('configure', [[ - \Rector\Transform\Rector\String_\StringToClassConstantRector::STRINGS_TO_CLASS_CONSTANTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + $services->set(StringToClassConstantRector::class)->call('configure', [[ + StringToClassConstantRector::STRINGS_TO_CLASS_CONSTANTS => ValueObjectInliner::inline([ + @@ -24,12 +27,13 @@ - new \Rector\Transform\ValueObject\StringToClassConstant( + new StringToClassConstant( 'compiler.post_dump', 'Yet\AnotherClass', 'CONSTANT' ), - new \Rector\Transform\ValueObject\StringToClassConstant('compiler.to_class', 'Yet\AnotherClass', 'class'), + new StringToClassConstant('compiler.to_class', 'Yet\AnotherClass', 'class'), + @@ -54,7 +58,6 @@ - ]), ]]); }; diff --git a/rules/transform/tests/Rector/String_/ToStringToMethodCallRector/config/configured_rule.php b/rules/transform/tests/Rector/String_/ToStringToMethodCallRector/config/configured_rule.php index ef81924a561b..74f91dd1ad5e 100644 --- a/rules/transform/tests/Rector/String_/ToStringToMethodCallRector/config/configured_rule.php +++ b/rules/transform/tests/Rector/String_/ToStringToMethodCallRector/config/configured_rule.php @@ -1,12 +1,14 @@ services(); - $services->set(\Rector\Transform\Rector\String_\ToStringToMethodCallRector::class)->call('configure', [[ - \Rector\Transform\Rector\String_\ToStringToMethodCallRector::METHOD_NAMES_BY_TYPE => [ - \Symfony\Component\Config\ConfigCache::class => 'getPath', + $services->set(ToStringToMethodCallRector::class)->call('configure', [[ + ToStringToMethodCallRector::METHOD_NAMES_BY_TYPE => [ + ConfigCache::class => 'getPath', ], ]]); }; diff --git a/rules/type-declaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/config/configured_rule.php b/rules/type-declaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/config/configured_rule.php index dcf908f9ec96..1d6980aa739c 100644 --- a/rules/type-declaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/config/configured_rule.php +++ b/rules/type-declaration/tests/Rector/ClassMethod/AddParamTypeDeclarationRector/config/configured_rule.php @@ -1,14 +1,21 @@ services(); - $services->set(\Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector::class)->call( + $services->set(AddParamTypeDeclarationRector::class)->call( 'configure', [[ - \Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector::PARAMETER_TYPEHINTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - + AddParamTypeDeclarationRector::PARAMETER_TYPEHINTS => ValueObjectInliner::inline([ @@ -33,23 +40,19 @@ - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration( - \Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddParamTypeDeclarationRector\Contract\ParentInterfaceWithChangeTypeInterface::class, + + new AddParamTypeDeclaration( + ParentInterfaceWithChangeTypeInterface::class, 'process', 0, - new \PHPStan\Type\StringType() - ), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration( - \Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddParamTypeDeclarationRector\Source\ParserInterface::class, - 'parse', - 0, - new \PHPStan\Type\StringType() + new StringType() ), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration( - \Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddParamTypeDeclarationRector\Source\ClassMetadataFactory::class, + new AddParamTypeDeclaration(ParserInterface::class, 'parse', 0, new StringType()), + new AddParamTypeDeclaration( + ClassMetadataFactory::class, 'setEntityManager', 0, - new \PHPStan\Type\ObjectType('Doctrine\ORM\EntityManagerInterface') + new ObjectType('Doctrine\ORM\EntityManagerInterface') ), @@ -75,7 +78,7 @@ - + ]), ]] ); diff --git a/rules/visibility/tests/Rector/ClassMethod/ChangeMethodVisibilityRector/config/configured_rule.php b/rules/visibility/tests/Rector/ClassMethod/ChangeMethodVisibilityRector/config/configured_rule.php index a17bbb466b2c..63ab7b6ed493 100644 --- a/rules/visibility/tests/Rector/ClassMethod/ChangeMethodVisibilityRector/config/configured_rule.php +++ b/rules/visibility/tests/Rector/ClassMethod/ChangeMethodVisibilityRector/config/configured_rule.php @@ -1,34 +1,21 @@ services(); $services->set(ChangeMethodVisibilityRector::class)->call('configure', [[ - ChangeMethodVisibilityRector::METHOD_VISIBILITIES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([ - - new \Rector\Visibility\ValueObject\ChangeMethodVisibility( - \Rector\Visibility\Tests\Rector\ClassMethod\ChangeMethodVisibilityRector\Source\ParentObject::class, - 'toBePublicMethod', - \Rector\Core\ValueObject\Visibility::PUBLIC - ), - new \Rector\Visibility\ValueObject\ChangeMethodVisibility( - \Rector\Visibility\Tests\Rector\ClassMethod\ChangeMethodVisibilityRector\Source\ParentObject::class, - 'toBeProtectedMethod', - \Rector\Core\ValueObject\Visibility::PROTECTED - ), - new \Rector\Visibility\ValueObject\ChangeMethodVisibility( - \Rector\Visibility\Tests\Rector\ClassMethod\ChangeMethodVisibilityRector\Source\ParentObject::class, - 'toBePrivateMethod', - \Rector\Core\ValueObject\Visibility::PRIVATE - ), - new \Rector\Visibility\ValueObject\ChangeMethodVisibility( - \Rector\Visibility\Tests\Rector\ClassMethod\ChangeMethodVisibilityRector\Source\ParentObject::class, - 'toBePublicStaticMethod', - \Rector\Core\ValueObject\Visibility::PUBLIC - ), + ChangeMethodVisibilityRector::METHOD_VISIBILITIES => ValueObjectInliner::inline([ + + new ChangeMethodVisibility(ParentObject::class, 'toBePublicMethod', Visibility::PUBLIC), + new ChangeMethodVisibility(ParentObject::class, 'toBeProtectedMethod', Visibility::PROTECTED), + new ChangeMethodVisibility(ParentObject::class, 'toBePrivateMethod', Visibility::PRIVATE), + new ChangeMethodVisibility(ParentObject::class, 'toBePublicStaticMethod', Visibility::PUBLIC), diff --git a/rules/visibility/tests/Rector/Property/ChangePropertyVisibilityRector/config/configured_rule.php b/rules/visibility/tests/Rector/Property/ChangePropertyVisibilityRector/config/configured_rule.php index 5f7385ccb41b..301388b36dec 100644 --- a/rules/visibility/tests/Rector/Property/ChangePropertyVisibilityRector/config/configured_rule.php +++ b/rules/visibility/tests/Rector/Property/ChangePropertyVisibilityRector/config/configured_rule.php @@ -1,19 +1,22 @@ services(); - $services->set(\Rector\Visibility\Rector\Property\ChangePropertyVisibilityRector::class)->call('configure', [[ - \Rector\Visibility\Rector\Property\ChangePropertyVisibilityRector::PROPERTY_TO_VISIBILITY_BY_CLASS => [ - \Rector\Visibility\Tests\Rector\Property\ChangePropertyVisibilityRector\Source\ParentObject::class => [ - 'toBePublicProperty' => \Rector\Core\ValueObject\Visibility::PUBLIC, - 'toBeProtectedProperty' => \Rector\Core\ValueObject\Visibility::PROTECTED, - 'toBePrivateProperty' => \Rector\Core\ValueObject\Visibility::PRIVATE, - 'toBePublicStaticProperty' => \Rector\Core\ValueObject\Visibility::PUBLIC, + $services->set(ChangePropertyVisibilityRector::class)->call('configure', [[ + ChangePropertyVisibilityRector::PROPERTY_TO_VISIBILITY_BY_CLASS => [ + ParentObject::class => [ + 'toBePublicProperty' => Visibility::PUBLIC, + 'toBeProtectedProperty' => Visibility::PROTECTED, + 'toBePrivateProperty' => Visibility::PRIVATE, + 'toBePublicStaticProperty' => Visibility::PUBLIC, ], 'Rector\Visibility\Tests\Rector\Property\ChangePropertyVisibilityRector\Fixture\Fixture3' => [ - 'toBePublicStaticProperty' => \Rector\Core\ValueObject\Visibility::PUBLIC, + 'toBePublicStaticProperty' => Visibility::PUBLIC, ], ], ]]);