diff --git a/build/target-repository/docs/beyond_php_file_processors.md b/build/target-repository/docs/beyond_php_file_processors.md index 96a6913d170..365aa0b2827 100644 --- a/build/target-repository/docs/beyond_php_file_processors.md +++ b/build/target-repository/docs/beyond_php_file_processors.md @@ -22,7 +22,6 @@ All you have to do is using the ChangePackageVersionComposerRector: use Rector\Composer\Rector\ChangePackageVersionComposerRector; use Rector\Composer\ValueObject\PackageAndVersion; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); @@ -45,7 +44,6 @@ use Rector\Composer\Rector\ReplacePackageAndVersionComposerRector; use Rector\Composer\ValueObject\PackageAndVersion; use Rector\Composer\ValueObject\ReplacePackageAndVersion; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); diff --git a/build/target-repository/docs/rector_rules_overview.md b/build/target-repository/docs/rector_rules_overview.md index 426de679e54..abf6392a44e 100644 --- a/build/target-repository/docs/rector_rules_overview.md +++ b/build/target-repository/docs/rector_rules_overview.md @@ -119,17 +119,16 @@ use PHPStan\Type\ObjectType; use Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector; use Rector\Arguments\ValueObject\ArgumentAdder; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(ArgumentAdderRector::class) - ->call('configure', [[ - ArgumentAdderRector::ADDED_ARGUMENTS => ValueObjectInliner::inline([ + ->configure([ + ArgumentAdderRector::ADDED_ARGUMENTS => [ new ArgumentAdder('SomeExampleClass', 'someMethod', 0, 'someArgument', true, new ObjectType('SomeType')), - ]), - ]]); + ], + ]); }; ``` @@ -163,17 +162,12 @@ Streamline the operator arguments of version_compare function use Rector\Arguments\Rector\FuncCall\FunctionArgumentDefaultValueReplacerRector; use Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(FunctionArgumentDefaultValueReplacerRector::class) - ->call('configure', [[ - FunctionArgumentDefaultValueReplacerRector::REPLACED_ARGUMENTS => ValueObjectInliner::inline([ - new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'gte', 'ge'), - ]), - ]]); + ->configure([new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'gte', 'ge')]); }; ``` @@ -198,17 +192,12 @@ Replaces defined map of arguments in defined methods and their calls. use Rector\Arguments\Rector\ClassMethod\ReplaceArgumentDefaultValueRector; use Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(ReplaceArgumentDefaultValueRector::class) - ->call('configure', [[ - ReplaceArgumentDefaultValueRector::REPLACED_ARGUMENTS => ValueObjectInliner::inline([ - new ReplaceArgumentDefaultValue('SomeClass', 'someMethod', 0, 'SomeClass::OLD_CONSTANT', false), - ]), - ]]); + ->configure([new ReplaceArgumentDefaultValue('SomeClass', 'someMethod', 0, 'SomeClass::OLD_CONSTANT', false)]); }; ``` @@ -234,17 +223,12 @@ Swap arguments in function calls use Rector\Arguments\Rector\FuncCall\SwapFuncCallArgumentsRector; use Rector\Arguments\ValueObject\SwapFuncCallArguments; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(SwapFuncCallArgumentsRector::class) - ->call('configure', [[ - SwapFuncCallArgumentsRector::FUNCTION_ARGUMENT_SWAPS => ValueObjectInliner::inline([ - new SwapFuncCallArguments('some_function', [1, 0]), ] - ), - ]]); + ->configure([new SwapFuncCallArguments('some_function', [1, 0])]); }; ``` @@ -326,9 +310,7 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(MoveServicesBySuffixToDirectoryRector::class) - ->call('configure', [[ - MoveServicesBySuffixToDirectoryRector::GROUP_NAMES_BY_SUFFIX => ['Repository'], - ]]); + ->configure(['Repository']); }; ``` @@ -364,11 +346,15 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(MoveValueObjectsToValueObjectDirectoryRector::class) - ->call('configure', [[ + ->configure([ MoveValueObjectsToValueObjectDirectoryRector::TYPES => ['ValueObjectInterfaceClassName'], + ]) + ->configure([ MoveValueObjectsToValueObjectDirectoryRector::SUFFIXES => ['Search'], + ]) + ->configure([ MoveValueObjectsToValueObjectDirectoryRector::ENABLE_VALUE_OBJECT_GUESSING => true, - ]]); + ]); }; ``` @@ -1962,9 +1948,9 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(ConsistentPregDelimiterRector::class) - ->call('configure', [[ + ->configure([ ConsistentPregDelimiterRector::DELIMITER => '#', - ]]); + ]); }; ``` @@ -2159,9 +2145,10 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(OrderAttributesRector::class) - ->call('configure', [[ - OrderAttributesRector::ATTRIBUTES_ORDER => ['First', 'Second'], - ]]); + ->configure(['First']) + ->configure([ + 1 => 'Second', + ]); }; ``` @@ -2227,17 +2214,14 @@ use PHPUnit\Framework\TestCase; use Rector\CodingStyle\Enum\PreferenceSelfThis; use Rector\CodingStyle\Rector\MethodCall\PreferThisOrSelfMethodCallRector; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(PreferThisOrSelfMethodCallRector::class) - ->call('configure', [[ - PreferThisOrSelfMethodCallRector::TYPE_TO_PREFERENCE => [ - TestCase::class => ValueObjectInliner::inline(PreferenceSelfThis::PREFER_SELF()), - - ], ]]); + ->configure([ + TestCase::class => PreferenceSelfThis::PREFER_SELF(), + ]); }; ``` @@ -2288,17 +2272,12 @@ Turns array return to yield return in specific type and method use Rector\CodingStyle\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector; use Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(ReturnArrayClassMethodToYieldRector::class) - ->call('configure', [[ - ReturnArrayClassMethodToYieldRector::METHODS_TO_YIELDS => ValueObjectInliner::inline([ - new ReturnArrayClassMethodToYield('PHPUnit\Framework\TestCase', '*provide*'), - ]), - ]]); + ->configure([new ReturnArrayClassMethodToYield('PHPUnit\Framework\TestCase', '*provide*')]); }; ``` @@ -2616,17 +2595,16 @@ Add package to "require" in `composer.json` use Rector\Composer\Rector\AddPackageToRequireComposerRector; use Rector\Composer\ValueObject\PackageAndVersion; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(AddPackageToRequireComposerRector::class) - ->call('configure', [[ - AddPackageToRequireComposerRector::PACKAGES_AND_VERSIONS => ValueObjectInliner::inline([ + ->configure([ + AddPackageToRequireComposerRector::PACKAGES_AND_VERSIONS => [ new PackageAndVersion('symfony/console', '^3.4'), - ]), - ]]); + ], + ]); }; ``` @@ -2654,17 +2632,16 @@ Add package to "require-dev" in `composer.json` use Rector\Composer\Rector\AddPackageToRequireDevComposerRector; use Rector\Composer\ValueObject\PackageAndVersion; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(AddPackageToRequireDevComposerRector::class) - ->call('configure', [[ - AddPackageToRequireDevComposerRector::PACKAGES_AND_VERSIONS => ValueObjectInliner::inline([ + ->configure([ + AddPackageToRequireDevComposerRector::PACKAGES_AND_VERSIONS => [ new PackageAndVersion('symfony/console', '^3.4'), - ]), - ]]); + ], + ]); }; ``` @@ -2692,17 +2669,16 @@ Change package version `composer.json` use Rector\Composer\Rector\ChangePackageVersionComposerRector; use Rector\Composer\ValueObject\PackageAndVersion; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(ChangePackageVersionComposerRector::class) - ->call('configure', [[ - ChangePackageVersionComposerRector::PACKAGES_AND_VERSIONS => ValueObjectInliner::inline([ + ->configure([ + ChangePackageVersionComposerRector::PACKAGES_AND_VERSIONS => [ new PackageAndVersion('symfony/console', '^4.4'), - ]), - ]]); + ], + ]); }; ``` @@ -2736,9 +2712,9 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(RemovePackageComposerRector::class) - ->call('configure', [[ + ->configure([ RemovePackageComposerRector::PACKAGE_NAMES => ['symfony/console'], - ]]); + ]); }; ``` @@ -2766,17 +2742,14 @@ Change package name in `composer.json` use Rector\Composer\Rector\RenamePackageComposerRector; use Rector\Composer\ValueObject\RenamePackage; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(RenamePackageComposerRector::class) - ->call('configure', [[ - RenamePackageComposerRector::RENAME_PACKAGES => ValueObjectInliner::inline([ - new RenamePackage('rector/rector', 'rector/rector-src'), - ]), - ]]); + ->configure([ + RenamePackageComposerRector::RENAME_PACKAGES => [new RenamePackage('rector/rector', 'rector/rector-src')], + ]); }; ``` @@ -2805,17 +2778,16 @@ Change package name and version `composer.json` use Rector\Composer\Rector\ReplacePackageAndVersionComposerRector; use Rector\Composer\ValueObject\ReplacePackageAndVersion; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(ReplacePackageAndVersionComposerRector::class) - ->call('configure', [[ - ReplacePackageAndVersionComposerRector::REPLACE_PACKAGES_AND_VERSIONS => ValueObjectInliner::inline([ + ->configure([ + ReplacePackageAndVersionComposerRector::REPLACE_PACKAGES_AND_VERSIONS => [ new ReplacePackageAndVersion('symfony/console', 'symfony/http-kernel', '^4.4'), - ]), - ]]); + ], + ]); }; ``` @@ -2910,9 +2882,7 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(RemoveAnnotationRector::class) - ->call('configure', [[ - RemoveAnnotationRector::ANNOTATIONS_TO_REMOVE => ['method'], - ]]); + ->configure(['method']); }; ``` @@ -3442,9 +3412,9 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(RemovePhpVersionIdCheckRector::class) - ->call('configure', [[ + ->configure([ RemovePhpVersionIdCheckRector::PHP_VERSION_CONSTRAINT => 80000, - ]]); + ]); }; ``` @@ -3920,11 +3890,9 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(AddMethodParentCallRector::class) - ->call('configure', [[ - AddMethodParentCallRector::METHODS_BY_PARENT_TYPES => [ - 'ParentClassWithNewConstructor' => '__construct', - - ], ]]); + ->configure([ + 'ParentClassWithNewConstructor' => '__construct', + ]); }; ``` @@ -4676,10 +4644,12 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(DowngradeParameterTypeWideningRector::class) - ->call('configure', [[ + ->configure([ DowngradeParameterTypeWideningRector::SAFE_TYPES => [], + ]) + ->configure([ DowngradeParameterTypeWideningRector::SAFE_TYPES_TO_METHODS => [], - ]]); + ]); }; ``` @@ -5211,17 +5181,12 @@ Refactor PHP attribute markers to annotations notation use Rector\DowngradePhp80\Rector\Class_\DowngradeAttributeToAnnotationRector; use Rector\DowngradePhp80\ValueObject\DowngradeAttributeToAnnotation; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(DowngradeAttributeToAnnotationRector::class) - ->call('configure', [[ - DowngradeAttributeToAnnotationRector::ATTRIBUTE_TO_ANNOTATION => ValueObjectInliner::inline([ - new DowngradeAttributeToAnnotation('Symfony\Component\Routing\Annotation\Route'), - ]), - ]]); + ->configure([new DowngradeAttributeToAnnotation('Symfony\Component\Routing\Annotation\Route')]); }; ``` @@ -6094,17 +6059,12 @@ Make class methods generic based on implemented interface use Rector\Generics\Rector\ClassMethod\GenericClassMethodParamRector; use Rector\Generics\ValueObject\GenericClassMethodParam; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(GenericClassMethodParamRector::class) - ->call('configure', [[ - GenericClassMethodParamRector::GENERIC_CLASS_METHOD_PARAMS => ValueObjectInliner::inline([ - new GenericClassMethodParam('SomeInterface', 'getParams', 0, 'ParamInterface'), - ]), - ]]); + ->configure([new GenericClassMethodParam('SomeInterface', 'getParams', 0, 'ParamInterface')]); }; ``` @@ -6663,9 +6623,10 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(StringClassNameToClassConstantRector::class) - ->call('configure', [[ - StringClassNameToClassConstantRector::CLASSES_TO_SKIP => ['ClassName', 'AnotherClassName'], - ]]); + ->configure(['ClassName']) + ->configure([ + 1 => 'AnotherClassName', + ]); }; ``` @@ -7201,12 +7162,12 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(ReservedObjectRector::class) - ->call('configure', [[ - ReservedObjectRector::RESERVED_KEYWORDS_TO_REPLACEMENTS => [ - 'ReservedObject' => 'SmartObject', - 'Object' => 'AnotherSmartObject', - - ], ]]); + ->configure([ + 'ReservedObject' => 'SmartObject', + ]) + ->configure([ + 'Object' => 'AnotherSmartObject', + ]); }; ``` @@ -7565,9 +7526,9 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(AddLiteralSeparatorToNumberRector::class) - ->call('configure', [[ + ->configure([ AddLiteralSeparatorToNumberRector::LIMIT_VALUE => 1000000, - ]]); + ]); }; ``` @@ -7810,11 +7771,9 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(ReservedFnFunctionRector::class) - ->call('configure', [[ - ReservedFnFunctionRector::RESERVED_NAMES_TO_NEW_ONES => [ - 'fn' => 'someFunctionName', - - ], ]]); + ->configure([ + 'fn' => 'someFunctionName', + ]); }; ``` @@ -7871,10 +7830,12 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(TypedPropertyRector::class) - ->call('configure', [[ + ->configure([ TypedPropertyRector::CLASS_LIKE_TYPE_ONLY => false, + ]) + ->configure([ TypedPropertyRector::PRIVATE_PROPERTY_ONLY => false, - ]]); + ]); }; ``` @@ -7907,17 +7868,12 @@ Change annotation to attribute use Rector\Php80\Rector\Class_\AnnotationToAttributeRector; use Rector\Php80\ValueObject\AnnotationToAttribute; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(AnnotationToAttributeRector::class) - ->call('configure', [[ - AnnotationToAttributeRector::ANNOTATION_TO_ATTRIBUTE => ValueObjectInliner::inline([ - new AnnotationToAttribute('Symfony\Component\Routing\Annotation\Route'), - ]), - ]]); + ->configure([new AnnotationToAttribute('Symfony\Component\Routing\Annotation\Route')]); }; ``` @@ -8023,9 +7979,9 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(DoctrineAnnotationClassToAttributeRector::class) - ->call('configure', [[ + ->configure([ DoctrineAnnotationClassToAttributeRector::REMOVE_ANNOTATIONS => true, - ]]); + ]); }; ``` @@ -9069,17 +9025,12 @@ Replace string values in specific method call by constant of provided class use Rector\Privatization\Rector\MethodCall\ReplaceStringWithClassConstantRector; use Rector\Privatization\ValueObject\ReplaceStringWithClassConstant; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(ReplaceStringWithClassConstantRector::class) - ->call('configure', [[ - ReplaceStringWithClassConstantRector::REPLACE_STRING_WITH_CLASS_CONSTANT => ValueObjectInliner::inline([ - new ReplaceStringWithClassConstant('SomeClass', 'call', 0, 'Placeholder', false), - ]), - ]]); + ->configure([new ReplaceStringWithClassConstant('SomeClass', 'call', 0, 'Placeholder', false)]); }; ``` @@ -9112,17 +9063,12 @@ Removes defined arguments in defined methods and their calls. use Rector\Removing\Rector\ClassMethod\ArgumentRemoverRector; use Rector\Removing\ValueObject\ArgumentRemover; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(ArgumentRemoverRector::class) - ->call('configure', [[ - ArgumentRemoverRector::REMOVED_ARGUMENTS => ValueObjectInliner::inline([ - new ArgumentRemover('ExampleClass', 'someMethod', 0, [true]), ] - ), - ]]); + ->configure([new ArgumentRemover('ExampleClass', 'someMethod', 0, [true])]); }; ``` @@ -9148,17 +9094,12 @@ Remove argument by position by function name use Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector; use Rector\Removing\ValueObject\RemoveFuncCallArg; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(RemoveFuncCallArgRector::class) - ->call('configure', [[ - RemoveFuncCallArgRector::REMOVED_FUNCTION_ARGUMENTS => ValueObjectInliner::inline([ - new RemoveFuncCallArg('remove_last_arg', 1), - ]), - ]]); + ->configure([new RemoveFuncCallArg('remove_last_arg', 1)]); }; ``` @@ -9183,17 +9124,14 @@ Remove ini_get by configuration use Rector\Removing\Rector\FuncCall\RemoveFuncCallRector; use Rector\Removing\ValueObject\RemoveFuncCall; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(RemoveFuncCallRector::class) - ->call('configure', [[ - RemoveFuncCallRector::REMOVE_FUNC_CALLS => ValueObjectInliner::inline([ - new RemoveFuncCall('ini_get', [['y2k_compliance']]), ] - ), - ]]); + ->configure([ + RemoveFuncCallRector::REMOVE_FUNC_CALLS => [new RemoveFuncCall('ini_get', [['y2k_compliance']])], + ]); }; ``` @@ -9222,9 +9160,7 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(RemoveInterfacesRector::class) - ->call('configure', [[ - RemoveInterfacesRector::INTERFACES_TO_REMOVE => ['SomeInterface'], - ]]); + ->configure(['SomeInterface']); }; ``` @@ -9255,9 +9191,7 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(RemoveParentRector::class) - ->call('configure', [[ - RemoveParentRector::PARENT_TYPES_TO_REMOVE => ['SomeParentClass'], - ]]); + ->configure(['SomeParentClass']); }; ``` @@ -9288,9 +9222,7 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(RemoveTraitUseRector::class) - ->call('configure', [[ - RemoveTraitUseRector::TRAITS_TO_REMOVE => ['TraitNameToRemove'], - ]]); + ->configure(['TraitNameToRemove']); }; ``` @@ -9447,17 +9379,12 @@ Replaces defined Pseudo_Namespaces by Namespace\Ones. use Rector\Renaming\Rector\FileWithoutNamespace\PseudoNamespaceToNamespaceRector; use Rector\Renaming\ValueObject\PseudoNamespaceToNamespace; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(PseudoNamespaceToNamespaceRector::class) - ->call('configure', [[ - PseudoNamespaceToNamespaceRector::NAMESPACE_PREFIXES_WITH_EXCLUDED_CLASSES => ValueObjectInliner::inline([ - new PseudoNamespaceToNamespace('Some_', ['Some_Class_To_Keep']), ] - ), - ]]); + ->configure([new PseudoNamespaceToNamespace('Some_', ['Some_Class_To_Keep'])]); }; ``` @@ -9485,16 +9412,12 @@ Turns defined annotations above properties and methods to their new values. use Rector\Renaming\Rector\ClassMethod\RenameAnnotationRector; use Rector\Renaming\ValueObject\RenameAnnotationByType; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(RenameAnnotationRector::class) - ->call( - 'configure', - [[ValueObjectInliner::inline(new RenameAnnotationByType('PHPUnit\Framework\TestCase', 'test', 'scenario'))]] - ); + ->configure([new RenameAnnotationByType('PHPUnit\Framework\TestCase', 'test', 'scenario')]); }; ``` @@ -9529,17 +9452,16 @@ Replaces defined class constants in their calls. use Rector\Renaming\Rector\ClassConstFetch\RenameClassConstFetchRector; use Rector\Renaming\ValueObject\RenameClassAndConstFetch; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(RenameClassConstFetchRector::class) - ->call('configure', [[ - RenameClassConstFetchRector::CLASS_CONSTANT_RENAME => ValueObjectInliner::inline([ + ->configure([ + RenameClassConstFetchRector::CLASS_CONSTANT_RENAME => [ new RenameClassAndConstFetch('SomeClass', 'OTHER_OLD_CONSTANT', 'DifferentClass', 'NEW_CONSTANT'), - ]), - ]]); + ], + ]); }; ``` @@ -9570,11 +9492,9 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(RenameClassRector::class) - ->call('configure', [[ - RenameClassRector::OLD_TO_NEW_CLASSES => [ - 'App\SomeOldClass' => 'App\SomeNewClass', - - ], ]]); + ->configure([ + 'App\SomeOldClass' => 'App\SomeNewClass', + ]); }; ``` @@ -9615,12 +9535,12 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(RenameConstantRector::class) - ->call('configure', [[ - RenameConstantRector::OLD_TO_NEW_CONSTANTS => [ - 'MYSQL_ASSOC' => 'MYSQLI_ASSOC', - 'OLD_CONSTANT' => 'NEW_CONSTANT', - - ], ]]); + ->configure([ + 'MYSQL_ASSOC' => 'MYSQLI_ASSOC', + ]) + ->configure([ + 'OLD_CONSTANT' => 'NEW_CONSTANT', + ]); }; ``` @@ -9655,11 +9575,9 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(RenameFunctionRector::class) - ->call('configure', [[ - RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [ - 'view' => 'Laravel\Templating\render', - - ], ]]); + ->configure([ + 'view' => 'Laravel\Templating\render', + ]); }; ``` @@ -9684,17 +9602,12 @@ Turns method names to new ones. use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\ValueObject\MethodCallRename; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(RenameMethodRector::class) - ->call('configure', [[ - RenameMethodRector::METHOD_CALL_RENAMES => ValueObjectInliner::inline([ - new MethodCallRename('SomeExampleClass', 'oldMethod', 'newMethod'), - ]), - ]]); + ->configure([new MethodCallRename('SomeExampleClass', 'oldMethod', 'newMethod')]); }; ``` @@ -9724,11 +9637,9 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(RenameNamespaceRector::class) - ->call('configure', [[ - RenameNamespaceRector::OLD_TO_NEW_NAMESPACES => [ - 'SomeOldNamespace' => 'SomeNewNamespace', - - ], ]]); + ->configure([ + 'SomeOldNamespace' => 'SomeNewNamespace', + ]); }; ``` @@ -9753,17 +9664,12 @@ Replaces defined old properties by new ones. use Rector\Renaming\Rector\PropertyFetch\RenamePropertyRector; use Rector\Renaming\ValueObject\RenameProperty; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(RenamePropertyRector::class) - ->call('configure', [[ - RenamePropertyRector::RENAMED_PROPERTIES => ValueObjectInliner::inline([ - new RenameProperty('SomeClass', 'someOldProperty', 'someNewProperty'), - ]), - ]]); + ->configure([new RenameProperty('SomeClass', 'someOldProperty', 'someNewProperty')]); }; ``` @@ -9788,17 +9694,16 @@ Turns method names to new ones. use Rector\Renaming\Rector\StaticCall\RenameStaticMethodRector; use Rector\Renaming\ValueObject\RenameStaticMethod; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(RenameStaticMethodRector::class) - ->call('configure', [[ - RenameStaticMethodRector::OLD_TO_NEW_METHODS_BY_CLASSES => ValueObjectInliner::inline([ + ->configure([ + RenameStaticMethodRector::OLD_TO_NEW_METHODS_BY_CLASSES => [ new RenameStaticMethod('SomeClass', 'oldMethod', 'AnotherExampleClass', 'newStaticMethod'), - ]), - ]]); + ], + ]); }; ``` @@ -9815,17 +9720,16 @@ return static function (ContainerConfigurator $containerConfigurator): void { use Rector\Renaming\Rector\StaticCall\RenameStaticMethodRector; use Rector\Renaming\ValueObject\RenameStaticMethod; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(RenameStaticMethodRector::class) - ->call('configure', [[ - RenameStaticMethodRector::OLD_TO_NEW_METHODS_BY_CLASSES => ValueObjectInliner::inline([ + ->configure([ + RenameStaticMethodRector::OLD_TO_NEW_METHODS_BY_CLASSES => [ new RenameStaticMethod('SomeClass', 'oldMethod', 'SomeClass', 'newStaticMethod'), - ]), - ]]); + ], + ]); }; ``` @@ -9854,11 +9758,9 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(RenameStringRector::class) - ->call('configure', [[ - RenameStringRector::STRING_CHANGES => [ - 'ROLE_PREVIOUS_ADMIN' => 'IS_IMPERSONATOR', - - ], ]]); + ->configure([ + 'ROLE_PREVIOUS_ADMIN' => 'IS_IMPERSONATOR', + ]); }; ``` @@ -9891,17 +9793,12 @@ In case you have accidentally removed use imports but code still contains partia use Rector\Restoration\Rector\Namespace_\CompleteImportForPartialAnnotationRector; use Rector\Restoration\ValueObject\CompleteImportForPartialAnnotation; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(CompleteImportForPartialAnnotationRector::class) - ->call('configure', [[ - CompleteImportForPartialAnnotationRector::USE_IMPORTS_TO_RESTORE => ValueObjectInliner::inline([ - new CompleteImportForPartialAnnotation('Doctrine\ORM\Mapping', 'ORM'), - ]), - ]]); + ->configure([new CompleteImportForPartialAnnotation('Doctrine\ORM\Mapping', 'ORM')]); }; ``` @@ -10017,9 +9914,9 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(BooleanInBooleanNotRuleFixerRector::class) - ->call('configure', [[ + ->configure([ BooleanInBooleanNotRuleFixerRector::TREAT_AS_NON_EMPTY => true, - ]]); + ]); }; ``` @@ -10059,9 +9956,9 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(BooleanInIfConditionRuleFixerRector::class) - ->call('configure', [[ + ->configure([ BooleanInIfConditionRuleFixerRector::TREAT_AS_NON_EMPTY => false, - ]]); + ]); }; ``` @@ -10100,9 +9997,9 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(BooleanInTernaryOperatorRuleFixerRector::class) - ->call('configure', [[ + ->configure([ BooleanInTernaryOperatorRuleFixerRector::TREAT_AS_NON_EMPTY => false, - ]]); + ]); }; ``` @@ -10137,9 +10034,9 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(DisallowedEmptyRuleFixerRector::class) - ->call('configure', [[ + ->configure([ DisallowedEmptyRuleFixerRector::TREAT_AS_NON_EMPTY => false, - ]]); + ]); }; ``` @@ -10174,9 +10071,9 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(DisallowedShortTernaryRuleFixerRector::class) - ->call('configure', [[ + ->configure([ DisallowedShortTernaryRuleFixerRector::TREAT_AS_NON_EMPTY => false, - ]]); + ]); }; ``` @@ -10228,11 +10125,9 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(AddInterfaceByParentRector::class) - ->call('configure', [[ - AddInterfaceByParentRector::INTERFACE_BY_PARENT => [ - 'SomeParent' => 'SomeInterface', - - ], ]]); + ->configure([ + 'SomeParent' => 'SomeInterface', + ]); }; ``` @@ -10264,11 +10159,9 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(AddInterfaceByTraitRector::class) - ->call('configure', [[ - AddInterfaceByTraitRector::INTERFACE_BY_TRAIT => [ - 'SomeTrait' => 'SomeInterface', - - ], ]]); + ->configure([ + 'SomeTrait' => 'SomeInterface', + ]); }; ``` @@ -10296,17 +10189,12 @@ Move help facade-like function calls to constructor injection use Rector\Transform\Rector\FuncCall\ArgumentFuncCallToMethodCallRector; use Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(ArgumentFuncCallToMethodCallRector::class) - ->call('configure', [[ - ArgumentFuncCallToMethodCallRector::FUNCTIONS_TO_METHOD_CALLS => ValueObjectInliner::inline([ - new ArgumentFuncCallToMethodCall('view', 'Illuminate\Contracts\View\Factory', 'make'), - ]), - ]]); + ->configure([new ArgumentFuncCallToMethodCall('view', 'Illuminate\Contracts\View\Factory', 'make')]); }; ``` @@ -10349,19 +10237,16 @@ Replace key value on specific attribute to class constant use Rector\Transform\Rector\Attribute\AttributeKeyToClassConstFetchRector; use Rector\Transform\ValueObject\AttributeKeyToClassConstFetch; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(AttributeKeyToClassConstFetchRector::class) - ->call('configure', [[ - AttributeKeyToClassConstFetchRector::ATTRIBUTE_KEYS_TO_CLASS_CONST_FETCHES => ValueObjectInliner::inline([ - new AttributeKeyToClassConstFetch('Doctrine\ORM\Mapping\Column', 'type', 'Doctrine\DBAL\Types\Types', [ - 'STRING', - ]), ] - ), - ]]); + ->configure( + [new AttributeKeyToClassConstFetch('Doctrine\ORM\Mapping\Column', 'type', 'Doctrine\DBAL\Types\Types', [ + 'STRING', + ])] + ); }; ``` @@ -10393,17 +10278,12 @@ Change a callable in method call to standalone variable assign use Rector\Transform\Rector\MethodCall\CallableInMethodCallToVariableRector; use Rector\Transform\ValueObject\CallableInMethodCallToVariable; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(CallableInMethodCallToVariableRector::class) - ->call('configure', [[ - CallableInMethodCallToVariableRector::CALLABLE_IN_METHOD_CALL_TO_VARIABLE => ValueObjectInliner::inline([ - new CallableInMethodCallToVariable('Nette\Caching\Cache', 'save', 1), - ]), - ]]); + ->configure([new CallableInMethodCallToVariable('Nette\Caching\Cache', 'save', 1)]); }; ``` @@ -10467,21 +10347,18 @@ Change magic array access add to `$list[],` to explicit `$list->addMethod(...)` use Rector\Transform\Rector\Assign\DimFetchAssignToMethodCallRector; use Rector\Transform\ValueObject\DimFetchAssignToMethodCall; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(DimFetchAssignToMethodCallRector::class) - ->call('configure', [[ - DimFetchAssignToMethodCallRector::DIM_FETCH_ASSIGN_TO_METHOD_CALL => ValueObjectInliner::inline([ - new DimFetchAssignToMethodCall( - 'Nette\Application\Routers\RouteList', - 'Nette\Application\Routers\Route', - 'addRoute' - ), - ]), - ]]); + ->configure( + [new DimFetchAssignToMethodCall( + 'Nette\Application\Routers\RouteList', + 'Nette\Application\Routers\Route', + 'addRoute' + )] + ); }; ``` @@ -10520,11 +10397,9 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(FuncCallToConstFetchRector::class) - ->call('configure', [[ - FuncCallToConstFetchRector::FUNCTIONS_TO_CONSTANTS => [ - 'php_sapi_name' => 'PHP_SAPI', - - ], ]]); + ->configure([ + 'php_sapi_name' => 'PHP_SAPI', + ]); }; ``` @@ -10555,17 +10430,12 @@ Turns defined function calls to local method calls. use Rector\Transform\Rector\FuncCall\FuncCallToMethodCallRector; use Rector\Transform\ValueObject\FuncCallToMethodCall; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(FuncCallToMethodCallRector::class) - ->call('configure', [[ - FuncCallToMethodCallRector::FUNC_CALL_TO_CLASS_METHOD_CALL => ValueObjectInliner::inline([ - new FuncCallToMethodCall('view', 'Namespaced\SomeRenderer', 'render'), - ]), - ]]); + ->configure([new FuncCallToMethodCall('view', 'Namespaced\SomeRenderer', 'render')]); }; ``` @@ -10610,11 +10480,9 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(FuncCallToNewRector::class) - ->call('configure', [[ - FuncCallToNewRector::FUNCTIONS_TO_NEWS => [ - 'collection' => ['Collection'], - - ], ]]); + ->configure([ + 'collection' => ['Collection'], + ]); }; ``` @@ -10645,17 +10513,12 @@ Turns defined function call to static method call. use Rector\Transform\Rector\FuncCall\FuncCallToStaticCallRector; use Rector\Transform\ValueObject\FuncCallToStaticCall; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(FuncCallToStaticCallRector::class) - ->call('configure', [[ - FuncCallToStaticCallRector::FUNC_CALLS_TO_STATIC_CALLS => ValueObjectInliner::inline([ - new FuncCallToStaticCall('view', 'SomeStaticClass', 'render'), - ]), - ]]); + ->configure([new FuncCallToStaticCall('view', 'SomeStaticClass', 'render')]); }; ``` @@ -10680,17 +10543,12 @@ Turns defined `__get`/`__set` to specific method calls. use Rector\Transform\Rector\Assign\GetAndSetToMethodCallRector; use Rector\Transform\ValueObject\GetAndSetToMethodCall; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(GetAndSetToMethodCallRector::class) - ->call('configure', [[ - GetAndSetToMethodCallRector::TYPE_TO_METHOD_CALLS => ValueObjectInliner::inline([ - new GetAndSetToMethodCall('SomeContainer', 'addService', 'getService'), - ]), - ]]); + ->configure([new GetAndSetToMethodCall('SomeContainer', 'addService', 'getService')]); }; ``` @@ -10720,11 +10578,9 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(MergeInterfacesRector::class) - ->call('configure', [[ - MergeInterfacesRector::OLD_TO_NEW_INTERFACES => [ - 'SomeOldInterface' => 'SomeInterface', - - ], ]]); + ->configure([ + 'SomeOldInterface' => 'SomeInterface', + ]); }; ``` @@ -10751,19 +10607,16 @@ Turns old method call with specific types to new one with arguments use Rector\Transform\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector; use Rector\Transform\ValueObject\MethodCallToAnotherMethodCallWithArguments; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(MethodCallToAnotherMethodCallWithArgumentsRector::class) - ->call('configure', [[ - MethodCallToAnotherMethodCallWithArgumentsRector::METHOD_CALL_RENAMES_WITH_ADDED_ARGUMENTS => ValueObjectInliner::inline([ - new MethodCallToAnotherMethodCallWithArguments('Nette\DI\ServiceDefinition', 'setInject', 'addTag', [ - 'inject', - ]), ] - ), - ]]); + ->configure( + [new MethodCallToAnotherMethodCallWithArguments('Nette\DI\ServiceDefinition', 'setInject', 'addTag', [ + 'inject', + ])] + ); }; ``` @@ -10789,17 +10642,12 @@ Change method one method from one service to a method call to in another service use Rector\Transform\Rector\MethodCall\MethodCallToMethodCallRector; use Rector\Transform\ValueObject\MethodCallToMethodCall; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(MethodCallToMethodCallRector::class) - ->call('configure', [[ - MethodCallToMethodCallRector::METHOD_CALLS_TO_METHOD_CALLS => ValueObjectInliner::inline([ - new MethodCallToMethodCall('FirstDependency', 'go', 'SecondDependency', 'away'), - ]), - ]]); + ->configure([new MethodCallToMethodCall('FirstDependency', 'go', 'SecondDependency', 'away')]); }; ``` @@ -10840,11 +10688,9 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(MethodCallToPropertyFetchRector::class) - ->call('configure', [[ - MethodCallToPropertyFetchRector::METHOD_CALL_TO_PROPERTY_FETCHES => [ - 'someMethod' => 'someProperty', - - ], ]]); + ->configure([ + 'someMethod' => 'someProperty', + ]); }; ``` @@ -10875,17 +10721,12 @@ Change method call to desired static call use Rector\Transform\Rector\MethodCall\MethodCallToStaticCallRector; use Rector\Transform\ValueObject\MethodCallToStaticCall; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(MethodCallToStaticCallRector::class) - ->call('configure', [[ - MethodCallToStaticCallRector::METHOD_CALLS_TO_STATIC_CALLS => ValueObjectInliner::inline([ - new MethodCallToStaticCall('AnotherDependency', 'process', 'StaticCaller', 'anotherMethod'), - ]), - ]]); + ->configure([new MethodCallToStaticCall('AnotherDependency', 'process', 'StaticCaller', 'anotherMethod')]); }; ``` @@ -10923,17 +10764,12 @@ Change new with specific argument to method call use Rector\Transform\Rector\New_\NewArgToMethodCallRector; use Rector\Transform\ValueObject\NewArgToMethodCall; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(NewArgToMethodCallRector::class) - ->call('configure', [[ - NewArgToMethodCallRector::NEW_ARGS_TO_METHOD_CALLS => ValueObjectInliner::inline([ - new NewArgToMethodCall('Dotenv', true, 'usePutenv'), - ]), - ]]); + ->configure([new NewArgToMethodCall('Dotenv', true, 'usePutenv')]); }; ``` @@ -10969,9 +10805,7 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(NewToConstructorInjectionRector::class) - ->call('configure', [[ - NewToConstructorInjectionRector::TYPES_TO_CONSTRUCTOR_INJECTION => ['Validator'], - ]]); + ->configure(['Validator']); }; ``` @@ -11013,17 +10847,12 @@ Replaces creating object instances with "new" keyword with factory method. use Rector\Transform\Rector\New_\NewToMethodCallRector; use Rector\Transform\ValueObject\NewToMethodCall; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(NewToMethodCallRector::class) - ->call('configure', [[ - NewToMethodCallRector::NEWS_TO_METHOD_CALLS => ValueObjectInliner::inline([ - new NewToMethodCall('MyClass', 'MyClassFactory', 'create'), - ]), - ]]); + ->configure([new NewToMethodCall('MyClass', 'MyClassFactory', 'create')]); }; ``` @@ -11058,17 +10887,12 @@ Change new Object to static call use Rector\Transform\Rector\New_\NewToStaticCallRector; use Rector\Transform\ValueObject\NewToStaticCall; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(NewToStaticCallRector::class) - ->call('configure', [[ - NewToStaticCallRector::TYPE_TO_STATIC_CALLS => ValueObjectInliner::inline([ - new NewToStaticCall('Cookie', 'Cookie', 'create'), - ]), - ]]); + ->configure([new NewToStaticCall('Cookie', 'Cookie', 'create')]); }; ``` @@ -11099,17 +10923,12 @@ Replaces parent class to specific traits use Rector\Transform\Rector\Class_\ParentClassToTraitsRector; use Rector\Transform\ValueObject\ParentClassToTraits; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(ParentClassToTraitsRector::class) - ->call('configure', [[ - ParentClassToTraitsRector::PARENT_CLASS_TO_TRAITS => ValueObjectInliner::inline([ - new ParentClassToTraits('Nette\Object', ['Nette\SmartObject']), ] - ), - ]]); + ->configure([new ParentClassToTraits('Nette\Object', ['Nette\SmartObject'])]); }; ``` @@ -11137,17 +10956,12 @@ Turns property assign of specific type and property name to method call use Rector\Transform\Rector\Assign\PropertyAssignToMethodCallRector; use Rector\Transform\ValueObject\PropertyAssignToMethodCall; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(PropertyAssignToMethodCallRector::class) - ->call('configure', [[ - PropertyAssignToMethodCallRector::PROPERTY_ASSIGNS_TO_METHODS_CALLS => ValueObjectInliner::inline([ - new PropertyAssignToMethodCall('SomeClass', 'oldProperty', 'newMethodCall'), - ]), - ]]); + ->configure([new PropertyAssignToMethodCall('SomeClass', 'oldProperty', 'newMethodCall')]); }; ``` @@ -11173,17 +10987,16 @@ Replaces properties assign calls be defined methods. use Rector\Transform\Rector\Assign\PropertyFetchToMethodCallRector; use Rector\Transform\ValueObject\PropertyFetchToMethodCall; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(PropertyFetchToMethodCallRector::class) - ->call('configure', [[ - PropertyFetchToMethodCallRector::PROPERTIES_TO_METHOD_CALLS => ValueObjectInliner::inline([ - new PropertyFetchToMethodCall('SomeObject', 'property', 'getProperty', 'setProperty', []), ] - ), - ]]); + ->configure([ + PropertyFetchToMethodCallRector::PROPERTIES_TO_METHOD_CALLS => [ + new PropertyFetchToMethodCall('SomeObject', 'property', 'getProperty', 'setProperty', []), + ], + ]); }; ``` @@ -11202,17 +11015,16 @@ return static function (ContainerConfigurator $containerConfigurator): void { use Rector\Transform\Rector\Assign\PropertyFetchToMethodCallRector; use Rector\Transform\ValueObject\PropertyFetchToMethodCall; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(PropertyFetchToMethodCallRector::class) - ->call('configure', [[ - PropertyFetchToMethodCallRector::PROPERTIES_TO_METHOD_CALLS => ValueObjectInliner::inline([ - new PropertyFetchToMethodCall('SomeObject', 'property', 'getConfig', ['someArg']), ] - ), - ]]); + ->configure([ + PropertyFetchToMethodCallRector::PROPERTIES_TO_METHOD_CALLS => [ + new PropertyFetchToMethodCall('SomeObject', 'property', 'getConfig', ['someArg']), + ], + ]); }; ``` @@ -11237,17 +11049,12 @@ Changes method calls in child of specific types to defined property method call use Rector\Transform\Rector\MethodCall\ReplaceParentCallByPropertyCallRector; use Rector\Transform\ValueObject\ReplaceParentCallByPropertyCall; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(ReplaceParentCallByPropertyCallRector::class) - ->call('configure', [[ - ReplaceParentCallByPropertyCallRector::PARENT_CALLS_TO_PROPERTIES => ValueObjectInliner::inline([ - new ReplaceParentCallByPropertyCall('SomeTypeToReplace', 'someMethodCall', 'someProperty'), - ]), - ]]); + ->configure([new ReplaceParentCallByPropertyCall('SomeTypeToReplace', 'someMethodCall', 'someProperty')]); }; ``` @@ -11278,17 +11085,12 @@ Get service call to constructor injection use Rector\Transform\Rector\MethodCall\ServiceGetterToConstructorInjectionRector; use Rector\Transform\ValueObject\ServiceGetterToConstructorInjection; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(ServiceGetterToConstructorInjectionRector::class) - ->call('configure', [[ - ServiceGetterToConstructorInjectionRector::METHOD_CALL_TO_SERVICES => ValueObjectInliner::inline([ - new ServiceGetterToConstructorInjection('FirstService', 'getAnotherService', 'AnotherService'), - ]), - ]]); + ->configure([new ServiceGetterToConstructorInjection('FirstService', 'getAnotherService', 'AnotherService')]); }; ``` @@ -11352,17 +11154,12 @@ Change method that returns single value to multiple values use Rector\Transform\Rector\ClassMethod\SingleToManyMethodRector; use Rector\Transform\ValueObject\SingleToManyMethod; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(SingleToManyMethodRector::class) - ->call('configure', [[ - SingleToManyMethodRector::SINGLES_TO_MANY_METHODS => ValueObjectInliner::inline([ - new SingleToManyMethod('SomeClass', 'getNode', 'getNodes'), - ]), - ]]); + ->configure([new SingleToManyMethod('SomeClass', 'getNode', 'getNodes')]); }; ``` @@ -11397,17 +11194,12 @@ Turns static call to function call. use Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector; use Rector\Transform\ValueObject\StaticCallToFuncCall; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(StaticCallToFuncCallRector::class) - ->call('configure', [[ - StaticCallToFuncCallRector::STATIC_CALLS_TO_FUNCTIONS => ValueObjectInliner::inline([ - new StaticCallToFuncCall('OldClass', 'oldMethod', 'new_function'), - ]), - ]]); + ->configure([new StaticCallToFuncCall('OldClass', 'oldMethod', 'new_function')]); }; ``` @@ -11432,22 +11224,19 @@ Change static call to service method via constructor injection use Rector\Transform\Rector\StaticCall\StaticCallToMethodCallRector; use Rector\Transform\ValueObject\StaticCallToMethodCall; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->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' - ), - ]), - ]]); + ->configure( + [new StaticCallToMethodCall( + 'Nette\Utils\FileSystem', + 'write', + 'Symplify\SmartFileSystem\SmartFileSystem', + 'dumpFile' + )] + ); }; ``` @@ -11491,17 +11280,12 @@ Change static call to new instance use Rector\Transform\Rector\StaticCall\StaticCallToNewRector; use Rector\Transform\ValueObject\StaticCallToNew; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(StaticCallToNewRector::class) - ->call('configure', [[ - StaticCallToNewRector::STATIC_CALLS_TO_NEWS => ValueObjectInliner::inline([ - new StaticCallToNew('JsonResponse', 'create'), - ]), - ]]); + ->configure([new StaticCallToNew('JsonResponse', 'create')]); }; ``` @@ -11532,17 +11316,12 @@ Changes strings to specific constants use Rector\Transform\Rector\String_\StringToClassConstantRector; use Rector\Transform\ValueObject\StringToClassConstant; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(StringToClassConstantRector::class) - ->call('configure', [[ - StringToClassConstantRector::STRINGS_TO_CLASS_CONSTANTS => ValueObjectInliner::inline([ - new StringToClassConstant('compiler.post_dump', 'Yet\AnotherClass', 'CONSTANT'), - ]), - ]]); + ->configure([new StringToClassConstant('compiler.post_dump', 'Yet\AnotherClass', 'CONSTANT')]); }; ``` @@ -11577,11 +11356,9 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(ToStringToMethodCallRector::class) - ->call('configure', [[ - ToStringToMethodCallRector::METHOD_NAMES_BY_TYPE => [ - 'SomeObject' => 'getPath', - - ], ]]); + ->configure([ + 'SomeObject' => 'getPath', + ]); }; ``` @@ -11609,17 +11386,12 @@ Turns defined `__isset`/`__unset` calls to specific method calls. use Rector\Transform\Rector\Isset_\UnsetAndIssetToMethodCallRector; use Rector\Transform\ValueObject\UnsetAndIssetToMethodCall; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(UnsetAndIssetToMethodCallRector::class) - ->call('configure', [[ - UnsetAndIssetToMethodCallRector::ISSET_UNSET_TO_METHOD_CALL => ValueObjectInliner::inline([ - new UnsetAndIssetToMethodCall('SomeContainer', 'hasService', 'removeService'), - ]), - ]]); + ->configure([new UnsetAndIssetToMethodCall('SomeContainer', 'hasService', 'removeService')]); }; ``` @@ -11647,17 +11419,12 @@ Wrap return value of specific method use Rector\Transform\Rector\ClassMethod\WrapReturnRector; use Rector\Transform\ValueObject\WrapReturn; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(WrapReturnRector::class) - ->call('configure', [[ - WrapReturnRector::TYPE_METHOD_WRAPS => ValueObjectInliner::inline([ - new WrapReturn('SomeClass', 'getItem', true), - ]), - ]]); + ->configure([new WrapReturn('SomeClass', 'getItem', true)]); }; ``` @@ -11787,17 +11554,16 @@ use PHPStan\Type\StringType; use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector; use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(AddParamTypeDeclarationRector::class) - ->call('configure', [[ - AddParamTypeDeclarationRector::PARAMETER_TYPEHINTS => ValueObjectInliner::inline([ + ->configure([ + AddParamTypeDeclarationRector::PARAMETER_TYPEHINTS => [ new AddParamTypeDeclaration('SomeClass', 'process', 0, new StringType()), - ]), - ]]); + ], + ]); }; ``` @@ -11828,16 +11594,12 @@ use PHPStan\Type\StringType; use Rector\TypeDeclaration\Rector\Property\AddPropertyTypeDeclarationRector; use Rector\TypeDeclaration\ValueObject\AddPropertyTypeDeclaration; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(AddPropertyTypeDeclarationRector::class) - ->call( - 'configure', - [[ValueObjectInliner::inline(new AddPropertyTypeDeclaration('ParentClass', 'name', new StringType()))]] - ); + ->configure([new AddPropertyTypeDeclaration('ParentClass', 'name', new StringType())]); }; ``` @@ -11867,19 +11629,18 @@ use PHPStan\Type\MixedType; use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector; use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(AddReturnTypeDeclarationRector::class) - ->call('configure', [[ - AddReturnTypeDeclarationRector::METHOD_RETURN_TYPES => ValueObjectInliner::inline([ + ->configure([ + AddReturnTypeDeclarationRector::METHOD_RETURN_TYPES => [ new AddReturnTypeDeclaration('SomeClass', 'getData', new ArrayType(new MixedType(false), new MixedType( false ))), - ]), - ]]); + ], + ]); }; ``` @@ -11913,9 +11674,9 @@ return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(AddVoidReturnTypeWhereNoReturnRector::class) - ->call('configure', [[ + ->configure([ AddVoidReturnTypeWhereNoReturnRector::USE_PHPDOC => false, - ]]); + ]); }; ``` @@ -12282,17 +12043,12 @@ Change visibility of constant from parent class. use Rector\Visibility\Rector\ClassConst\ChangeConstantVisibilityRector; use Rector\Visibility\ValueObject\ChangeConstantVisibility; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(ChangeConstantVisibilityRector::class) - ->call('configure', [[ - ChangeConstantVisibilityRector::CLASS_CONSTANT_VISIBILITY_CHANGES => ValueObjectInliner::inline([ - new ChangeConstantVisibility('ParentObject', 'SOME_CONSTANT', 2), - ]), - ]]); + ->configure([new ChangeConstantVisibility('ParentObject', 'SOME_CONSTANT', 2)]); }; ``` @@ -12325,17 +12081,12 @@ Change visibility of method from parent class. use Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector; use Rector\Visibility\ValueObject\ChangeMethodVisibility; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\SymfonyPhpConfig\ValueObjectInliner; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(ChangeMethodVisibilityRector::class) - ->call('configure', [[ - ChangeMethodVisibilityRector::METHOD_VISIBILITIES => ValueObjectInliner::inline([ - new ChangeMethodVisibility('FrameworkClass', 'someMethod', 2), - ]), - ]]); + ->configure([new ChangeMethodVisibility('FrameworkClass', 'someMethod', 2)]); }; ``` diff --git a/composer.json b/composer.json index 9b380898dcd..4539be1cfee 100644 --- a/composer.json +++ b/composer.json @@ -45,18 +45,18 @@ "symfony/finder": "^5.4|^6.0", "symfony/process": "^5.4|^6.0", "symfony/yaml": "^5.4|^6.0", - "symplify/astral": "^10.0", - "symplify/autowire-array-parameter": "^10.0", - "symplify/composer-json-manipulator": "^10.0", - "symplify/console-color-diff": "^10.0", - "symplify/easy-parallel": "^10.0", - "symplify/package-builder": "^10.0-beta11", - "symplify/rule-doc-generator-contracts": "^10.0-beta11", - "symplify/simple-php-doc-parser": "^10.0", - "symplify/skipper": "^10.0", - "symplify/smart-file-system": "^10.0", - "symplify/symfony-php-config": "^10.0", - "symplify/vendor-patches": "^10.0", + "symplify/astral": "^10.0-beta17", + "symplify/autowire-array-parameter": "^10.0-beta17", + "symplify/composer-json-manipulator": "^10.0-beta17", + "symplify/console-color-diff": "^10.0-beta17", + "symplify/easy-parallel": "^10.0-beta17", + "symplify/package-builder": "^10.0-beta17", + "symplify/rule-doc-generator-contracts": "^10.0-beta17", + "symplify/simple-php-doc-parser": "^10.0-beta17", + "symplify/skipper": "^10.0-beta17", + "symplify/smart-file-system": "^10.0-beta17", + "symplify/symfony-php-config": "^10.0-beta17", + "symplify/vendor-patches": "^10.0-beta17", "tracy/tracy": "^2.8", "webmozart/assert": "^1.10" }, @@ -142,7 +142,7 @@ "phpstan": "vendor/bin/phpstan analyse --ansi --error-format symplify", "phpstan-config": "vendor/bin/phpstan analyse config --ansi --error-format symplify", "docs": [ - "vendor/bin/rule-doc-generator generate packages rules --output-file build/rector_rules_overview.md --ansi --categorize", + "vendor/bin/rule-doc-generator generate packages rules --output-file build/rector_rules_overview.md --ansi --categorize --configure-method", "mv build/rector_rules_overview.md build/target-repository/docs/rector_rules_overview.md", "vendor/bin/ecs check-markdown build/target-repository/docs/rector_rules_overview.md --ansi --fix" ], diff --git a/config/services.php b/config/services.php index 32ca54c1f21..3242a62842c 100644 --- a/config/services.php +++ b/config/services.php @@ -28,6 +28,7 @@ use Rector\Caching\Cache; use Rector\Caching\CacheFactory; use Rector\Core\Console\ConsoleApplication; +use Rector\Core\Validation\Collector\EmptyConfigurableRectorCollector; use Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory; use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocator\IntermediateSourceLocator; use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider; @@ -78,6 +79,9 @@ $services->set(FileSystemGuard::class); + $services->set(EmptyConfigurableRectorCollector::class) + ->arg('$containerBuilder', service('service_container')); + $services->set(SimpleCallableNodeTraverser::class); $services->set(ParserFactory::class); diff --git a/packages/ReadWrite/Guard/VariableToConstantGuard.php b/packages/ReadWrite/Guard/VariableToConstantGuard.php index d273c9b28a0..e597e260a61 100644 --- a/packages/ReadWrite/Guard/VariableToConstantGuard.php +++ b/packages/ReadWrite/Guard/VariableToConstantGuard.php @@ -51,6 +51,10 @@ public function isReadArg(Arg $arg): bool $functionReflection = $this->reflectionProvider->getFunction($functionName, $argScope); + if (! $argScope instanceof Scope) { + return true; + } + $referenceParametersPositions = $this->resolveFunctionReferencePositions( $functionReflection, [$arg], diff --git a/phpstan.neon b/phpstan.neon index 30e741657ee..1d56842c77a 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -606,3 +606,12 @@ parameters: path: src/Application/ApplicationFileProcessor.php - '#Call to function property_exists\(\) with PhpParser\\Node\\Stmt\\ClassLike and (.*?) will always evaluate to true#' + + # code sample configuration + - + message: '#new is limited to 3 "new \(new \)\)" nesting to each other\. You have 4 nesting#' + paths: + - rules/Renaming/Rector/ClassConstFetch/RenameClassConstFetchRector.php + - rules/Arguments/Rector/ClassMethod/ArgumentAdderRector.php + - rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeDeclarationRector.php + - rules/Transform/Rector/Assign/PropertyFetchToMethodCallRector.php diff --git a/preload.php b/preload.php index acac5a5c6cb..480da996488 100644 --- a/preload.php +++ b/preload.php @@ -252,7 +252,6 @@ require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/ParserFactory.php'; require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php'; require_once __DIR__ . '/vendor/symplify/symfony-php-config/src/Reflection/ArgumentAndParameterFactory.php'; -require_once __DIR__ . '/vendor/symplify/symfony-php-config/src/ValueObjectInliner.php'; require_once __DIR__ . '/vendor/symfony/dependency-injection/Loader/Configurator/AbstractConfigurator.php'; require_once __DIR__ . '/vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php'; require_once __DIR__ . '/vendor/symfony/contracts/Deprecation/function.php'; diff --git a/rules/Arguments/Rector/ClassMethod/ArgumentAdderRector.php b/rules/Arguments/Rector/ClassMethod/ArgumentAdderRector.php index b83b08e44dc..80d27cf6491 100644 --- a/rules/Arguments/Rector/ClassMethod/ArgumentAdderRector.php +++ b/rules/Arguments/Rector/ClassMethod/ArgumentAdderRector.php @@ -53,14 +53,6 @@ public function __construct( public function getRuleDefinition(): RuleDefinition { - $objectType = new ObjectType('SomeType'); - - $exampleConfiguration = [ - self::ADDED_ARGUMENTS => [ - new ArgumentAdder('SomeExampleClass', 'someMethod', 0, 'someArgument', true, $objectType), - ], - ]; - return new RuleDefinition( 'This Rector adds new default arguments in calls of defined methods and class types.', [ @@ -89,7 +81,11 @@ public function someMethod($value = true) } CODE_SAMPLE , - $exampleConfiguration + [ + new ArgumentAdder('SomeExampleClass', 'someMethod', 0, 'someArgument', true, new ObjectType( + 'SomeType' + )), + ] ), ] ); diff --git a/rules/Arguments/Rector/ClassMethod/ReplaceArgumentDefaultValueRector.php b/rules/Arguments/Rector/ClassMethod/ReplaceArgumentDefaultValueRector.php index 745a624b085..a202d67a25e 100644 --- a/rules/Arguments/Rector/ClassMethod/ReplaceArgumentDefaultValueRector.php +++ b/rules/Arguments/Rector/ClassMethod/ReplaceArgumentDefaultValueRector.php @@ -53,15 +53,13 @@ public function getRuleDefinition(): RuleDefinition CODE_SAMPLE , [ - self::REPLACED_ARGUMENTS => [ - new ReplaceArgumentDefaultValue( - 'SomeClass', - 'someMethod', - 0, - 'SomeClass::OLD_CONSTANT', - false - ), - ], + new ReplaceArgumentDefaultValue( + 'SomeClass', + 'someMethod', + 0, + 'SomeClass::OLD_CONSTANT', + false + ), ] ), ] diff --git a/rules/Arguments/Rector/FuncCall/FunctionArgumentDefaultValueReplacerRector.php b/rules/Arguments/Rector/FuncCall/FunctionArgumentDefaultValueReplacerRector.php index e9f32b59122..2614f531241 100644 --- a/rules/Arguments/Rector/FuncCall/FunctionArgumentDefaultValueReplacerRector.php +++ b/rules/Arguments/Rector/FuncCall/FunctionArgumentDefaultValueReplacerRector.php @@ -50,11 +50,7 @@ public function getRuleDefinition(): RuleDefinition version_compare(PHP_VERSION, '5.6', 'ge'); CODE_SAMPLE , - [ - self::REPLACED_ARGUMENTS => [ - new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'gte', 'ge',), - ], - ] + [new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'gte', 'ge',)] ), ]); } diff --git a/rules/Arguments/Rector/FuncCall/SwapFuncCallArgumentsRector.php b/rules/Arguments/Rector/FuncCall/SwapFuncCallArgumentsRector.php index 26ff04a9ca4..826013ffac9 100644 --- a/rules/Arguments/Rector/FuncCall/SwapFuncCallArgumentsRector.php +++ b/rules/Arguments/Rector/FuncCall/SwapFuncCallArgumentsRector.php @@ -58,9 +58,7 @@ public function run($one, $two) } CODE_SAMPLE , - [ - self::FUNCTION_ARGUMENT_SWAPS => [new SwapFuncCallArguments('some_function', [1, 0])], - ] + [new SwapFuncCallArguments('some_function', [1, 0])], ), ]); } diff --git a/rules/Autodiscovery/Rector/Class_/MoveServicesBySuffixToDirectoryRector.php b/rules/Autodiscovery/Rector/Class_/MoveServicesBySuffixToDirectoryRector.php index 8bd1650dd7e..7547e055c69 100644 --- a/rules/Autodiscovery/Rector/Class_/MoveServicesBySuffixToDirectoryRector.php +++ b/rules/Autodiscovery/Rector/Class_/MoveServicesBySuffixToDirectoryRector.php @@ -65,9 +65,7 @@ class ProductRepository } CODE_SAMPLE , - [ - self::GROUP_NAMES_BY_SUFFIX => ['Repository'], - ] + ['Repository'] ), ]); } diff --git a/rules/CodingStyle/Rector/ClassMethod/OrderAttributesRector.php b/rules/CodingStyle/Rector/ClassMethod/OrderAttributesRector.php index 4fa58f548c0..1b1dfefdca3 100644 --- a/rules/CodingStyle/Rector/ClassMethod/OrderAttributesRector.php +++ b/rules/CodingStyle/Rector/ClassMethod/OrderAttributesRector.php @@ -54,9 +54,7 @@ class Someclass } CODE_SAMPLE , - [ - self::ATTRIBUTES_ORDER => ['First', 'Second'], - ] + ['First', 'Second'], ), ]); } diff --git a/rules/CodingStyle/Rector/ClassMethod/ReturnArrayClassMethodToYieldRector.php b/rules/CodingStyle/Rector/ClassMethod/ReturnArrayClassMethodToYieldRector.php index d5e90411c14..102df069278 100644 --- a/rules/CodingStyle/Rector/ClassMethod/ReturnArrayClassMethodToYieldRector.php +++ b/rules/CodingStyle/Rector/ClassMethod/ReturnArrayClassMethodToYieldRector.php @@ -73,11 +73,7 @@ public static function provideData() } CODE_SAMPLE , - [ - self::METHODS_TO_YIELDS => [ - new ReturnArrayClassMethodToYield('PHPUnit\Framework\TestCase', '*provide*'), - ], - ] + [new ReturnArrayClassMethodToYield('PHPUnit\Framework\TestCase', '*provide*')] ), ]); } diff --git a/rules/CodingStyle/Rector/MethodCall/PreferThisOrSelfMethodCallRector.php b/rules/CodingStyle/Rector/MethodCall/PreferThisOrSelfMethodCallRector.php index b80c7453ac3..a1d857248ba 100644 --- a/rules/CodingStyle/Rector/MethodCall/PreferThisOrSelfMethodCallRector.php +++ b/rules/CodingStyle/Rector/MethodCall/PreferThisOrSelfMethodCallRector.php @@ -64,9 +64,7 @@ public function run() CODE_SAMPLE , [ - self::TYPE_TO_PREFERENCE => [ - 'PHPUnit\Framework\TestCase' => PreferenceSelfThis::PREFER_SELF(), - ], + 'PHPUnit\Framework\TestCase' => PreferenceSelfThis::PREFER_SELF(), ] ), ]); diff --git a/rules/Composer/Rector/AddPackageToRequireComposerRector.php b/rules/Composer/Rector/AddPackageToRequireComposerRector.php index 3e9716eefda..d2ddc8dfa49 100644 --- a/rules/Composer/Rector/AddPackageToRequireComposerRector.php +++ b/rules/Composer/Rector/AddPackageToRequireComposerRector.php @@ -55,9 +55,7 @@ public function getRuleDefinition(): RuleDefinition } CODE_SAMPLE , - [ - self::PACKAGES_AND_VERSIONS => [new PackageAndVersion('symfony/console', '^3.4')], - ] + [new PackageAndVersion('symfony/console', '^3.4')] ), ]); } diff --git a/rules/Composer/Rector/AddPackageToRequireDevComposerRector.php b/rules/Composer/Rector/AddPackageToRequireDevComposerRector.php index af990ba2194..ff7951801cd 100644 --- a/rules/Composer/Rector/AddPackageToRequireDevComposerRector.php +++ b/rules/Composer/Rector/AddPackageToRequireDevComposerRector.php @@ -58,9 +58,7 @@ public function getRuleDefinition(): RuleDefinition } CODE_SAMPLE , - [ - self::PACKAGES_AND_VERSIONS => [new PackageAndVersion('symfony/console', '^3.4')], - ] + [new PackageAndVersion('symfony/console', '^3.4')] ), ]); } diff --git a/rules/Composer/Rector/ChangePackageVersionComposerRector.php b/rules/Composer/Rector/ChangePackageVersionComposerRector.php index f0fd8053e93..08289c40439 100644 --- a/rules/Composer/Rector/ChangePackageVersionComposerRector.php +++ b/rules/Composer/Rector/ChangePackageVersionComposerRector.php @@ -61,9 +61,7 @@ public function getRuleDefinition(): RuleDefinition } CODE_SAMPLE , - [ - self::PACKAGES_AND_VERSIONS => [new PackageAndVersion('symfony/console', '^4.4')], - ] + [new PackageAndVersion('symfony/console', '^4.4')] ), ]); } diff --git a/rules/Composer/Rector/RemovePackageComposerRector.php b/rules/Composer/Rector/RemovePackageComposerRector.php index 3c755d41e13..a60c0045913 100644 --- a/rules/Composer/Rector/RemovePackageComposerRector.php +++ b/rules/Composer/Rector/RemovePackageComposerRector.php @@ -34,8 +34,9 @@ public function refactor(ComposerJson $composerJson): void public function getRuleDefinition(): RuleDefinition { - return new RuleDefinition('Remove package from "require" and "require-dev" in `composer.json`', [new ConfiguredCodeSample( - <<<'CODE_SAMPLE' + return new RuleDefinition('Remove package from "require" and "require-dev" in `composer.json`', [ + new ConfiguredCodeSample( + <<<'CODE_SAMPLE' { "require": { "symfony/console": "^3.4" @@ -43,15 +44,13 @@ public function getRuleDefinition(): RuleDefinition } CODE_SAMPLE , - <<<'CODE_SAMPLE' + <<<'CODE_SAMPLE' { } CODE_SAMPLE , - [ - self::PACKAGE_NAMES => ['symfony/console'], - ] - ), + ['symfony/console'] + ), ]); } diff --git a/rules/Composer/Rector/RenamePackageComposerRector.php b/rules/Composer/Rector/RenamePackageComposerRector.php index 21a1bed3a20..b6c11992b69 100644 --- a/rules/Composer/Rector/RenamePackageComposerRector.php +++ b/rules/Composer/Rector/RenamePackageComposerRector.php @@ -68,9 +68,7 @@ public function getRuleDefinition(): RuleDefinition } CODE_SAMPLE , - [ - self::RENAME_PACKAGES => [new RenamePackage('rector/rector', 'rector/rector-src')], - ] + [new RenamePackage('rector/rector', 'rector/rector-src')] ), ]); } diff --git a/rules/Composer/Rector/ReplacePackageAndVersionComposerRector.php b/rules/Composer/Rector/ReplacePackageAndVersionComposerRector.php index a7eed3ee811..81a51731f4a 100644 --- a/rules/Composer/Rector/ReplacePackageAndVersionComposerRector.php +++ b/rules/Composer/Rector/ReplacePackageAndVersionComposerRector.php @@ -62,13 +62,7 @@ public function getRuleDefinition(): RuleDefinition } CODE_SAMPLE , - [ - self::REPLACE_PACKAGES_AND_VERSIONS => [new ReplacePackageAndVersion( - 'symfony/console', - 'symfony/http-kernel', - '^4.4' - )], - ] + [new ReplacePackageAndVersion('symfony/console', 'symfony/http-kernel', '^4.4')] ), ]); } diff --git a/rules/DeadCode/Rector/ClassLike/RemoveAnnotationRector.php b/rules/DeadCode/Rector/ClassLike/RemoveAnnotationRector.php index 41137c9bdc3..e872f47623d 100644 --- a/rules/DeadCode/Rector/ClassLike/RemoveAnnotationRector.php +++ b/rules/DeadCode/Rector/ClassLike/RemoveAnnotationRector.php @@ -57,9 +57,7 @@ final class SomeClass } CODE_SAMPLE , - [ - self::ANNOTATIONS_TO_REMOVE => ['method'], - ] + ['method'], ), ]); } diff --git a/rules/DependencyInjection/Rector/ClassMethod/AddMethodParentCallRector.php b/rules/DependencyInjection/Rector/ClassMethod/AddMethodParentCallRector.php index 8a542c66e94..cf3d16b1836 100644 --- a/rules/DependencyInjection/Rector/ClassMethod/AddMethodParentCallRector.php +++ b/rules/DependencyInjection/Rector/ClassMethod/AddMethodParentCallRector.php @@ -62,9 +62,7 @@ public function __construct() CODE_SAMPLE , [ - self::METHODS_BY_PARENT_TYPES => [ - 'ParentClassWithNewConstructor' => MethodName::CONSTRUCT, - ], + 'ParentClassWithNewConstructor' => MethodName::CONSTRUCT, ] ), ] diff --git a/rules/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector.php b/rules/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector.php index 8a9ad49d572..72e45e4cb78 100644 --- a/rules/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector.php +++ b/rules/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector.php @@ -74,11 +74,7 @@ public function action() } CODE_SAMPLE , - [ - self::ATTRIBUTE_TO_ANNOTATION => [ - new DowngradeAttributeToAnnotation('Symfony\Component\Routing\Annotation\Route'), - ], - ] + [new DowngradeAttributeToAnnotation('Symfony\Component\Routing\Annotation\Route')] ), ]); } diff --git a/rules/Generics/Rector/ClassMethod/GenericClassMethodParamRector.php b/rules/Generics/Rector/ClassMethod/GenericClassMethodParamRector.php index 1b6d513f0aa..82f4d85a537 100644 --- a/rules/Generics/Rector/ClassMethod/GenericClassMethodParamRector.php +++ b/rules/Generics/Rector/ClassMethod/GenericClassMethodParamRector.php @@ -113,11 +113,7 @@ final class SomeClass implements SomeInterface } CODE_SAMPLE , - [ - self::GENERIC_CLASS_METHOD_PARAMS => [ - new GenericClassMethodParam('SomeInterface', 'getParams', 0, 'ParamInterface'), - ], - ] + [new GenericClassMethodParam('SomeInterface', 'getParams', 0, 'ParamInterface')] ), ]); } diff --git a/rules/Php55/Rector/String_/StringClassNameToClassConstantRector.php b/rules/Php55/Rector/String_/StringClassNameToClassConstantRector.php index 21f7d69afd8..f02902bf298 100644 --- a/rules/Php55/Rector/String_/StringClassNameToClassConstantRector.php +++ b/rules/Php55/Rector/String_/StringClassNameToClassConstantRector.php @@ -80,9 +80,7 @@ public function run() } CODE_SAMPLE , - [ - self::CLASSES_TO_SKIP => ['ClassName', 'AnotherClassName'], - ] + ['ClassName', 'AnotherClassName'], ), ]); } diff --git a/rules/Php71/Rector/Name/ReservedObjectRector.php b/rules/Php71/Rector/Name/ReservedObjectRector.php index f107afd0f35..d7eb3c00a57 100644 --- a/rules/Php71/Rector/Name/ReservedObjectRector.php +++ b/rules/Php71/Rector/Name/ReservedObjectRector.php @@ -58,10 +58,8 @@ class SmartObject CODE_SAMPLE , [ - self::RESERVED_KEYWORDS_TO_REPLACEMENTS => [ - 'ReservedObject' => 'SmartObject', - 'Object' => 'AnotherSmartObject', - ], + 'ReservedObject' => 'SmartObject', + 'Object' => 'AnotherSmartObject', ] ), ] diff --git a/rules/Php74/Rector/Function_/ReservedFnFunctionRector.php b/rules/Php74/Rector/Function_/ReservedFnFunctionRector.php index 21f383322a9..5beed37c673 100644 --- a/rules/Php74/Rector/Function_/ReservedFnFunctionRector.php +++ b/rules/Php74/Rector/Function_/ReservedFnFunctionRector.php @@ -74,9 +74,7 @@ function f($value) CODE_SAMPLE , [ - self::RESERVED_NAMES_TO_NEW_ONES => [ - 'fn' => 'someFunctionName', - ], + 'fn' => 'someFunctionName', ] ), ]); diff --git a/rules/Php80/Rector/Class_/AnnotationToAttributeRector.php b/rules/Php80/Rector/Class_/AnnotationToAttributeRector.php index a0617821a51..5213eb29598 100644 --- a/rules/Php80/Rector/Class_/AnnotationToAttributeRector.php +++ b/rules/Php80/Rector/Class_/AnnotationToAttributeRector.php @@ -88,11 +88,7 @@ public function action() } CODE_SAMPLE , - [ - self::ANNOTATION_TO_ATTRIBUTE => [ - new AnnotationToAttribute('Symfony\Component\Routing\Annotation\Route'), - ], - ] + [new AnnotationToAttribute('Symfony\Component\Routing\Annotation\Route')] ), ]); } diff --git a/rules/Privatization/Rector/MethodCall/ReplaceStringWithClassConstantRector.php b/rules/Privatization/Rector/MethodCall/ReplaceStringWithClassConstantRector.php index 41096977b38..bb31614621a 100644 --- a/rules/Privatization/Rector/MethodCall/ReplaceStringWithClassConstantRector.php +++ b/rules/Privatization/Rector/MethodCall/ReplaceStringWithClassConstantRector.php @@ -59,11 +59,7 @@ public function run() } CODE_SAMPLE , - [ - self::REPLACE_STRING_WITH_CLASS_CONSTANT => [ - new ReplaceStringWithClassConstant('SomeClass', 'call', 0, 'Placeholder'), - ], - ] + [new ReplaceStringWithClassConstant('SomeClass', 'call', 0, 'Placeholder')] ), ]); } diff --git a/rules/Removing/Rector/ClassMethod/ArgumentRemoverRector.php b/rules/Removing/Rector/ClassMethod/ArgumentRemoverRector.php index 968e069ba01..02d0a787901 100644 --- a/rules/Removing/Rector/ClassMethod/ArgumentRemoverRector.php +++ b/rules/Removing/Rector/ClassMethod/ArgumentRemoverRector.php @@ -48,9 +48,7 @@ public function getRuleDefinition(): RuleDefinition $someObject->someMethod(); CODE_SAMPLE , - [ - self::REMOVED_ARGUMENTS => [new ArgumentRemover('ExampleClass', 'someMethod', 0, [true])], - ] + [new ArgumentRemover('ExampleClass', 'someMethod', 0, [true])] ), ] ); diff --git a/rules/Removing/Rector/Class_/RemoveInterfacesRector.php b/rules/Removing/Rector/Class_/RemoveInterfacesRector.php index 714172028aa..dc3ce40416d 100644 --- a/rules/Removing/Rector/Class_/RemoveInterfacesRector.php +++ b/rules/Removing/Rector/Class_/RemoveInterfacesRector.php @@ -43,9 +43,7 @@ class SomeClass } CODE_SAMPLE , - [ - self::INTERFACES_TO_REMOVE => ['SomeInterface'], - ] + ['SomeInterface'] ), ]); } diff --git a/rules/Removing/Rector/Class_/RemoveParentRector.php b/rules/Removing/Rector/Class_/RemoveParentRector.php index a5bfb53578c..5004d165ad8 100644 --- a/rules/Removing/Rector/Class_/RemoveParentRector.php +++ b/rules/Removing/Rector/Class_/RemoveParentRector.php @@ -52,9 +52,7 @@ final class SomeClass } CODE_SAMPLE , - [ - self::PARENT_TYPES_TO_REMOVE => ['SomeParentClass'], - ] + ['SomeParentClass'] ), ]); } diff --git a/rules/Removing/Rector/Class_/RemoveTraitUseRector.php b/rules/Removing/Rector/Class_/RemoveTraitUseRector.php index e30199f00a6..0b38fab5278 100644 --- a/rules/Removing/Rector/Class_/RemoveTraitUseRector.php +++ b/rules/Removing/Rector/Class_/RemoveTraitUseRector.php @@ -48,9 +48,7 @@ class SomeClass } CODE_SAMPLE , - [ - self::TRAITS_TO_REMOVE => ['TraitNameToRemove'], - ] + ['TraitNameToRemove'] ), ]); } diff --git a/rules/Removing/Rector/FuncCall/RemoveFuncCallArgRector.php b/rules/Removing/Rector/FuncCall/RemoveFuncCallArgRector.php index 0f63066bca8..73213b3bcab 100644 --- a/rules/Removing/Rector/FuncCall/RemoveFuncCallArgRector.php +++ b/rules/Removing/Rector/FuncCall/RemoveFuncCallArgRector.php @@ -41,9 +41,7 @@ public function getRuleDefinition(): RuleDefinition remove_last_arg(1); CODE_SAMPLE , - [ - self::REMOVED_FUNCTION_ARGUMENTS => [new RemoveFuncCallArg('remove_last_arg', 1)], - ] + [new RemoveFuncCallArg('remove_last_arg', 1)] ), ]); } diff --git a/rules/Removing/Rector/FuncCall/RemoveFuncCallRector.php b/rules/Removing/Rector/FuncCall/RemoveFuncCallRector.php index 23ec86bc94b..587a14cf354 100644 --- a/rules/Removing/Rector/FuncCall/RemoveFuncCallRector.php +++ b/rules/Removing/Rector/FuncCall/RemoveFuncCallRector.php @@ -38,13 +38,6 @@ public function __construct( public function getRuleDefinition(): RuleDefinition { - $configuration = [ - self::REMOVE_FUNC_CALLS => [ - new RemoveFuncCall('ini_get', [ - 1 => ['y2k_compliance'], - ]), - ], - ]; return new RuleDefinition( 'Remove ini_get by configuration', [ @@ -58,7 +51,11 @@ public function getRuleDefinition(): RuleDefinition ini_get('keep_me'); CODE_SAMPLE , - $configuration + [ + new RemoveFuncCall('ini_get', [ + 1 => ['y2k_compliance'], + ]), + ] ), ] ); } diff --git a/rules/Renaming/Rector/ClassConstFetch/RenameClassConstFetchRector.php b/rules/Renaming/Rector/ClassConstFetch/RenameClassConstFetchRector.php index 94f4474c197..e8ef90f5013 100644 --- a/rules/Renaming/Rector/ClassConstFetch/RenameClassConstFetchRector.php +++ b/rules/Renaming/Rector/ClassConstFetch/RenameClassConstFetchRector.php @@ -34,13 +34,6 @@ final class RenameClassConstFetchRector extends AbstractRector implements Config public function getRuleDefinition(): RuleDefinition { - $configuration = [ - self::CLASS_CONSTANT_RENAME => [ - new RenameClassConstFetch('SomeClass', 'OLD_CONSTANT', 'NEW_CONSTANT'), - new RenameClassAndConstFetch('SomeClass', 'OTHER_OLD_CONSTANT', 'DifferentClass', 'NEW_CONSTANT'), - ], - ]; - return new RuleDefinition( 'Replaces defined class constants in their calls.', [ @@ -55,7 +48,15 @@ public function getRuleDefinition(): RuleDefinition $value = DifferentClass::NEW_CONSTANT; CODE_SAMPLE , - $configuration + [ + new RenameClassConstFetch('SomeClass', 'OLD_CONSTANT', 'NEW_CONSTANT'), + new RenameClassAndConstFetch( + 'SomeClass', + 'OTHER_OLD_CONSTANT', + 'DifferentClass', + 'NEW_CONSTANT' + ), + ] ), ] ); diff --git a/rules/Renaming/Rector/ConstFetch/RenameConstantRector.php b/rules/Renaming/Rector/ConstFetch/RenameConstantRector.php index 914072d622c..c3110834817 100644 --- a/rules/Renaming/Rector/ConstFetch/RenameConstantRector.php +++ b/rules/Renaming/Rector/ConstFetch/RenameConstantRector.php @@ -53,10 +53,8 @@ public function run() CODE_SAMPLE , [ - self::OLD_TO_NEW_CONSTANTS => [ - 'MYSQL_ASSOC' => 'MYSQLI_ASSOC', - 'OLD_CONSTANT' => 'NEW_CONSTANT', - ], + 'MYSQL_ASSOC' => 'MYSQLI_ASSOC', + 'OLD_CONSTANT' => 'NEW_CONSTANT', ] ), ]); diff --git a/rules/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector.php b/rules/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector.php index 837c6f38e84..758b91609d2 100644 --- a/rules/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector.php +++ b/rules/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector.php @@ -68,11 +68,7 @@ public function getRuleDefinition(): RuleDefinition $someClassToKeep = new Some_Class_To_Keep; CODE_SAMPLE , - [ - self::NAMESPACE_PREFIXES_WITH_EXCLUDED_CLASSES => [ - new PseudoNamespaceToNamespace('Some_', ['Some_Class_To_Keep']), - ], - ] + [new PseudoNamespaceToNamespace('Some_', ['Some_Class_To_Keep'])] ), ]); } diff --git a/rules/Renaming/Rector/FuncCall/RenameFunctionRector.php b/rules/Renaming/Rector/FuncCall/RenameFunctionRector.php index be8e19a189b..5a384c9ff8c 100644 --- a/rules/Renaming/Rector/FuncCall/RenameFunctionRector.php +++ b/rules/Renaming/Rector/FuncCall/RenameFunctionRector.php @@ -37,9 +37,7 @@ public function getRuleDefinition(): RuleDefinition 'view("...", []);', 'Laravel\Templating\render("...", []);', [ - self::OLD_FUNCTION_TO_NEW_FUNCTION => [ - 'view' => 'Laravel\Templating\render', - ], + 'view' => 'Laravel\Templating\render', ] ), ]); diff --git a/rules/Renaming/Rector/MethodCall/RenameMethodRector.php b/rules/Renaming/Rector/MethodCall/RenameMethodRector.php index 17c5d2e88f8..1d09718bd53 100644 --- a/rules/Renaming/Rector/MethodCall/RenameMethodRector.php +++ b/rules/Renaming/Rector/MethodCall/RenameMethodRector.php @@ -58,11 +58,7 @@ public function getRuleDefinition(): RuleDefinition $someObject->newMethod(); CODE_SAMPLE , - [ - self::METHOD_CALL_RENAMES => [ - new MethodCallRename('SomeExampleClass', 'oldMethod', 'newMethod'), - ], - ] + [new MethodCallRename('SomeExampleClass', 'oldMethod', 'newMethod')] ), ]); } diff --git a/rules/Renaming/Rector/Name/RenameClassRector.php b/rules/Renaming/Rector/Name/RenameClassRector.php index bea0195f7bc..7d9b10db84c 100644 --- a/rules/Renaming/Rector/Name/RenameClassRector.php +++ b/rules/Renaming/Rector/Name/RenameClassRector.php @@ -70,9 +70,7 @@ function someFunction(SomeNewClass $someOldClass): SomeNewClass CODE_SAMPLE , [ - self::OLD_TO_NEW_CLASSES => [ - 'App\SomeOldClass' => 'App\SomeNewClass', - ], + 'App\SomeOldClass' => 'App\SomeNewClass', ] ), ]); diff --git a/rules/Renaming/Rector/Namespace_/RenameNamespaceRector.php b/rules/Renaming/Rector/Namespace_/RenameNamespaceRector.php index 57c4c0968ac..1e73f32ee31 100644 --- a/rules/Renaming/Rector/Namespace_/RenameNamespaceRector.php +++ b/rules/Renaming/Rector/Namespace_/RenameNamespaceRector.php @@ -53,9 +53,7 @@ public function getRuleDefinition(): RuleDefinition '$someObject = new SomeOldNamespace\SomeClass;', '$someObject = new SomeNewNamespace\SomeClass;', [ - self::OLD_TO_NEW_NAMESPACES => [ - 'SomeOldNamespace' => 'SomeNewNamespace', - ], + 'SomeOldNamespace' => 'SomeNewNamespace', ] ), ]); diff --git a/rules/Renaming/Rector/PropertyFetch/RenamePropertyRector.php b/rules/Renaming/Rector/PropertyFetch/RenamePropertyRector.php index a8d051c8cad..656593cdc3a 100644 --- a/rules/Renaming/Rector/PropertyFetch/RenamePropertyRector.php +++ b/rules/Renaming/Rector/PropertyFetch/RenamePropertyRector.php @@ -41,11 +41,7 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( '$someObject->someOldProperty;', '$someObject->someNewProperty;', - [ - self::RENAMED_PROPERTIES => [ - new RenameProperty('SomeClass', 'someOldProperty', 'someNewProperty'), - ], - ] + [new RenameProperty('SomeClass', 'someOldProperty', 'someNewProperty')] ), ]); } diff --git a/rules/Renaming/Rector/StaticCall/RenameStaticMethodRector.php b/rules/Renaming/Rector/StaticCall/RenameStaticMethodRector.php index b112215964f..d2c672eb0cd 100644 --- a/rules/Renaming/Rector/StaticCall/RenameStaticMethodRector.php +++ b/rules/Renaming/Rector/StaticCall/RenameStaticMethodRector.php @@ -25,11 +25,6 @@ final class RenameStaticMethodRector extends AbstractRector implements Configura */ final public const OLD_TO_NEW_METHODS_BY_CLASSES = 'old_to_new_method_by_classes'; - /** - * @var string - */ - private const SOME_CLASS = 'SomeClass'; - /** * @var RenameStaticMethod[] */ @@ -37,28 +32,11 @@ final class RenameStaticMethodRector extends AbstractRector implements Configura public function getRuleDefinition(): RuleDefinition { - $renameClassConfiguration = [ - self::OLD_TO_NEW_METHODS_BY_CLASSES => [ - new RenameStaticMethod(self::SOME_CLASS, 'oldMethod', 'AnotherExampleClass', 'newStaticMethod'), - ], - ]; - - $renameMethodConfiguration = [ - self::OLD_TO_NEW_METHODS_BY_CLASSES => [ - new RenameStaticMethod(self::SOME_CLASS, 'oldMethod', self::SOME_CLASS, 'newStaticMethod'), - ], - ]; - return new RuleDefinition('Turns method names to new ones.', [ new ConfiguredCodeSample( 'SomeClass::oldStaticMethod();', 'AnotherExampleClass::newStaticMethod();', - $renameClassConfiguration - ), - new ConfiguredCodeSample( - 'SomeClass::oldStaticMethod();', - 'SomeClass::newStaticMethod();', - $renameMethodConfiguration + [new RenameStaticMethod('SomeClass', 'oldMethod', 'AnotherExampleClass', 'newStaticMethod')] ), ]); } diff --git a/rules/Renaming/Rector/String_/RenameStringRector.php b/rules/Renaming/Rector/String_/RenameStringRector.php index 1d103ed2f2c..165a9d23558 100644 --- a/rules/Renaming/Rector/String_/RenameStringRector.php +++ b/rules/Renaming/Rector/String_/RenameStringRector.php @@ -54,9 +54,7 @@ public function run() CODE_SAMPLE , [ - self::STRING_CHANGES => [ - 'ROLE_PREVIOUS_ADMIN' => 'IS_IMPERSONATOR', - ], + 'ROLE_PREVIOUS_ADMIN' => 'IS_IMPERSONATOR', ] ), ]); diff --git a/rules/Restoration/Rector/Namespace_/CompleteImportForPartialAnnotationRector.php b/rules/Restoration/Rector/Namespace_/CompleteImportForPartialAnnotationRector.php index c4530a3dd26..6795fdba75a 100644 --- a/rules/Restoration/Rector/Namespace_/CompleteImportForPartialAnnotationRector.php +++ b/rules/Restoration/Rector/Namespace_/CompleteImportForPartialAnnotationRector.php @@ -36,9 +36,11 @@ final class CompleteImportForPartialAnnotationRector extends AbstractRector impl public function getRuleDefinition(): RuleDefinition { - return new RuleDefinition('In case you have accidentally removed use imports but code still contains partial use statements, this will save you', [ - new ConfiguredCodeSample( - <<<'CODE_SAMPLE' + return new RuleDefinition( + 'In case you have accidentally removed use imports but code still contains partial use statements, this will save you', + [ + new ConfiguredCodeSample( + <<<'CODE_SAMPLE' class SomeClass { /** @@ -47,8 +49,8 @@ class SomeClass public $id; } CODE_SAMPLE - , - <<<'CODE_SAMPLE' + , + <<<'CODE_SAMPLE' use Doctrine\ORM\Mapping as ORM; class SomeClass @@ -59,14 +61,12 @@ class SomeClass public $id; } CODE_SAMPLE - , - [ - self::USE_IMPORTS_TO_RESTORE => [ - new CompleteImportForPartialAnnotation('Doctrine\ORM\Mapping', 'ORM'), - ], - ] - ), - ]); + , + [new CompleteImportForPartialAnnotation('Doctrine\ORM\Mapping', 'ORM')] + ), + + ] + ); } /** diff --git a/rules/Transform/Rector/Assign/DimFetchAssignToMethodCallRector.php b/rules/Transform/Rector/Assign/DimFetchAssignToMethodCallRector.php index 7afa87eb733..3ce24fb9f54 100644 --- a/rules/Transform/Rector/Assign/DimFetchAssignToMethodCallRector.php +++ b/rules/Transform/Rector/Assign/DimFetchAssignToMethodCallRector.php @@ -66,13 +66,11 @@ public static function createRouter() CODE_SAMPLE , [ - self::DIM_FETCH_ASSIGN_TO_METHOD_CALL => [ - new DimFetchAssignToMethodCall( - 'Nette\Application\Routers\RouteList', - 'Nette\Application\Routers\Route', - 'addRoute' - ), - ], + new DimFetchAssignToMethodCall( + 'Nette\Application\Routers\RouteList', + 'Nette\Application\Routers\Route', + 'addRoute' + ), ] ), ] diff --git a/rules/Transform/Rector/Assign/GetAndSetToMethodCallRector.php b/rules/Transform/Rector/Assign/GetAndSetToMethodCallRector.php index 87b430c06bf..97890d7cb7c 100644 --- a/rules/Transform/Rector/Assign/GetAndSetToMethodCallRector.php +++ b/rules/Transform/Rector/Assign/GetAndSetToMethodCallRector.php @@ -56,11 +56,7 @@ public function getRuleDefinition(): RuleDefinition $container->setService("someService", $someService); CODE_SAMPLE , - [ - self::TYPE_TO_METHOD_CALLS => [ - new GetAndSetToMethodCall('SomeContainer', 'addService', 'getService'), - ], - ] + [new GetAndSetToMethodCall('SomeContainer', 'addService', 'getService')] ), ]); } diff --git a/rules/Transform/Rector/Assign/PropertyAssignToMethodCallRector.php b/rules/Transform/Rector/Assign/PropertyAssignToMethodCallRector.php index 7153a9502c7..7ad38a9e86f 100644 --- a/rules/Transform/Rector/Assign/PropertyAssignToMethodCallRector.php +++ b/rules/Transform/Rector/Assign/PropertyAssignToMethodCallRector.php @@ -44,11 +44,7 @@ public function getRuleDefinition(): RuleDefinition $someObject->newMethodCall(false); CODE_SAMPLE , - [ - self::PROPERTY_ASSIGNS_TO_METHODS_CALLS => [ - new PropertyAssignToMethodCall('SomeClass', 'oldProperty', 'newMethodCall'), - ], - ] + [new PropertyAssignToMethodCall('SomeClass', 'oldProperty', 'newMethodCall')] ), ]); } diff --git a/rules/Transform/Rector/Assign/PropertyFetchToMethodCallRector.php b/rules/Transform/Rector/Assign/PropertyFetchToMethodCallRector.php index 81a5c117ab3..9e9a720f1b4 100644 --- a/rules/Transform/Rector/Assign/PropertyFetchToMethodCallRector.php +++ b/rules/Transform/Rector/Assign/PropertyFetchToMethodCallRector.php @@ -33,41 +33,26 @@ final class PropertyFetchToMethodCallRector extends AbstractRector implements Co public function getRuleDefinition(): RuleDefinition { - $firstConfiguration = [ - self::PROPERTIES_TO_METHOD_CALLS => [ - new PropertyFetchToMethodCall('SomeObject', 'property', 'getProperty', 'setProperty'), - ], - ]; - - $secondConfiguration = [ - self::PROPERTIES_TO_METHOD_CALLS => [ - new PropertyFetchToMethodCall('SomeObject', 'property', 'getConfig', null, ['someArg']), - ], - ]; return new RuleDefinition('Replaces properties assign calls be defined methods.', [ new ConfiguredCodeSample( <<<'CODE_SAMPLE' $result = $object->property; $object->property = $value; + +$bare = $object->bareProperty; CODE_SAMPLE , <<<'CODE_SAMPLE' $result = $object->getProperty(); $object->setProperty($value); + +$bare = $object->getConfig('someArg'); CODE_SAMPLE , - $firstConfiguration - ), - new ConfiguredCodeSample( - <<<'CODE_SAMPLE' -$result = $object->property; -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -$result = $object->getProperty('someArg'); -CODE_SAMPLE - , - $secondConfiguration + [ + new PropertyFetchToMethodCall('SomeObject', 'property', 'getProperty', 'setProperty'), + new PropertyFetchToMethodCall('SomeObject', 'bareProperty', 'getConfig', null, ['someArg']), + ] ), ]); } diff --git a/rules/Transform/Rector/Attribute/AttributeKeyToClassConstFetchRector.php b/rules/Transform/Rector/Attribute/AttributeKeyToClassConstFetchRector.php index d115cd04ee8..b02f214930d 100644 --- a/rules/Transform/Rector/Attribute/AttributeKeyToClassConstFetchRector.php +++ b/rules/Transform/Rector/Attribute/AttributeKeyToClassConstFetchRector.php @@ -57,11 +57,9 @@ class SomeClass CODE_SAMPLE , [ - self::ATTRIBUTE_KEYS_TO_CLASS_CONST_FETCHES => [ - new AttributeKeyToClassConstFetch('Doctrine\ORM\Mapping\Column', 'type', 'Doctrine\DBAL\Types\Types', [ - 'string' => 'STRING', - ]), - ], + new AttributeKeyToClassConstFetch('Doctrine\ORM\Mapping\Column', 'type', 'Doctrine\DBAL\Types\Types', [ + 'string' => 'STRING', + ]), ] ), ]); diff --git a/rules/Transform/Rector/ClassMethod/SingleToManyMethodRector.php b/rules/Transform/Rector/ClassMethod/SingleToManyMethodRector.php index 5295e4e21a5..55f4b1dbb06 100644 --- a/rules/Transform/Rector/ClassMethod/SingleToManyMethodRector.php +++ b/rules/Transform/Rector/ClassMethod/SingleToManyMethodRector.php @@ -67,9 +67,7 @@ public function getNodes(): array } CODE_SAMPLE , - [ - self::SINGLES_TO_MANY_METHODS => [new SingleToManyMethod('SomeClass', 'getNode', 'getNodes')], - ] + [new SingleToManyMethod('SomeClass', 'getNode', 'getNodes')] ), ]); } diff --git a/rules/Transform/Rector/ClassMethod/WrapReturnRector.php b/rules/Transform/Rector/ClassMethod/WrapReturnRector.php index 1f89f519a01..24d03f2badb 100644 --- a/rules/Transform/Rector/ClassMethod/WrapReturnRector.php +++ b/rules/Transform/Rector/ClassMethod/WrapReturnRector.php @@ -55,9 +55,7 @@ public function getItem() } CODE_SAMPLE , - [ - self::TYPE_METHOD_WRAPS => [new WrapReturn('SomeClass', 'getItem', true)], - ] + [new WrapReturn('SomeClass', 'getItem', true)] ), ]); } diff --git a/rules/Transform/Rector/Class_/AddInterfaceByParentRector.php b/rules/Transform/Rector/Class_/AddInterfaceByParentRector.php index 7200af93b23..470503ab90e 100644 --- a/rules/Transform/Rector/Class_/AddInterfaceByParentRector.php +++ b/rules/Transform/Rector/Class_/AddInterfaceByParentRector.php @@ -50,9 +50,7 @@ class SomeClass extends SomeParent implements SomeInterface CODE_SAMPLE , [ - self::INTERFACE_BY_PARENT => [ - 'SomeParent' => 'SomeInterface', - ], + 'SomeParent' => 'SomeInterface', ] ), ]); diff --git a/rules/Transform/Rector/Class_/AddInterfaceByTraitRector.php b/rules/Transform/Rector/Class_/AddInterfaceByTraitRector.php index d1cb59859ce..a122c749cd2 100644 --- a/rules/Transform/Rector/Class_/AddInterfaceByTraitRector.php +++ b/rules/Transform/Rector/Class_/AddInterfaceByTraitRector.php @@ -50,9 +50,7 @@ class SomeClass implements SomeInterface CODE_SAMPLE , [ - self::INTERFACE_BY_TRAIT => [ - 'SomeTrait' => 'SomeInterface', - ], + 'SomeTrait' => 'SomeInterface', ] ), ]); diff --git a/rules/Transform/Rector/Class_/MergeInterfacesRector.php b/rules/Transform/Rector/Class_/MergeInterfacesRector.php index d45b78ad2a9..63d5992f222 100644 --- a/rules/Transform/Rector/Class_/MergeInterfacesRector.php +++ b/rules/Transform/Rector/Class_/MergeInterfacesRector.php @@ -50,9 +50,7 @@ class SomeClass implements SomeInterface CODE_SAMPLE , [ - self::OLD_TO_NEW_INTERFACES => [ - 'SomeOldInterface' => 'SomeInterface', - ], + 'SomeOldInterface' => 'SomeInterface', ] ), ]); diff --git a/rules/Transform/Rector/Class_/ParentClassToTraitsRector.php b/rules/Transform/Rector/Class_/ParentClassToTraitsRector.php index 278b3d044be..d88ec36d4ec 100644 --- a/rules/Transform/Rector/Class_/ParentClassToTraitsRector.php +++ b/rules/Transform/Rector/Class_/ParentClassToTraitsRector.php @@ -57,11 +57,7 @@ class SomeClass } CODE_SAMPLE , - [ - self::PARENT_CLASS_TO_TRAITS => [ - new ParentClassToTraits('Nette\Object', ['Nette\SmartObject']), - ], - ] + [new ParentClassToTraits('Nette\Object', ['Nette\SmartObject'])] ), ]); } diff --git a/rules/Transform/Rector/FuncCall/ArgumentFuncCallToMethodCallRector.php b/rules/Transform/Rector/FuncCall/ArgumentFuncCallToMethodCallRector.php index 48fb4ed7a28..4e744f183f5 100644 --- a/rules/Transform/Rector/FuncCall/ArgumentFuncCallToMethodCallRector.php +++ b/rules/Transform/Rector/FuncCall/ArgumentFuncCallToMethodCallRector.php @@ -85,11 +85,7 @@ public function action() } CODE_SAMPLE , - [ - self::FUNCTIONS_TO_METHOD_CALLS => [ - new ArgumentFuncCallToMethodCall('view', 'Illuminate\Contracts\View\Factory', 'make'), - ], - ] + [new ArgumentFuncCallToMethodCall('view', 'Illuminate\Contracts\View\Factory', 'make')] ), ]); } diff --git a/rules/Transform/Rector/FuncCall/FuncCallToConstFetchRector.php b/rules/Transform/Rector/FuncCall/FuncCallToConstFetchRector.php index 9be7b112731..602a161d210 100644 --- a/rules/Transform/Rector/FuncCall/FuncCallToConstFetchRector.php +++ b/rules/Transform/Rector/FuncCall/FuncCallToConstFetchRector.php @@ -54,9 +54,7 @@ public function run() CODE_SAMPLE , [ - self::FUNCTIONS_TO_CONSTANTS => [ - 'php_sapi_name' => 'PHP_SAPI', - ], + 'php_sapi_name' => 'PHP_SAPI', ] ), diff --git a/rules/Transform/Rector/FuncCall/FuncCallToMethodCallRector.php b/rules/Transform/Rector/FuncCall/FuncCallToMethodCallRector.php index c0270228b8e..72caf077fb5 100644 --- a/rules/Transform/Rector/FuncCall/FuncCallToMethodCallRector.php +++ b/rules/Transform/Rector/FuncCall/FuncCallToMethodCallRector.php @@ -70,11 +70,7 @@ public function run() } CODE_SAMPLE , - [ - self::FUNC_CALL_TO_CLASS_METHOD_CALL => [ - new FuncCallToMethodCall('view', 'Namespaced\SomeRenderer', 'render'), - ], - ] + [new FuncCallToMethodCall('view', 'Namespaced\SomeRenderer', 'render')] ), ]); } diff --git a/rules/Transform/Rector/FuncCall/FuncCallToNewRector.php b/rules/Transform/Rector/FuncCall/FuncCallToNewRector.php index 1bdfae2e880..bb3ed03a4f6 100644 --- a/rules/Transform/Rector/FuncCall/FuncCallToNewRector.php +++ b/rules/Transform/Rector/FuncCall/FuncCallToNewRector.php @@ -54,9 +54,7 @@ public function run() CODE_SAMPLE , [ - self::FUNCTIONS_TO_NEWS => [ - 'collection' => ['Collection'], - ], + 'collection' => ['Collection'], ] ), ]); diff --git a/rules/Transform/Rector/FuncCall/FuncCallToStaticCallRector.php b/rules/Transform/Rector/FuncCall/FuncCallToStaticCallRector.php index d446f286d22..f95ea566fe7 100644 --- a/rules/Transform/Rector/FuncCall/FuncCallToStaticCallRector.php +++ b/rules/Transform/Rector/FuncCall/FuncCallToStaticCallRector.php @@ -34,11 +34,7 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( 'view("...", []);', 'SomeClass::render("...", []);', - [ - self::FUNC_CALLS_TO_STATIC_CALLS => [ - new FuncCallToStaticCall('view', 'SomeStaticClass', 'render'), - ], - ] + [new FuncCallToStaticCall('view', 'SomeStaticClass', 'render')] ), ]); } diff --git a/rules/Transform/Rector/Isset_/UnsetAndIssetToMethodCallRector.php b/rules/Transform/Rector/Isset_/UnsetAndIssetToMethodCallRector.php index 4d15a07e13f..92eb8e15b56 100644 --- a/rules/Transform/Rector/Isset_/UnsetAndIssetToMethodCallRector.php +++ b/rules/Transform/Rector/Isset_/UnsetAndIssetToMethodCallRector.php @@ -32,8 +32,6 @@ final class UnsetAndIssetToMethodCallRector extends AbstractRector implements Co public function getRuleDefinition(): RuleDefinition { - $unsetAndIssetToMethodCall = new UnsetAndIssetToMethodCall('SomeContainer', 'hasService', 'removeService'); - return new RuleDefinition('Turns defined `__isset`/`__unset` calls to specific method calls.', [ new ConfiguredCodeSample( <<<'CODE_SAMPLE' @@ -48,9 +46,7 @@ public function getRuleDefinition(): RuleDefinition $container->removeService("someKey"); CODE_SAMPLE , - [ - self::ISSET_UNSET_TO_METHOD_CALL => [$unsetAndIssetToMethodCall], - ] + [new UnsetAndIssetToMethodCall('SomeContainer', 'hasService', 'removeService')] ), ]); } diff --git a/rules/Transform/Rector/MethodCall/CallableInMethodCallToVariableRector.php b/rules/Transform/Rector/MethodCall/CallableInMethodCallToVariableRector.php index 4ed618be75d..12f8432a2d0 100644 --- a/rules/Transform/Rector/MethodCall/CallableInMethodCallToVariableRector.php +++ b/rules/Transform/Rector/MethodCall/CallableInMethodCallToVariableRector.php @@ -68,11 +68,7 @@ public function run() } CODE_SAMPLE , - [ - self::CALLABLE_IN_METHOD_CALL_TO_VARIABLE => [ - new CallableInMethodCallToVariable('Nette\Caching\Cache', 'save', 1), - ], - ] + [new CallableInMethodCallToVariable('Nette\Caching\Cache', 'save', 1)] ), ]); } diff --git a/rules/Transform/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector.php b/rules/Transform/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector.php index d5b327e0b4a..3a172b5cba0 100644 --- a/rules/Transform/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector.php +++ b/rules/Transform/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector.php @@ -44,14 +44,12 @@ public function getRuleDefinition(): RuleDefinition CODE_SAMPLE , [ - self::METHOD_CALL_RENAMES_WITH_ADDED_ARGUMENTS => [ - new MethodCallToAnotherMethodCallWithArguments( - 'Nette\DI\ServiceDefinition', - 'setInject', - 'addTag', - ['inject'] - ), - ], + new MethodCallToAnotherMethodCallWithArguments( + 'Nette\DI\ServiceDefinition', + 'setInject', + 'addTag', + ['inject'] + ), ] ), ]); diff --git a/rules/Transform/Rector/MethodCall/MethodCallToPropertyFetchRector.php b/rules/Transform/Rector/MethodCall/MethodCallToPropertyFetchRector.php index 7eae2ccb259..d89b8a186df 100644 --- a/rules/Transform/Rector/MethodCall/MethodCallToPropertyFetchRector.php +++ b/rules/Transform/Rector/MethodCall/MethodCallToPropertyFetchRector.php @@ -53,9 +53,7 @@ public function run() CODE_SAMPLE , [ - self::METHOD_CALL_TO_PROPERTY_FETCHES => [ - 'someMethod' => 'someProperty', - ], + 'someMethod' => 'someProperty', ] ), ]); diff --git a/rules/Transform/Rector/MethodCall/MethodCallToStaticCallRector.php b/rules/Transform/Rector/MethodCall/MethodCallToStaticCallRector.php index 5f7a00b3dda..2b451df34be 100644 --- a/rules/Transform/Rector/MethodCall/MethodCallToStaticCallRector.php +++ b/rules/Transform/Rector/MethodCall/MethodCallToStaticCallRector.php @@ -66,11 +66,7 @@ public function loadConfiguration() } CODE_SAMPLE , - [ - self::METHOD_CALLS_TO_STATIC_CALLS => [ - new MethodCallToStaticCall('AnotherDependency', 'process', 'StaticCaller', 'anotherMethod'), - ], - ] + [new MethodCallToStaticCall('AnotherDependency', 'process', 'StaticCaller', 'anotherMethod')] ), ]); } diff --git a/rules/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector.php b/rules/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector.php index afc5287eca2..95ba469d96b 100644 --- a/rules/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector.php +++ b/rules/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector.php @@ -54,11 +54,7 @@ public function run(SomeTypeToReplace $someTypeToReplace) } CODE_SAMPLE , - [ - self::PARENT_CALLS_TO_PROPERTIES => [ - new ReplaceParentCallByPropertyCall('SomeTypeToReplace', 'someMethodCall', 'someProperty'), - ], - ] + [new ReplaceParentCallByPropertyCall('SomeTypeToReplace', 'someMethodCall', 'someProperty')] ), ] ); diff --git a/rules/Transform/Rector/MethodCall/ServiceGetterToConstructorInjectionRector.php b/rules/Transform/Rector/MethodCall/ServiceGetterToConstructorInjectionRector.php index 3b197c08e15..ca0406390a4 100644 --- a/rules/Transform/Rector/MethodCall/ServiceGetterToConstructorInjectionRector.php +++ b/rules/Transform/Rector/MethodCall/ServiceGetterToConstructorInjectionRector.php @@ -114,11 +114,7 @@ public function run() } CODE_SAMPLE , - [ - self::METHOD_CALL_TO_SERVICES => [ - new ServiceGetterToConstructorInjection('FirstService', 'getAnotherService', 'AnotherService'), - ], - ] + [new ServiceGetterToConstructorInjection('FirstService', 'getAnotherService', 'AnotherService')] ), ]); } diff --git a/rules/Transform/Rector/New_/NewArgToMethodCallRector.php b/rules/Transform/Rector/New_/NewArgToMethodCallRector.php index 096b1bb15f2..417c59dd85b 100644 --- a/rules/Transform/Rector/New_/NewArgToMethodCallRector.php +++ b/rules/Transform/Rector/New_/NewArgToMethodCallRector.php @@ -57,9 +57,7 @@ public function run() } CODE_SAMPLE , - [ - self::NEW_ARGS_TO_METHOD_CALLS => [new NewArgToMethodCall('Dotenv', true, 'usePutenv')], - ] + [new NewArgToMethodCall('Dotenv', true, 'usePutenv')] ), ]); } diff --git a/rules/Transform/Rector/New_/NewToConstructorInjectionRector.php b/rules/Transform/Rector/New_/NewToConstructorInjectionRector.php index 50cef483189..29d75cc8199 100644 --- a/rules/Transform/Rector/New_/NewToConstructorInjectionRector.php +++ b/rules/Transform/Rector/New_/NewToConstructorInjectionRector.php @@ -81,9 +81,7 @@ public function run() } CODE_SAMPLE , - [ - self::TYPES_TO_CONSTRUCTOR_INJECTION => ['Validator'], - ] + ['Validator'] ), ]); } diff --git a/rules/Transform/Rector/New_/NewToMethodCallRector.php b/rules/Transform/Rector/New_/NewToMethodCallRector.php index 8ec704606b3..4755b7b23cd 100644 --- a/rules/Transform/Rector/New_/NewToMethodCallRector.php +++ b/rules/Transform/Rector/New_/NewToMethodCallRector.php @@ -69,9 +69,7 @@ public function example() { } CODE_SAMPLE , - [ - self::NEWS_TO_METHOD_CALLS => [new NewToMethodCall('MyClass', 'MyClassFactory', 'create')], - ] + [new NewToMethodCall('MyClass', 'MyClassFactory', 'create')] ), ]); } diff --git a/rules/Transform/Rector/New_/NewToStaticCallRector.php b/rules/Transform/Rector/New_/NewToStaticCallRector.php index 19cd29d3f15..2260a3b734b 100644 --- a/rules/Transform/Rector/New_/NewToStaticCallRector.php +++ b/rules/Transform/Rector/New_/NewToStaticCallRector.php @@ -52,9 +52,7 @@ public function run() } CODE_SAMPLE , - [ - self::TYPE_TO_STATIC_CALLS => [new NewToStaticCall('Cookie', 'Cookie', 'create')], - ] + [new NewToStaticCall('Cookie', 'Cookie', 'create')] ), ]); } diff --git a/rules/Transform/Rector/StaticCall/StaticCallToFuncCallRector.php b/rules/Transform/Rector/StaticCall/StaticCallToFuncCallRector.php index 0554acf0d70..6819702ccff 100644 --- a/rules/Transform/Rector/StaticCall/StaticCallToFuncCallRector.php +++ b/rules/Transform/Rector/StaticCall/StaticCallToFuncCallRector.php @@ -39,11 +39,7 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( 'OldClass::oldMethod("args");', 'new_function("args");', - [ - self::STATIC_CALLS_TO_FUNCTIONS => [ - new StaticCallToFuncCall('OldClass', 'oldMethod', 'new_function'), - ], - ] + [new StaticCallToFuncCall('OldClass', 'oldMethod', 'new_function')] ), ]); } diff --git a/rules/Transform/Rector/StaticCall/StaticCallToMethodCallRector.php b/rules/Transform/Rector/StaticCall/StaticCallToMethodCallRector.php index cb85489ef46..5dfd84c7bda 100644 --- a/rules/Transform/Rector/StaticCall/StaticCallToMethodCallRector.php +++ b/rules/Transform/Rector/StaticCall/StaticCallToMethodCallRector.php @@ -80,14 +80,12 @@ public function run() CODE_SAMPLE , [ - self::STATIC_CALLS_TO_METHOD_CALLS => [ - new StaticCallToMethodCall( - 'Nette\Utils\FileSystem', - 'write', - 'Symplify\SmartFileSystem\SmartFileSystem', - 'dumpFile' - ), - ], + new StaticCallToMethodCall( + 'Nette\Utils\FileSystem', + 'write', + 'Symplify\SmartFileSystem\SmartFileSystem', + 'dumpFile' + ), ] ), ]); diff --git a/rules/Transform/Rector/StaticCall/StaticCallToNewRector.php b/rules/Transform/Rector/StaticCall/StaticCallToNewRector.php index 0f9fb169c41..2e31689ec1f 100644 --- a/rules/Transform/Rector/StaticCall/StaticCallToNewRector.php +++ b/rules/Transform/Rector/StaticCall/StaticCallToNewRector.php @@ -56,9 +56,7 @@ public function run() } CODE_SAMPLE , - [ - self::STATIC_CALLS_TO_NEWS => [new StaticCallToNew('JsonResponse', 'create')], - ] + [new StaticCallToNew('JsonResponse', 'create')] ), ]); } diff --git a/rules/Transform/Rector/String_/StringToClassConstantRector.php b/rules/Transform/Rector/String_/StringToClassConstantRector.php index 37cb5a6d82d..17e650c6322 100644 --- a/rules/Transform/Rector/String_/StringToClassConstantRector.php +++ b/rules/Transform/Rector/String_/StringToClassConstantRector.php @@ -52,11 +52,7 @@ public static function getSubscribedEvents() } CODE_SAMPLE , - [ - self::STRINGS_TO_CLASS_CONSTANTS => [ - new StringToClassConstant('compiler.post_dump', 'Yet\AnotherClass', 'CONSTANT'), - ], - ] + [new StringToClassConstant('compiler.post_dump', 'Yet\AnotherClass', 'CONSTANT')] ), ]); } diff --git a/rules/Transform/Rector/String_/ToStringToMethodCallRector.php b/rules/Transform/Rector/String_/ToStringToMethodCallRector.php index b8ab4a980f7..b1a11dc9ab5 100644 --- a/rules/Transform/Rector/String_/ToStringToMethodCallRector.php +++ b/rules/Transform/Rector/String_/ToStringToMethodCallRector.php @@ -48,9 +48,7 @@ public function getRuleDefinition(): RuleDefinition CODE_SAMPLE , [ - self::METHOD_NAMES_BY_TYPE => [ - 'SomeObject' => 'getPath', - ], + 'SomeObject' => 'getPath', ] ), ]); diff --git a/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeDeclarationRector.php b/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeDeclarationRector.php index e50f4d8e73f..ff2a4981f3a 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeDeclarationRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeDeclarationRector.php @@ -44,10 +44,6 @@ public function __construct( public function getRuleDefinition(): RuleDefinition { - $configuration = [ - self::PARAMETER_TYPEHINTS => [new AddParamTypeDeclaration('SomeClass', 'process', 0, new StringType())], - ]; - return new RuleDefinition('Add param types where needed', [ new ConfiguredCodeSample( <<<'CODE_SAMPLE' @@ -68,7 +64,7 @@ public function process(string $name) } CODE_SAMPLE , - $configuration + [new AddParamTypeDeclaration('SomeClass', 'process', 0, new StringType())] ), ]); } diff --git a/rules/TypeDeclaration/Rector/ClassMethod/AddReturnTypeDeclarationRector.php b/rules/TypeDeclaration/Rector/ClassMethod/AddReturnTypeDeclarationRector.php index 639d4fec7d9..937716cc128 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/AddReturnTypeDeclarationRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/AddReturnTypeDeclarationRector.php @@ -41,9 +41,6 @@ public function __construct( public function getRuleDefinition(): RuleDefinition { $arrayType = new ArrayType(new MixedType(), new MixedType()); - $configuration = [ - self::METHOD_RETURN_TYPES => [new AddReturnTypeDeclaration('SomeClass', 'getData', $arrayType)], - ]; return new RuleDefinition('Changes defined return typehint of method and class.', [ new ConfiguredCodeSample( @@ -65,7 +62,7 @@ public function getData(): array } CODE_SAMPLE , - $configuration + [new AddReturnTypeDeclaration('SomeClass', 'getData', $arrayType)] ), ]); } diff --git a/rules/Visibility/Rector/ClassConst/ChangeConstantVisibilityRector.php b/rules/Visibility/Rector/ClassConst/ChangeConstantVisibilityRector.php index 0b58e757c19..866f1a68210 100644 --- a/rules/Visibility/Rector/ClassConst/ChangeConstantVisibilityRector.php +++ b/rules/Visibility/Rector/ClassConst/ChangeConstantVisibilityRector.php @@ -65,11 +65,7 @@ class MyClass extends FrameworkClass } CODE_SAMPLE , - [ - self::CLASS_CONSTANT_VISIBILITY_CHANGES => [ - new ChangeConstantVisibility('ParentObject', 'SOME_CONSTANT', Visibility::PROTECTED), - ], - ] + [new ChangeConstantVisibility('ParentObject', 'SOME_CONSTANT', Visibility::PROTECTED)] ), ] ); diff --git a/rules/Visibility/Rector/ClassMethod/ChangeMethodVisibilityRector.php b/rules/Visibility/Rector/ClassMethod/ChangeMethodVisibilityRector.php index 6b6a7f636e7..66f511195bf 100644 --- a/rules/Visibility/Rector/ClassMethod/ChangeMethodVisibilityRector.php +++ b/rules/Visibility/Rector/ClassMethod/ChangeMethodVisibilityRector.php @@ -77,11 +77,7 @@ protected function someMethod() } CODE_SAMPLE , - [ - self::METHOD_VISIBILITIES => [ - new ChangeMethodVisibility('FrameworkClass', 'someMethod', Visibility::PROTECTED), - ], - ] + [new ChangeMethodVisibility('FrameworkClass', 'someMethod', Visibility::PROTECTED)] ), ] ); diff --git a/src/Console/Command/ProcessCommand.php b/src/Console/Command/ProcessCommand.php index 169b38bcde3..d31a87db7d5 100644 --- a/src/Console/Command/ProcessCommand.php +++ b/src/Console/Command/ProcessCommand.php @@ -102,7 +102,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->missedRectorDueVersionChecker->check($this->rectors); // 2. inform user about registering configurable rule without configuration - $this->emptyConfigurableRectorChecker->check($this->rectors); + $this->emptyConfigurableRectorChecker->check(); // 3. collect all files from files+dirs provided paths $files = $this->fileFactory->createFromPaths($paths, $configuration); diff --git a/src/NonPhpFile/Rector/RenameClassNonPhpRector.php b/src/NonPhpFile/Rector/RenameClassNonPhpRector.php index a09c9bb076c..ebaaa2314c3 100644 --- a/src/NonPhpFile/Rector/RenameClassNonPhpRector.php +++ b/src/NonPhpFile/Rector/RenameClassNonPhpRector.php @@ -62,9 +62,7 @@ public function getRuleDefinition(): RuleDefinition CODE_SAMPLE , [ - self::RENAME_CLASSES => [ - 'SomeOldClass' => 'SomeNewClass', - ], + 'SomeOldClass' => 'SomeNewClass', ] ), ] diff --git a/src/Validation/Collector/EmptyConfigurableRectorCollector.php b/src/Validation/Collector/EmptyConfigurableRectorCollector.php index e9993a8177f..9bbd3dd2ed1 100644 --- a/src/Validation/Collector/EmptyConfigurableRectorCollector.php +++ b/src/Validation/Collector/EmptyConfigurableRectorCollector.php @@ -5,80 +5,60 @@ namespace Rector\Core\Validation\Collector; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; -use Rector\Core\Contract\Rector\RectorInterface; use Rector\Core\NonPhpFile\Rector\RenameClassNonPhpRector; -use Rector\Naming\Naming\PropertyNaming; -use Symplify\PackageBuilder\Reflection\PrivatesAccessor; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Definition; +/** + * @see \Rector\Core\Tests\Validation\Collector\EmptyConfigurableRectorCollector\EmptyConfigurableRectorCollectorTest + */ final class EmptyConfigurableRectorCollector { public function __construct( - private readonly PrivatesAccessor $privatesAccessor, - private readonly PropertyNaming $propertyNaming + private readonly ContainerBuilder $containerBuilder ) { } /** - * @param RectorInterface[] $rectors - * @return RectorInterface[] + * @return array> */ - public function resolveEmptyConfigurable(array $rectors): array + public function resolveEmptyConfigurableRectorClasses(): array { - $emptyConfigurableRectors = []; - foreach ($rectors as $rector) { - if ($this->shouldSkip($rector)) { + $emptyConfigurableRectorClasses = []; + + foreach ($this->containerBuilder->getServiceIds() as $serviceId) { + if (! is_a($serviceId, ConfigurableRectorInterface::class, true)) { + continue; + } + + // it seems always loaded + if (is_a($serviceId, RenameClassNonPhpRector::class, true)) { + continue; + } + + $serviceDefinition = $this->containerBuilder->getDefinition($serviceId); + if ($this->hasConfigureMethodCall($serviceDefinition)) { continue; } - $emptyConfigurableRectors = $this->collectEmptyConfigurableRectors($rector, $emptyConfigurableRectors); + $emptyConfigurableRectorClasses[] = $serviceId; } - return $emptyConfigurableRectors; + return $emptyConfigurableRectorClasses; } - /** - * @param RectorInterface[] $emptyConfigurableRectors - * @return RectorInterface[] - */ - private function collectEmptyConfigurableRectors(RectorInterface $rector, array $emptyConfigurableRectors): array + private function hasConfigureMethodCall(Definition $definition): bool { - $ruleDefinition = $rector->getRuleDefinition(); - - /** @var ConfiguredCodeSample[] $codeSamples */ - $codeSamples = $ruleDefinition->getCodeSamples(); - foreach ($codeSamples as $codeSample) { - $configuration = $codeSample->getConfiguration(); - - foreach (array_keys($configuration) as $key) { - $key = $this->propertyNaming->underscoreToName($key); - if (! property_exists($rector, $key)) { - continue; - } - - // @see /~https://github.com/rectorphp/rector-laravel/pull/19 - if (str_starts_with($key, 'exclude')) { - continue; + foreach ($definition->getMethodCalls() as $methodCall) { + if ($methodCall[0] === 'configure') { + if (! isset($methodCall[1][0])) { + return false; } - $value = $this->privatesAccessor->getPrivateProperty($rector, $key); - if ($value === []) { - $emptyConfigurableRectors[] = $rector; - return $emptyConfigurableRectors; - } + return $methodCall[1][0] !== []; } } - return $emptyConfigurableRectors; - } - - private function shouldSkip(RectorInterface $rector): bool - { - if (! $rector instanceof ConfigurableRectorInterface) { - return true; - } - - // it seems always loaded - return $rector instanceof RenameClassNonPhpRector; + return false; } } diff --git a/src/Validation/EmptyConfigurableRectorChecker.php b/src/Validation/EmptyConfigurableRectorChecker.php index 75d38a7e6ac..145f5c6c51a 100644 --- a/src/Validation/EmptyConfigurableRectorChecker.php +++ b/src/Validation/EmptyConfigurableRectorChecker.php @@ -4,8 +4,7 @@ namespace Rector\Core\Validation; -use function count; -use Rector\Core\Contract\Rector\RectorInterface; +use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Validation\Collector\EmptyConfigurableRectorCollector; use Symfony\Component\Console\Style\SymfonyStyle; @@ -17,20 +16,17 @@ public function __construct( ) { } - /** - * @param RectorInterface[] $rectors - */ - public function check(array $rectors): void + public function check(): void { - $emptyConfigurableRectors = $this->emptyConfigurableRectorCollector->resolveEmptyConfigurable($rectors); - if ($emptyConfigurableRectors === []) { + $emptyConfigurableRectorClasses = $this->emptyConfigurableRectorCollector->resolveEmptyConfigurableRectorClasses(); + if ($emptyConfigurableRectorClasses === []) { return; } - $this->reportWarningMessage($emptyConfigurableRectors); + $this->reportWarningMessage($emptyConfigurableRectorClasses); $solutionMessage = sprintf( - 'Do you want to run them?%sConfigure them in `rector.php` with ...->call("configure", ...);', + 'Do you want to run them?%sConfigure them in `rector.php` with "...->configure(...);"', PHP_EOL ); $this->symfonyStyle->note($solutionMessage); @@ -42,18 +38,18 @@ public function check(array $rectors): void } /** - * @param RectorInterface[] $emptyConfigurableRectors + * @param array> $emptyConfigurableRectorClasses */ - private function reportWarningMessage(array $emptyConfigurableRectors): void + private function reportWarningMessage(array $emptyConfigurableRectorClasses): void { $warningMessage = sprintf( 'Your project contains %d configurable rector rules that are skipped as need to be configured to run.', - count($emptyConfigurableRectors) + count($emptyConfigurableRectorClasses) ); $this->symfonyStyle->warning($warningMessage); - foreach ($emptyConfigurableRectors as $emptyConfigurableRector) { - $this->symfonyStyle->writeln(' * ' . $emptyConfigurableRector::class); + foreach ($emptyConfigurableRectorClasses as $emptyConfigurableRectorClass) { + $this->symfonyStyle->writeln(' * ' . $emptyConfigurableRectorClass); } // to take time to absorb it diff --git a/tests/Validation/Collector/EmptyConfigurableRectorCollector/ConfigurableArrayHasValuesTest.php b/tests/Validation/Collector/EmptyConfigurableRectorCollector/ConfigurableArrayHasValuesTest.php deleted file mode 100644 index 5f72e845f05..00000000000 --- a/tests/Validation/Collector/EmptyConfigurableRectorCollector/ConfigurableArrayHasValuesTest.php +++ /dev/null @@ -1,31 +0,0 @@ -bootFromConfigFiles([__DIR__ . '/config/configurable_array_has_values.php']); - $this->collector = $this->getService(EmptyConfigurableRectorCollector::class); - } - - public function test(): void - { - $emptyConfigurableRectors = $this->collector->resolveEmptyConfigurable( - [$this->getService(AnnotationToAttributeRector::class)] - ); - $this->assertCount(0, $emptyConfigurableRectors); - } -} diff --git a/tests/Validation/Collector/EmptyConfigurableRectorCollector/ConfigurableArrayMissingTest.php b/tests/Validation/Collector/EmptyConfigurableRectorCollector/ConfigurableArrayMissingTest.php index f1150b8fbb9..1b3a4e7592b 100644 --- a/tests/Validation/Collector/EmptyConfigurableRectorCollector/ConfigurableArrayMissingTest.php +++ b/tests/Validation/Collector/EmptyConfigurableRectorCollector/ConfigurableArrayMissingTest.php @@ -5,7 +5,6 @@ namespace Rector\Core\Tests\Validation\Collector\EmptyConfigurableRectorCollector; use Rector\Core\Validation\Collector\EmptyConfigurableRectorCollector; -use Rector\Php80\Rector\Class_\AnnotationToAttributeRector; use Rector\Testing\PHPUnit\AbstractTestCase; /** @@ -23,9 +22,7 @@ protected function setUp(): void public function test(): void { - $emptyConfigurableRectors = $this->collector->resolveEmptyConfigurable( - [$this->getService(AnnotationToAttributeRector::class)] - ); + $emptyConfigurableRectors = $this->collector->resolveEmptyConfigurableRectorClasses(); $this->assertCount(1, $emptyConfigurableRectors); } } diff --git a/tests/Validation/Collector/EmptyConfigurableRectorCollector/ConfigurableNotArrayTest.php b/tests/Validation/Collector/EmptyConfigurableRectorCollector/ConfigurableNotArrayTest.php deleted file mode 100644 index 79f753fc6e1..00000000000 --- a/tests/Validation/Collector/EmptyConfigurableRectorCollector/ConfigurableNotArrayTest.php +++ /dev/null @@ -1,33 +0,0 @@ -bootFromConfigFiles([__DIR__ . '/config/configurable_not_array.php']); - $this->collector = $this->getService(EmptyConfigurableRectorCollector::class); - } - - public function test(): void - { - $emptyConfigurableRectors = $this->collector->resolveEmptyConfigurable( - [$this->getService(TypedPropertyRector::class)] - ); - $this->assertCount(0, $emptyConfigurableRectors); - } -} diff --git a/tests/Validation/Collector/EmptyConfigurableRectorCollector/EmptyConfigurableRectorCollectorTest.php b/tests/Validation/Collector/EmptyConfigurableRectorCollector/EmptyConfigurableRectorCollectorTest.php new file mode 100644 index 00000000000..f31cdc3af5b --- /dev/null +++ b/tests/Validation/Collector/EmptyConfigurableRectorCollector/EmptyConfigurableRectorCollectorTest.php @@ -0,0 +1,25 @@ +bootFromConfigFiles([__DIR__ . '/config/configurable_array_has_values.php']); + $this->emptyConfigurableRectorCollector = $this->getService(EmptyConfigurableRectorCollector::class); + } + + public function test(): void + { + $emptyConfigurableRectors = $this->emptyConfigurableRectorCollector->resolveEmptyConfigurableRectorClasses(); + $this->assertCount(0, $emptyConfigurableRectors); + } +} diff --git a/tests/Validation/Collector/EmptyConfigurableRectorCollector/EmptyConfigureTest.php b/tests/Validation/Collector/EmptyConfigurableRectorCollector/EmptyConfigureTest.php new file mode 100644 index 00000000000..8d218a01d56 --- /dev/null +++ b/tests/Validation/Collector/EmptyConfigurableRectorCollector/EmptyConfigureTest.php @@ -0,0 +1,25 @@ +bootFromConfigFiles([__DIR__ . '/config/empty_configure.php']); + $this->emptyConfigurableRectorCollector = $this->getService(EmptyConfigurableRectorCollector::class); + } + + public function test(): void + { + $emptyConfigurableRectors = $this->emptyConfigurableRectorCollector->resolveEmptyConfigurableRectorClasses(); + $this->assertCount(1, $emptyConfigurableRectors); + } +} diff --git a/tests/Validation/Collector/EmptyConfigurableRectorCollector/NotConfigurableRectorTest.php b/tests/Validation/Collector/EmptyConfigurableRectorCollector/NotConfigurableRectorTest.php deleted file mode 100644 index 2f0f7f304bc..00000000000 --- a/tests/Validation/Collector/EmptyConfigurableRectorCollector/NotConfigurableRectorTest.php +++ /dev/null @@ -1,31 +0,0 @@ -bootFromConfigFiles([__DIR__ . '/config/not_configurable.php']); - $this->collector = $this->getService(EmptyConfigurableRectorCollector::class); - } - - public function test(): void - { - $emptyConfigurableRectors = $this->collector->resolveEmptyConfigurable( - [$this->getService(ChangeLocalPropertyToVariableRector::class)] - ); - $this->assertCount(0, $emptyConfigurableRectors); - } -} diff --git a/tests/Validation/Collector/EmptyConfigurableRectorCollector/config/configurable_not_array.php b/tests/Validation/Collector/EmptyConfigurableRectorCollector/config/configurable_not_array.php deleted file mode 100644 index 21547d12b2c..00000000000 --- a/tests/Validation/Collector/EmptyConfigurableRectorCollector/config/configurable_not_array.php +++ /dev/null @@ -1,11 +0,0 @@ -services(); - $services->set(TypedPropertyRector::class); -}; diff --git a/tests/Validation/Collector/EmptyConfigurableRectorCollector/config/not_configurable.php b/tests/Validation/Collector/EmptyConfigurableRectorCollector/config/empty_configure.php similarity index 64% rename from tests/Validation/Collector/EmptyConfigurableRectorCollector/config/not_configurable.php rename to tests/Validation/Collector/EmptyConfigurableRectorCollector/config/empty_configure.php index 8ddab5d85a7..fcf50b34426 100644 --- a/tests/Validation/Collector/EmptyConfigurableRectorCollector/config/not_configurable.php +++ b/tests/Validation/Collector/EmptyConfigurableRectorCollector/config/empty_configure.php @@ -2,10 +2,12 @@ declare(strict_types=1); -use Rector\Privatization\Rector\Class_\ChangeLocalPropertyToVariableRector; +use Rector\Php80\Rector\Class_\AnnotationToAttributeRector; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); - $services->set(ChangeLocalPropertyToVariableRector::class); + + $services->set(AnnotationToAttributeRector::class) + ->configure([]); }; diff --git a/utils/compiler/src/PhpScoper/StaticEasyPrefixer.php b/utils/compiler/src/PhpScoper/StaticEasyPrefixer.php index 168eab45f91..7d5a1f2506d 100644 --- a/utils/compiler/src/PhpScoper/StaticEasyPrefixer.php +++ b/utils/compiler/src/PhpScoper/StaticEasyPrefixer.php @@ -38,9 +38,6 @@ final class StaticEasyPrefixer // this is public API of a Rector rule 'Symplify\RuleDocGenerator\*', - - // for configuring sets with ValueObjectInliner - 'Symplify\SymfonyPhpConfig\*', ]; /**