Removing single-rule elastic package set, merge Decomplex set to CodingStyle, merge FrameworkMigration to NetteToSymfony (#4079)

* drop elasticsearch-dsl50, used for single change, unmaintained

* [CodingStyleAdvanced] Move UseMessageVariableForSprintfInSymfonyStyleRector from single-rule set Decomplex to CodingStyleAdvanced

* merge FrameworkMigration with 1 class to NetteToSymfony

* [Transform] Move ServiceGetterToConstructorInjectionRector to Transform set

* [Transform] Move ReplaceParentCallByPropertyCallRector to Transform package

* [Transform] Move StaticCallToFunctionRector to Transform

* update docs

* [Transform] Move NewToStaticCallRector to Transform
This commit is contained in:
Tomas Votruba 2020-08-30 20:48:37 +02:00 committed by GitHub
parent 4584359f96
commit 3d03ec4beb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
50 changed files with 435 additions and 506 deletions

View File

@ -86,7 +86,6 @@
"Rector\\DynamicTypeAnalysis\\": "packages/dynamic-type-analysis/src",
"Rector\\DoctrineAnnotationGenerated\\": "packages/doctrine-annotation-generated/src",
"Rector\\FileSystemRector\\": "packages/file-system-rector/src",
"Rector\\FrameworkMigration\\": "rules/framework-migration/src",
"Rector\\FamilyTree\\": "packages/family-tree/src",
"Rector\\Guzzle\\": "rules/guzzle/src",
"Rector\\JMS\\": "rules/jms/src",
@ -150,7 +149,6 @@
"Rector\\NetteKdyby\\": "rules/nette-kdyby/src",
"Rector\\NetteUtilsCodeQuality\\": "rules/nette-utils-code-quality/src",
"Rector\\NetteCodeQuality\\": "rules/nette-code-quality/src",
"Rector\\Decomplex\\": "rules/decomplex/src",
"Rector\\Downgrade\\": "rules/downgrade/src",
"Rector\\SymfonyPhpConfig\\": "rules/symfony-php-config/src",
"Rector\\Injection\\": "rules/injection/src"
@ -236,7 +234,6 @@
"Rector\\NetteKdyby\\Tests\\": "rules/nette-kdyby/tests",
"Rector\\NetteUtilsCodeQuality\\Tests\\": "rules/nette-utils-code-quality/tests",
"Rector\\NetteCodeQuality\\Tests\\": "rules/nette-code-quality/tests",
"Rector\\Decomplex\\Tests\\": "rules/decomplex/tests",
"Rector\\Downgrade\\Tests\\": "rules/downgrade/tests",
"Rector\\SymfonyPhpConfig\\Tests\\": "rules/symfony-php-config/tests",
"Rector\\Injection\\Tests\\": "rules/injection/tests",

View File

@ -2,18 +2,10 @@
declare(strict_types=1);
use Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$parameters->set('project_directory', null);
$services = $containerConfigurator->services();
$services->defaults()
->public()
->autowire();
$services->load('Rector\FrameworkMigration\\', __DIR__ . '/../src');
$services->set(UseMessageVariableForSprintfInSymfonyStyleRector::class);
};

View File

@ -11,10 +11,10 @@ use Rector\Generic\Rector\Class_\AddPropertyByParentRector;
use Rector\Generic\Rector\Class_\RemoveParentRector;
use Rector\Generic\Rector\ClassLike\RemoveAnnotationRector;
use Rector\Generic\Rector\MethodCall\ReplaceParentCallByPropertyCallRector;
use Rector\Generic\ValueObject\ParentCallToProperty;
use Rector\Generic\ValueObject\ParentDependency;
use function Rector\SymfonyPhpConfig\inline_value_objects;
use Rector\Transform\Rector\MethodCall\MethodCallToPropertyFetchRector;
use Rector\Transform\ValueObject\ParentCallToProperty;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
/**

View File

@ -2,9 +2,9 @@
declare(strict_types=1);
use Rector\Generic\Rector\MethodCall\ServiceGetterToConstructorInjectionRector;
use Rector\Generic\ValueObject\MethodCallToService;
use function Rector\SymfonyPhpConfig\inline_value_objects;
use Rector\Transform\Rector\MethodCall\ServiceGetterToConstructorInjectionRector;
use Rector\Transform\ValueObject\MethodCallToService;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {

View File

@ -1,57 +0,0 @@
<?php
declare(strict_types=1);
use Rector\Renaming\Rector\Name\RenameClassRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
# https://github.com/ongr-io/ElasticsearchDSL/blob/5.x/CHANGELOG.md
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(RenameClassRector::class)
->call('configure', [[
RenameClassRector::OLD_TO_NEW_CLASSES => [
'ONGR\ElasticsearchDSL\Query\BoolQuery' => 'ONGR\ElasticsearchDSL\Query\Compound\BoolQuery',
'ONGR\ElasticsearchDSL\Query\BoostingQuery' => 'ONGR\ElasticsearchDSL\Query\Compound\BoostingQuery',
'ONGR\ElasticsearchDSL\Query\ConstantScoreQuery' => 'ONGR\ElasticsearchDSL\Query\Compound\ConstantScoreQuery',
'ONGR\ElasticsearchDSL\Query\DisMaxQuery' => 'ONGR\ElasticsearchDSL\Query\Compound\DisMaxQuery',
'ONGR\ElasticsearchDSL\Query\FunctionScoreQuery' => 'ONGR\ElasticsearchDSL\Query\Compound\FunctionScoreQuery',
'ONGR\ElasticsearchDSL\Query\IndicesQuery' => 'ONGR\ElasticsearchDSL\Query\Compound\IndicesQuery',
'ONGR\ElasticsearchDSL\Query\MatchQuery' => 'ONGR\ElasticsearchDSL\Query\FullText\MatchQuery',
'ONGR\ElasticsearchDSL\Query\CommonTermsQuery' => 'ONGR\ElasticsearchDSL\Query\FullText\CommonTermsQuery',
'ONGR\ElasticsearchDSL\Query\MatchPhrasePrefixQuery' => 'ONGR\ElasticsearchDSL\Query\FullText\MatchPhrasePrefixQuery',
'ONGR\ElasticsearchDSL\Query\MatchPhraseQuery' => 'ONGR\ElasticsearchDSL\Query\FullText\MatchPhraseQuery',
'ONGR\ElasticsearchDSL\Query\MultiMatchQuery' => 'ONGR\ElasticsearchDSL\Query\FullText\MultiMatchQuery',
'ONGR\ElasticsearchDSL\Query\QueryStringQuery' => 'ONGR\ElasticsearchDSL\Query\FullText\QueryStringQuery',
'ONGR\ElasticsearchDSL\Query\SimpleQueryStringQuery' => 'ONGR\ElasticsearchDSL\Query\FullText\SimpleQueryStringQuery',
'ONGR\ElasticsearchDSL\Query\ExistsQuery' => 'ONGR\ElasticsearchDSL\Query\TermLevel\ExistsQuery',
'ONGR\ElasticsearchDSL\Query\PrefixQuery' => 'ONGR\ElasticsearchDSL\Query\TermLevel\PrefixQuery',
'ONGR\ElasticsearchDSL\Query\RangeQuery' => 'ONGR\ElasticsearchDSL\Query\TermLevel\RangeQuery',
'ONGR\ElasticsearchDSL\Query\TermQuery' => 'ONGR\ElasticsearchDSL\Query\TermLevel\TermQuery',
'ONGR\ElasticsearchDSL\Query\TermsQuery' => 'ONGR\ElasticsearchDSL\Query\TermLevel\TermsQuery',
'ONGR\ElasticsearchDSL\Query\WildcardQuery' => 'ONGR\ElasticsearchDSL\Query\TermLevel\WildcardQuery',
'ONGR\ElasticsearchDSL\Query\FuzzyQuery' => 'ONGR\ElasticsearchDSL\Query\TermLevel\FuzzyQuery',
'ONGR\ElasticsearchDSL\Query\RegexpQuery' => 'ONGR\ElasticsearchDSL\Query\TermLevel\RegexpQuery',
'ONGR\ElasticsearchDSL\Query\TypeQuery' => 'ONGR\ElasticsearchDSL\Query\TermLevel\TypeQuery',
'ONGR\ElasticsearchDSL\Query\GeoBoundingBoxQuery' => 'ONGR\ElasticsearchDSL\Query\Geo\GeoBoundingBoxQuery',
'ONGR\ElasticsearchDSL\Query\GeoDistanceQuery' => 'ONGR\ElasticsearchDSL\Query\Geo\GeoDistanceQuery',
'ONGR\ElasticsearchDSL\Query\GeoDistanceRangeQuery' => 'ONGR\ElasticsearchDSL\Query\Geo\GeoDistanceRangeQuery',
'ONGR\ElasticsearchDSL\Query\GeoPolygonQuery' => 'ONGR\ElasticsearchDSL\Query\Geo\GeoPolygonQuery',
'ONGR\ElasticsearchDSL\Query\GeoShapeQuery' => 'ONGR\ElasticsearchDSL\Query\Geo\GeoShapeQuery',
'ONGR\ElasticsearchDSL\Query\HasChildQuery' => 'ONGR\ElasticsearchDSL\Query\Joining\HasChildQuery',
'ONGR\ElasticsearchDSL\Query\HasParentQuery' => 'ONGR\ElasticsearchDSL\Query\Joining\HasParentQuery',
'ONGR\ElasticsearchDSL\Query\NestedQuery' => 'ONGR\ElasticsearchDSL\Query\Joining\NestedQuery',
'ONGR\ElasticsearchDSL\Query\SpanContainingQuery' => 'ONGR\ElasticsearchDSL\Query\Span\SpanContainingQuery',
'ONGR\ElasticsearchDSL\Query\SpanFirstQuery' => 'ONGR\ElasticsearchDSL\Query\Span\SpanFirstQuery',
'ONGR\ElasticsearchDSL\Query\SpanMultiTermQuery' => 'ONGR\ElasticsearchDSL\Query\Span\SpanMultiTermQuery',
'ONGR\ElasticsearchDSL\Query\SpanNearQuery' => 'ONGR\ElasticsearchDSL\Query\Span\SpanNearQuery',
'ONGR\ElasticsearchDSL\Query\SpanNotQuery' => 'ONGR\ElasticsearchDSL\Query\Span\SpanNotQuery',
'ONGR\ElasticsearchDSL\Query\SpanOrQuery' => 'ONGR\ElasticsearchDSL\Query\Span\SpanOrQuery',
'ONGR\ElasticsearchDSL\Query\SpanWithinQuery' => 'ONGR\ElasticsearchDSL\Query\Span\SpanWithinQuery',
'ONGR\ElasticsearchDSL\Query\MoreLikeThisQuery' => 'ONGR\ElasticsearchDSL\Query\Specialized\MoreLikeThisQuery',
'ONGR\ElasticsearchDSL\Query\ScriptQuery' => 'ONGR\ElasticsearchDSL\Query\Specialized\ScriptQuery',
'ONGR\ElasticsearchDSL\Query\TemplateQuery' => 'ONGR\ElasticsearchDSL\Query\Specialized\TemplateQuery',
],
]]);
};

View File

@ -3,15 +3,15 @@
declare(strict_types=1);
use GuzzleHttp\Cookie\SetCookie;
use Rector\Generic\Rector\StaticCall\StaticCallToFunctionRector;
use Rector\Generic\ValueObject\StaticCallToFunction;
use Rector\Guzzle\Rector\MethodCall\MessageAsArrayRector;
use Rector\MagicDisclosure\Rector\MethodCall\FluentChainMethodCallToNormalMethodCallRector;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\ValueObject\MethodCallRename;
use function Rector\SymfonyPhpConfig\inline_value_objects;
use Rector\Transform\Rector\FuncCall\FuncCallToMethodCallRector;
use Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector;
use Rector\Transform\ValueObject\FuncNameToMethodCallName;
use Rector\Transform\ValueObject\StaticCallToFuncCall;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
@ -43,11 +43,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
FuncCallToMethodCallRector::FUNC_CALL_TO_CLASS_METHOD_CALL => inline_value_objects($configuration),
]]);
$services->set(StaticCallToFunctionRector::class)
$services->set(StaticCallToFuncCallRector::class)
->call('configure', [[
StaticCallToFunctionRector::STATIC_CALLS_TO_FUNCTIONS => inline_value_objects([
new StaticCallToFunction('GuzzleHttp\Utils', 'setPath', 'GuzzleHttp\set_path'),
new StaticCallToFunction('GuzzleHttp\Pool', 'batch', 'GuzzleHttp\Pool\batch'),
StaticCallToFuncCallRector::STATIC_CALLS_TO_FUNCTIONS => inline_value_objects([
new StaticCallToFuncCall('GuzzleHttp\Utils', 'setPath', 'GuzzleHttp\set_path'),
new StaticCallToFuncCall('GuzzleHttp\Pool', 'batch', 'GuzzleHttp\Pool\batch'),
]),
]]);

View File

@ -3,60 +3,58 @@
declare(strict_types=1);
use Rector\Generic\Rector\FuncCall\FuncCallToStaticCallRector;
use Rector\Generic\ValueObject\FuncNameToStaticCallName;
use function Rector\SymfonyPhpConfig\inline_value_objects;
use Rector\Transform\ValueObject\FuncNameToStaticCallName;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$configuration = [
new FuncNameToStaticCallName('array_add', 'Illuminate\Support\Arr', 'add'),
new FuncNameToStaticCallName('array_collapse', 'Illuminate\Support\Arr', 'collapse'),
new FuncNameToStaticCallName('array_divide', 'Illuminate\Support\Arr', 'divide'),
new FuncNameToStaticCallName('array_dot', 'Illuminate\Support\Arr', 'dot'),
new FuncNameToStaticCallName('array_except', 'Illuminate\Support\Arr', 'except'),
new FuncNameToStaticCallName('array_first', 'Illuminate\Support\Arr', 'first'),
new FuncNameToStaticCallName('array_flatten', 'Illuminate\Support\Arr', 'flatten'),
new FuncNameToStaticCallName('array_forget', 'Illuminate\Support\Arr', 'forget'),
new FuncNameToStaticCallName('array_get', 'Illuminate\Support\Arr', 'get'),
new FuncNameToStaticCallName('array_has', 'Illuminate\Support\Arr', 'has'),
new FuncNameToStaticCallName('array_last', 'Illuminate\Support\Arr', 'last'),
new FuncNameToStaticCallName('array_only', 'Illuminate\Support\Arr', 'only'),
new FuncNameToStaticCallName('array_pluck', 'Illuminate\Support\Arr', 'pluck'),
new FuncNameToStaticCallName('array_prepend', 'Illuminate\Support\Arr', 'prepend'),
new FuncNameToStaticCallName('array_pull', 'Illuminate\Support\Arr', 'pull'),
new FuncNameToStaticCallName('array_random', 'Illuminate\Support\Arr', 'random'),
new FuncNameToStaticCallName('array_sort', 'Illuminate\Support\Arr', 'sort'),
new FuncNameToStaticCallName('array_sort_recursive', 'Illuminate\Support\Arr', 'sortRecursive'),
new FuncNameToStaticCallName('array_where', 'Illuminate\Support\Arr', 'where'),
new FuncNameToStaticCallName('array_wrap', 'Illuminate\Support\Arr', 'wrap'),
new FuncNameToStaticCallName('array_set', 'Illuminate\Support\Arr', 'set'),
new FuncNameToStaticCallName('camel_case', 'Illuminate\Support\Str', 'camel'),
new FuncNameToStaticCallName('ends_with', 'Illuminate\Support\Str', 'endsWith'),
new FuncNameToStaticCallName('kebab_case', 'Illuminate\Support\Str', 'kebab'),
new FuncNameToStaticCallName('snake_case', 'Illuminate\Support\Str', 'snake'),
new FuncNameToStaticCallName('starts_with', 'Illuminate\Support\Str', 'startsWith'),
new FuncNameToStaticCallName('str_after', 'Illuminate\Support\Str', 'after'),
new FuncNameToStaticCallName('str_before', 'Illuminate\Support\Str', 'before'),
new FuncNameToStaticCallName('str_contains', 'Illuminate\Support\Str', 'contains'),
new FuncNameToStaticCallName('str_finish', 'Illuminate\Support\Str', 'finish'),
new FuncNameToStaticCallName('str_is', 'Illuminate\Support\Str', 'is'),
new FuncNameToStaticCallName('str_limit', 'Illuminate\Support\Str', 'limit'),
new FuncNameToStaticCallName('str_plural', 'Illuminate\Support\Str', 'plural'),
new FuncNameToStaticCallName('str_random', 'Illuminate\Support\Str', 'random'),
new FuncNameToStaticCallName('str_replace_array', 'Illuminate\Support\Str', 'replaceArray'),
new FuncNameToStaticCallName('str_replace_first', 'Illuminate\Support\Str', 'replaceFirst'),
new FuncNameToStaticCallName('str_replace_last', 'Illuminate\Support\Str', 'replaceLast'),
new FuncNameToStaticCallName('str_singular', 'Illuminate\Support\Str', 'singular'),
new FuncNameToStaticCallName('str_slug', 'Illuminate\Support\Str', 'slug'),
new FuncNameToStaticCallName('str_start', 'Illuminate\Support\Str', 'start'),
new FuncNameToStaticCallName('studly_case', 'Illuminate\Support\Str', 'studly'),
new FuncNameToStaticCallName('title_case', 'Illuminate\Support\Str', 'title'),
];
$services->set(FuncCallToStaticCallRector::class)
->call('configure', [[
FuncCallToStaticCallRector::FUNC_CALLS_TO_STATIC_CALLS => inline_value_objects($configuration),
FuncCallToStaticCallRector::FUNC_CALLS_TO_STATIC_CALLS => inline_value_objects([
new FuncNameToStaticCallName('array_add', 'Illuminate\Support\Arr', 'add'),
new FuncNameToStaticCallName('array_collapse', 'Illuminate\Support\Arr', 'collapse'),
new FuncNameToStaticCallName('array_divide', 'Illuminate\Support\Arr', 'divide'),
new FuncNameToStaticCallName('array_dot', 'Illuminate\Support\Arr', 'dot'),
new FuncNameToStaticCallName('array_except', 'Illuminate\Support\Arr', 'except'),
new FuncNameToStaticCallName('array_first', 'Illuminate\Support\Arr', 'first'),
new FuncNameToStaticCallName('array_flatten', 'Illuminate\Support\Arr', 'flatten'),
new FuncNameToStaticCallName('array_forget', 'Illuminate\Support\Arr', 'forget'),
new FuncNameToStaticCallName('array_get', 'Illuminate\Support\Arr', 'get'),
new FuncNameToStaticCallName('array_has', 'Illuminate\Support\Arr', 'has'),
new FuncNameToStaticCallName('array_last', 'Illuminate\Support\Arr', 'last'),
new FuncNameToStaticCallName('array_only', 'Illuminate\Support\Arr', 'only'),
new FuncNameToStaticCallName('array_pluck', 'Illuminate\Support\Arr', 'pluck'),
new FuncNameToStaticCallName('array_prepend', 'Illuminate\Support\Arr', 'prepend'),
new FuncNameToStaticCallName('array_pull', 'Illuminate\Support\Arr', 'pull'),
new FuncNameToStaticCallName('array_random', 'Illuminate\Support\Arr', 'random'),
new FuncNameToStaticCallName('array_sort', 'Illuminate\Support\Arr', 'sort'),
new FuncNameToStaticCallName('array_sort_recursive', 'Illuminate\Support\Arr', 'sortRecursive'),
new FuncNameToStaticCallName('array_where', 'Illuminate\Support\Arr', 'where'),
new FuncNameToStaticCallName('array_wrap', 'Illuminate\Support\Arr', 'wrap'),
new FuncNameToStaticCallName('array_set', 'Illuminate\Support\Arr', 'set'),
new FuncNameToStaticCallName('camel_case', 'Illuminate\Support\Str', 'camel'),
new FuncNameToStaticCallName('ends_with', 'Illuminate\Support\Str', 'endsWith'),
new FuncNameToStaticCallName('kebab_case', 'Illuminate\Support\Str', 'kebab'),
new FuncNameToStaticCallName('snake_case', 'Illuminate\Support\Str', 'snake'),
new FuncNameToStaticCallName('starts_with', 'Illuminate\Support\Str', 'startsWith'),
new FuncNameToStaticCallName('str_after', 'Illuminate\Support\Str', 'after'),
new FuncNameToStaticCallName('str_before', 'Illuminate\Support\Str', 'before'),
new FuncNameToStaticCallName('str_contains', 'Illuminate\Support\Str', 'contains'),
new FuncNameToStaticCallName('str_finish', 'Illuminate\Support\Str', 'finish'),
new FuncNameToStaticCallName('str_is', 'Illuminate\Support\Str', 'is'),
new FuncNameToStaticCallName('str_limit', 'Illuminate\Support\Str', 'limit'),
new FuncNameToStaticCallName('str_plural', 'Illuminate\Support\Str', 'plural'),
new FuncNameToStaticCallName('str_random', 'Illuminate\Support\Str', 'random'),
new FuncNameToStaticCallName('str_replace_array', 'Illuminate\Support\Str', 'replaceArray'),
new FuncNameToStaticCallName('str_replace_first', 'Illuminate\Support\Str', 'replaceFirst'),
new FuncNameToStaticCallName('str_replace_last', 'Illuminate\Support\Str', 'replaceLast'),
new FuncNameToStaticCallName('str_singular', 'Illuminate\Support\Str', 'singular'),
new FuncNameToStaticCallName('str_slug', 'Illuminate\Support\Str', 'slug'),
new FuncNameToStaticCallName('str_start', 'Illuminate\Support\Str', 'start'),
new FuncNameToStaticCallName('studly_case', 'Illuminate\Support\Str', 'studly'),
new FuncNameToStaticCallName('title_case', 'Illuminate\Support\Str', 'title'),
]),
]]);
};

View File

@ -3,7 +3,6 @@
declare(strict_types=1);
use Rector\Generic\Rector\FuncCall\FuncCallToStaticCallRector;
use Rector\Generic\ValueObject\FuncNameToStaticCallName;
use Rector\Nette\Rector\FuncCall\FilePutContentsToFileSystemWriteRector;
use Rector\Nette\Rector\FuncCall\JsonDecodeEncodeToNetteUtilsJsonDecodeEncodeRector;
use Rector\Nette\Rector\FuncCall\PregFunctionToNetteUtilsStringsRector;
@ -14,20 +13,20 @@ use Rector\Nette\Rector\Identical\StartsWithFunctionToNetteUtilsStringsRector;
use Rector\Nette\Rector\NotIdentical\StrposToStringsContainsRector;
use Rector\NetteUtilsCodeQuality\Rector\LNumber\ReplaceTimeNumberWithDateTimeConstantRector;
use function Rector\SymfonyPhpConfig\inline_value_objects;
use Rector\Transform\ValueObject\FuncNameToStaticCallName;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
# @see https://www.tomasvotruba.cz/blog/2018/07/30/hidden-gems-of-php-packages-nette-utils
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$configuration = [
new FuncNameToStaticCallName('file_get_contents', 'Nette\Utils\FileSystem', 'read'),
new FuncNameToStaticCallName('unlink', 'Nette\Utils\FileSystem', 'delete'),
new FuncNameToStaticCallName('rmdir', 'Nette\Utils\FileSystem', 'delete'),
];
$services->set(FuncCallToStaticCallRector::class)
->call('configure', [[
FuncCallToStaticCallRector::FUNC_CALLS_TO_STATIC_CALLS => inline_value_objects($configuration),
FuncCallToStaticCallRector::FUNC_CALLS_TO_STATIC_CALLS => inline_value_objects([
new FuncNameToStaticCallName('file_get_contents', 'Nette\Utils\FileSystem', 'read'),
new FuncNameToStaticCallName('unlink', 'Nette\Utils\FileSystem', 'delete'),
new FuncNameToStaticCallName('rmdir', 'Nette\Utils\FileSystem', 'delete'),
]),
]]);
$services->set(StrposToStringsContainsRector::class);

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
use Rector\Decomplex\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector;
use Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector;
use Rector\SOLID\Rector\Class_\ChangeReadOnlyVariableWithDefaultValueToConstantRector;
use Rector\SOLID\Rector\Class_\FinalizeClassesWithoutChildrenRector;
use Rector\SOLID\Rector\Class_\MakeUnusedClassesWithChildrenAbstractRector;

View File

@ -9,14 +9,12 @@ use Rector\Generic\Rector\ClassMethod\ArgumentDefaultValueReplacerRector;
use Rector\Generic\Rector\ClassMethod\ArgumentRemoverRector;
use Rector\Generic\Rector\ClassMethod\ChangeMethodVisibilityRector;
use Rector\Generic\Rector\ClassMethod\WrapReturnRector;
use Rector\Generic\Rector\New_\NewToStaticCallRector;
use Rector\Generic\ValueObject\AddedArgument;
use Rector\Generic\ValueObject\MethodReturnType;
use Rector\Generic\ValueObject\MethodVisibility;
use Rector\Generic\ValueObject\RemovedArgument;
use Rector\Generic\ValueObject\ReplacedArgument;
use Rector\Generic\ValueObject\TypeMethodWrap;
use Rector\Generic\ValueObject\TypeToStaticCall;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\Rector\Name\RenameClassRector;
use Rector\Renaming\ValueObject\MethodCallRename;
@ -24,6 +22,8 @@ use Rector\Symfony\Rector\MethodCall\ContainerGetToConstructorInjectionRector;
use Rector\Symfony\Rector\New_\RootNodeTreeBuilderRector;
use Rector\Symfony\Rector\New_\StringToArrayArgumentProcessRector;
use function Rector\SymfonyPhpConfig\inline_value_objects;
use Rector\Transform\Rector\New_\NewToStaticCallRector;
use Rector\Transform\ValueObject\NewToStaticCall;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
# https://github.com/symfony/symfony/pull/28447
@ -33,7 +33,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services->set(NewToStaticCallRector::class)
->call('configure', [[
NewToStaticCallRector::TYPE_TO_STATIC_CALLS => inline_value_objects([
new TypeToStaticCall(
new NewToStaticCall(
'Symfony\Component\HttpFoundation\Cookie',
'Symfony\Component\HttpFoundation\Cookie',
'create'

View File

@ -9,9 +9,8 @@
- [Autodiscovery](#autodiscovery) (4)
- [CakePHP](#cakephp) (6)
- [CodeQuality](#codequality) (58)
- [CodingStyle](#codingstyle) (35)
- [CodingStyle](#codingstyle) (36)
- [DeadCode](#deadcode) (40)
- [Decomplex](#decomplex) (1)
- [Decouple](#decouple) (1)
- [Doctrine](#doctrine) (17)
- [DoctrineCodeQuality](#doctrinecodequality) (7)
@ -19,7 +18,7 @@
- [Downgrade](#downgrade) (1)
- [DynamicTypeAnalysis](#dynamictypeanalysis) (3)
- [FileSystemRector](#filesystemrector) (1)
- [Generic](#generic) (42)
- [Generic](#generic) (39)
- [Guzzle](#guzzle) (1)
- [Injection](#injection) (1)
- [JMS](#jms) (2)
@ -70,7 +69,7 @@
- [SymfonyCodeQuality](#symfonycodequality) (1)
- [SymfonyPHPUnit](#symfonyphpunit) (1)
- [SymfonyPhpConfig](#symfonyphpconfig) (2)
- [Transform](#transform) (6)
- [Transform](#transform) (9)
- [Twig](#twig) (1)
- [TypeDeclaration](#typedeclaration) (9)
@ -2362,6 +2361,29 @@ Use ++ increment instead of `$var += 1`
<br><br>
### `UseMessageVariableForSprintfInSymfonyStyleRector`
- class: [`Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector`](/../master/rules/coding-style/src/Rector/MethodCall/UseMessageVariableForSprintfInSymfonyStyleRector.php)
- [test fixtures](/../master/rules/coding-style/tests/Rector/MethodCall/UseMessageVariableForSprintfInSymfonyStyleRector/Fixture)
Decouple `$message` property from `sprintf()` calls in `$this->smyfonyStyle->method()`
```diff
use Symfony\Component\Console\Style\SymfonyStyle;
final class SomeClass
{
public function run(SymfonyStyle $symfonyStyle)
{
- $symfonyStyle->info(sprintf('Hi %s', 'Tom'));
+ $message = sprintf('Hi %s', 'Tom');
+ $symfonyStyle->info($message);
}
}
```
<br><br>
### `VarConstantCommentRector`
- class: [`Rector\CodingStyle\Rector\ClassConst\VarConstantCommentRector`](/../master/rules/coding-style/src/Rector/ClassConst/VarConstantCommentRector.php)
@ -3336,31 +3358,6 @@ Change ternary of bool : false to && bool
<br><br>
## Decomplex
### `UseMessageVariableForSprintfInSymfonyStyleRector`
- class: [`Rector\Decomplex\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector`](/../master/rules/decomplex/src/Rector/MethodCall/UseMessageVariableForSprintfInSymfonyStyleRector.php)
- [test fixtures](/../master/rules/decomplex/tests/Rector/MethodCall/UseMessageVariableForSprintfInSymfonyStyleRector/Fixture)
Decouple `$message` property from `sprintf()` calls in `$this->smyfonyStyle->method()`
```diff
use Symfony\Component\Console\Style\SymfonyStyle;
final class SomeClass
{
public function run(SymfonyStyle $symfonyStyle)
{
- $symfonyStyle->info(sprintf('Hi %s', 'Tom'));
+ $message = sprintf('Hi %s', 'Tom');
+ $symfonyStyle->info($message);
}
}
```
<br><br>
## Decouple
### `DecoupleClassMethodToOwnClassRector`
@ -5163,7 +5160,7 @@ return function (ContainerConfigurator $containerConfigurator) : void {
$services->set(FuncCallToStaticCallRector::class)
->call('configure', [[
FuncCallToStaticCallRector::FUNC_CALLS_TO_STATIC_CALLS => [
\Rector\SymfonyPhpConfig\inline_value_object(new Rector\Generic\ValueObject\FuncNameToStaticCallName('view', 'SomeStaticClass', 'render'))]
\Rector\SymfonyPhpConfig\inline_value_object(new Rector\Transform\ValueObject\FuncNameToStaticCallName('view', 'SomeStaticClass', 'render'))]
]]);
};
```
@ -5377,44 +5374,6 @@ return function (ContainerConfigurator $containerConfigurator) : void {
<br><br>
### `NewToStaticCallRector`
- class: [`Rector\Generic\Rector\New_\NewToStaticCallRector`](/../master/rules/generic/src/Rector/New_/NewToStaticCallRector.php)
- [test fixtures](/../master/rules/generic/tests/Rector/New_/NewToStaticCallRector/Fixture)
Change new Object to static call
```php
<?php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Rector\Generic\Rector\New_\NewToStaticCallRector;
return function (ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$services->set(NewToStaticCallRector::class)
->call('configure', [[
NewToStaticCallRector::TYPE_TO_STATIC_CALLS => [
\Rector\SymfonyPhpConfig\inline_value_object(new Rector\Generic\ValueObject\TypeToStaticCall('Cookie', 'Cookie', 'create'))]
]]);
};
```
```diff
class SomeClass
{
public function run()
{
- new Cookie($name);
+ Cookie::create($name);
}
}
```
<br><br>
### `NormalToFluentRector`
- class: [`Rector\Generic\Rector\ClassMethod\NormalToFluentRector`](/../master/rules/generic/src/Rector/ClassMethod/NormalToFluentRector.php)
@ -5807,7 +5766,7 @@ return function (ContainerConfigurator $containerConfigurator) : void {
### `ReplaceParentCallByPropertyCallRector`
- class: [`Rector\Generic\Rector\MethodCall\ReplaceParentCallByPropertyCallRector`](/../master/rules/generic/src/Rector/MethodCall/ReplaceParentCallByPropertyCallRector.php)
- [test fixtures](/../master/rules/generic/tests/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/Fixture)
- [test fixtures](/../master/rules/transform/tests/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/Fixture)
Changes method calls in child of specific types to defined property method call
@ -5822,7 +5781,7 @@ return function (ContainerConfigurator $containerConfigurator) : void {
$services->set(ReplaceParentCallByPropertyCallRector::class)
->call('configure', [[
ReplaceParentCallByPropertyCallRector::PARENT_CALLS_TO_PROPERTIES => [
\Rector\SymfonyPhpConfig\inline_value_object(new Rector\Generic\ValueObject\ParentCallToProperty('SomeTypeToReplace', 'someMethodCall', 'someProperty'))]
\Rector\SymfonyPhpConfig\inline_value_object(new Rector\Transform\ValueObject\ParentCallToProperty('SomeTypeToReplace', 'someMethodCall', 'someProperty'))]
]]);
};
```
@ -5871,109 +5830,6 @@ Turns variable in controller action to property fetch, as follow up to action in
<br><br>
### `ServiceGetterToConstructorInjectionRector`
- class: [`Rector\Generic\Rector\MethodCall\ServiceGetterToConstructorInjectionRector`](/../master/rules/generic/src/Rector/MethodCall/ServiceGetterToConstructorInjectionRector.php)
- [test fixtures](/../master/rules/generic/tests/Rector/MethodCall/ServiceGetterToConstructorInjectionRector/Fixture)
Get service call to constructor injection
```php
<?php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Rector\Generic\Rector\MethodCall\ServiceGetterToConstructorInjectionRector;
return function (ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$services->set(ServiceGetterToConstructorInjectionRector::class)
->call('configure', [[
ServiceGetterToConstructorInjectionRector::METHOD_CALL_TO_SERVICES => [
\Rector\SymfonyPhpConfig\inline_value_object(new Rector\Generic\ValueObject\MethodCallToService('FirstService', 'getAnotherService', 'AnotherService'))]
]]);
};
```
```diff
final class SomeClass
{
/**
* @var FirstService
*/
private $firstService;
- public function __construct(FirstService $firstService)
- {
- $this->firstService = $firstService;
- }
-
- public function run()
- {
- $anotherService = $this->firstService->getAnotherService();
- $anotherService->run();
- }
-}
-
-class FirstService
-{
/**
* @var AnotherService
*/
private $anotherService;
- public function __construct(AnotherService $anotherService)
+ public function __construct(FirstService $firstService, AnotherService $anotherService)
{
+ $this->firstService = $firstService;
$this->anotherService = $anotherService;
}
- public function getAnotherService(): AnotherService
+ public function run()
{
- return $this->anotherService;
+ $anotherService = $this->anotherService;
+ $anotherService->run();
}
}
```
<br><br>
### `StaticCallToFunctionRector`
- class: [`Rector\Generic\Rector\StaticCall\StaticCallToFunctionRector`](/../master/rules/generic/src/Rector/StaticCall/StaticCallToFunctionRector.php)
- [test fixtures](/../master/rules/generic/tests/Rector/StaticCall/StaticCallToFunctionRector/Fixture)
Turns static call to function call.
```php
<?php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Rector\Generic\Rector\StaticCall\StaticCallToFunctionRector;
return function (ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$services->set(StaticCallToFunctionRector::class)
->call('configure', [[
StaticCallToFunctionRector::STATIC_CALLS_TO_FUNCTIONS => [
\Rector\SymfonyPhpConfig\inline_value_object(new Rector\Generic\ValueObject\StaticCallToFunction('OldClass', 'oldMethod', 'new_function'))]
]]);
};
```
```diff
-OldClass::oldMethod("args");
+new_function("args");
```
<br><br>
### `StringToClassConstantRector`
- class: [`Rector\Generic\Rector\String_\StringToClassConstantRector`](/../master/rules/generic/src/Rector/String_/StringToClassConstantRector.php)
@ -14295,6 +14151,44 @@ return function (ContainerConfigurator $containerConfigurator) : void {
<br><br>
### `NewToStaticCallRector`
- class: [`Rector\Transform\Rector\New_\NewToStaticCallRector`](/../master/rules/transform/src/Rector/New_/NewToStaticCallRector.php)
- [test fixtures](/../master/rules/transform/tests/Rector/New_/NewToStaticCallRector/Fixture)
Change new Object to static call
```php
<?php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Rector\Transform\Rector\New_\NewToStaticCallRector;
return function (ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$services->set(NewToStaticCallRector::class)
->call('configure', [[
NewToStaticCallRector::TYPE_TO_STATIC_CALLS => [
\Rector\SymfonyPhpConfig\inline_value_object(new Rector\Transform\ValueObject\NewToStaticCall('Cookie', 'Cookie', 'create'))]
]]);
};
```
```diff
class SomeClass
{
public function run()
{
- new Cookie($name);
+ Cookie::create($name);
}
}
```
<br><br>
### `PropertyToMethodRector`
- class: [`Rector\Transform\Rector\Assign\PropertyToMethodRector`](/../master/rules/transform/src/Rector/Assign/PropertyToMethodRector.php)
@ -14352,6 +14246,109 @@ return function (ContainerConfigurator $containerConfigurator) : void {
<br><br>
### `ServiceGetterToConstructorInjectionRector`
- class: [`Rector\Transform\Rector\MethodCall\ServiceGetterToConstructorInjectionRector`](/../master/rules/transform/src/Rector/MethodCall/ServiceGetterToConstructorInjectionRector.php)
- [test fixtures](/../master/rules/transform/tests/Rector/MethodCall/ServiceGetterToConstructorInjectionRector/Fixture)
Get service call to constructor injection
```php
<?php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Rector\Transform\Rector\MethodCall\ServiceGetterToConstructorInjectionRector;
return function (ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$services->set(ServiceGetterToConstructorInjectionRector::class)
->call('configure', [[
ServiceGetterToConstructorInjectionRector::METHOD_CALL_TO_SERVICES => [
\Rector\SymfonyPhpConfig\inline_value_object(new Rector\Transform\ValueObject\MethodCallToService('FirstService', 'getAnotherService', 'AnotherService'))]
]]);
};
```
```diff
final class SomeClass
{
/**
* @var FirstService
*/
private $firstService;
- public function __construct(FirstService $firstService)
- {
- $this->firstService = $firstService;
- }
-
- public function run()
- {
- $anotherService = $this->firstService->getAnotherService();
- $anotherService->run();
- }
-}
-
-class FirstService
-{
/**
* @var AnotherService
*/
private $anotherService;
- public function __construct(AnotherService $anotherService)
+ public function __construct(FirstService $firstService, AnotherService $anotherService)
{
+ $this->firstService = $firstService;
$this->anotherService = $anotherService;
}
- public function getAnotherService(): AnotherService
+ public function run()
{
- return $this->anotherService;
+ $anotherService = $this->anotherService;
+ $anotherService->run();
}
}
```
<br><br>
### `StaticCallToFuncCallRector`
- class: [`Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector`](/../master/rules/transform/src/Rector/StaticCall/StaticCallToFuncCallRector.php)
- [test fixtures](/../master/rules/transform/tests/Rector/StaticCall/StaticCallToFuncCallRector/Fixture)
Turns static call to function call.
```php
<?php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector;
return function (ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$services->set(StaticCallToFuncCallRector::class)
->call('configure', [[
StaticCallToFuncCallRector::STATIC_CALLS_TO_FUNCTIONS => [
\Rector\SymfonyPhpConfig\inline_value_object(new Rector\Transform\ValueObject\StaticCallToFuncCall('OldClass', 'oldMethod', 'new_function'))]
]]);
};
```
```diff
-OldClass::oldMethod("args");
+new_function("args");
```
<br><br>
## Twig
### `SimpleFunctionAndFilterRector`

View File

@ -76,6 +76,11 @@ final class SetList
*/
public const CODING_STYLE = __DIR__ . '/../../../../config/set/coding-style.php';
/**
* @var string
*/
public const CODING_STYLE_ADVANCED = __DIR__ . '/../../../../config/set/coding-style-advanced.php';
/**
* @var string
*/
@ -171,11 +176,6 @@ final class SetList
*/
public const EASY_ADMIN_BUNDLE_20 = __DIR__ . '/../../../../config/set/easy-admin-bundle20.php';
/**
* @var string
*/
public const ELASTICSEARCH_DSL_50 = __DIR__ . '/../../../../config/set/elasticsearch-dsl50.php';
/**
* @var string
*/

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace Rector\Decomplex\Rector\MethodCall;
namespace Rector\CodingStyle\Rector\MethodCall;
use PhpParser\Node;
use PhpParser\Node\Expr\Assign;
@ -13,7 +13,7 @@ use Rector\Core\RectorDefinition\CodeSample;
use Rector\Core\RectorDefinition\RectorDefinition;
/**
* @see \Rector\Decomplex\Tests\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector\UseMessageVariableForSprintfInSymfonyStyleRectorTest
* @see \Rector\CodingStyle\Tests\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector\UseMessageVariableForSprintfInSymfonyStyleRectorTest
*/
final class UseMessageVariableForSprintfInSymfonyStyleRector extends AbstractRector
{

View File

@ -1,6 +1,6 @@
<?php
namespace Rector\Decomplex\Tests\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector\Fixture;
namespace Rector\CodingStyle\Tests\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector\Fixture;
use Symfony\Component\Console\Style\SymfonyStyle;
@ -16,7 +16,7 @@ final class SomeClass
-----
<?php
namespace Rector\Decomplex\Tests\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector\Fixture;
namespace Rector\CodingStyle\Tests\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector\Fixture;
use Symfony\Component\Console\Style\SymfonyStyle;

View File

@ -2,11 +2,11 @@
declare(strict_types=1);
namespace Rector\Decomplex\Tests\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector;
namespace Rector\CodingStyle\Tests\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector;
use Iterator;
use Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector;
use Rector\Core\Testing\PHPUnit\AbstractRectorTestCase;
use Rector\Decomplex\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector;
use Symplify\SmartFileSystem\SmartFileInfo;
final class UseMessageVariableForSprintfInSymfonyStyleRectorTest extends AbstractRectorTestCase

View File

@ -10,7 +10,7 @@ use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\RectorDefinition\ConfiguredCodeSample;
use Rector\Core\RectorDefinition\RectorDefinition;
use Rector\Generic\ValueObject\FuncNameToStaticCallName;
use Rector\Transform\ValueObject\FuncNameToStaticCallName;
/**
* @see \Rector\Generic\Tests\Rector\FuncCall\FuncCallToStaticCallRector\FuncCallToStaticCallRectorTest

View File

@ -10,10 +10,10 @@ use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\RectorDefinition\ConfiguredCodeSample;
use Rector\Core\RectorDefinition\RectorDefinition;
use Rector\Generic\ValueObject\ParentCallToProperty;
use Rector\Transform\ValueObject\ParentCallToProperty;
/**
* @see \Rector\Generic\Tests\Rector\MethodCall\ReplaceParentCallByPropertyCallRector\ReplaceParentCallByPropertyCallRectorTest
* @see \Rector\Transform\Tests\Rector\MethodCall\ReplaceParentCallByPropertyCallRector\ReplaceParentCallByPropertyCallRectorTest
*/
final class ReplaceParentCallByPropertyCallRector extends AbstractRector implements ConfigurableRectorInterface
{

View File

@ -7,7 +7,7 @@ namespace Rector\Generic\Tests\Rector\FuncCall\FuncCallToStaticCallRector;
use Iterator;
use Rector\Core\Testing\PHPUnit\AbstractRectorTestCase;
use Rector\Generic\Rector\FuncCall\FuncCallToStaticCallRector;
use Rector\Generic\ValueObject\FuncNameToStaticCallName;
use Rector\Transform\ValueObject\FuncNameToStaticCallName;
use Symplify\SmartFileSystem\SmartFileInfo;
final class FuncCallToStaticCallRectorTest extends AbstractRectorTestCase

View File

@ -1,31 +0,0 @@
<?php
namespace Rector\Generic\Tests\Rector\MethodCall\ReplaceParentCallByPropertyCallRector\Fixture;
use Rector\Generic\Tests\Rector\MethodCall\ReplaceParentCallByPropertyCallRector\Source\TypeClassToReplaceMethodCallBy;
final class SomeClass
{
public function __construct(TypeClassToReplaceMethodCallBy $typeClassToReplaceMethodCallBy)
{
$typeClassToReplaceMethodCallBy->someMethod();
}
}
?>
-----
<?php
namespace Rector\Generic\Tests\Rector\MethodCall\ReplaceParentCallByPropertyCallRector\Fixture;
use Rector\Generic\Tests\Rector\MethodCall\ReplaceParentCallByPropertyCallRector\Source\TypeClassToReplaceMethodCallBy;
final class SomeClass
{
public function __construct(TypeClassToReplaceMethodCallBy $typeClassToReplaceMethodCallBy)
{
$this->someProperty->someMethod();
}
}
?>

View File

@ -1,10 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Generic\Tests\Rector\MethodCall\ReplaceParentCallByPropertyCallRector\Source;
abstract class TypeClassToReplaceMethodCallBy
{
}

View File

@ -1,31 +0,0 @@
<?php
namespace Rector\Generic\Tests\Rector\New_\NewToStaticCallRector\Fixture;
use Rector\Generic\Tests\Rector\New_\NewToStaticCallRector\Source\FromNewClass;
class SomeClass
{
public function run()
{
new FromNewClass($name);
}
}
?>
-----
<?php
namespace Rector\Generic\Tests\Rector\New_\NewToStaticCallRector\Fixture;
use Rector\Generic\Tests\Rector\New_\NewToStaticCallRector\Source\FromNewClass;
class SomeClass
{
public function run()
{
\Rector\Generic\Tests\Rector\New_\NewToStaticCallRector\Source\IntoStaticClass::run($name);
}
}
?>

View File

@ -1,10 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Generic\Tests\Rector\New_\NewToStaticCallRector\Source;
final class FromNewClass
{
}

View File

@ -1,31 +0,0 @@
<?php
namespace Rector\Generic\Tests\Rector\StaticCall\StaticCallToFunctionRector\Fixture;
use Rector\Generic\Tests\Rector\StaticCall\StaticCallToFunctionRector\Source\SomeOldStaticClass;
class SomeClass
{
public function someMethod()
{
SomeOldStaticClass::render('template', []);
}
}
?>
-----
<?php
namespace Rector\Generic\Tests\Rector\StaticCall\StaticCallToFunctionRector\Fixture;
use Rector\Generic\Tests\Rector\StaticCall\StaticCallToFunctionRector\Source\SomeOldStaticClass;
class SomeClass
{
public function someMethod()
{
\view('template', []);
}
}
?>

View File

@ -1,10 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Generic\Tests\Rector\StaticCall\StaticCallToFunctionRector\Source;
final class SomeOldStaticClass
{
}

View File

@ -5,6 +5,9 @@ declare(strict_types=1);
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$parameters->set('project_directory', null);
$services = $containerConfigurator->services();
$services->defaults()

View File

@ -18,8 +18,8 @@ use Rector\Core\Rector\AbstractRector;
use Rector\Core\RectorDefinition\CodeSample;
use Rector\Core\RectorDefinition\RectorDefinition;
use Rector\Core\Util\StaticRectorStrings;
use Rector\FrameworkMigration\Symfony\ImplicitToExplicitRoutingAnnotationDecorator;
use Rector\NetteToSymfony\Route\RouteInfoFactory;
use Rector\NetteToSymfony\Routing\ImplicitToExplicitRoutingAnnotationDecorator;
use Rector\NetteToSymfony\ValueObject\RouteInfo;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer;

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace Rector\FrameworkMigration\Symfony;
namespace Rector\NetteToSymfony\Routing;
use PhpParser\Node;
use PhpParser\Node\Stmt\ClassMethod;

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace Rector\Generic\Rector\MethodCall;
namespace Rector\Transform\Rector\MethodCall;
use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
@ -15,13 +15,13 @@ use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\RectorDefinition\ConfiguredCodeSample;
use Rector\Core\RectorDefinition\RectorDefinition;
use Rector\Generic\ValueObject\MethodCallToService;
use Rector\Naming\Naming\PropertyNaming;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\Transform\ValueObject\MethodCallToService;
use Webmozart\Assert\Assert;
/**
* @see \Rector\Generic\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\ServiceGetterToConstructorInjectionRectorTest
* @see \Rector\Transform\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\ServiceGetterToConstructorInjectionRectorTest
*/
final class ServiceGetterToConstructorInjectionRector extends AbstractRector implements ConfigurableRectorInterface
{

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace Rector\Generic\Rector\New_;
namespace Rector\Transform\Rector\New_;
use PhpParser\Node;
use PhpParser\Node\Expr\New_;
@ -10,11 +10,11 @@ use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\RectorDefinition\ConfiguredCodeSample;
use Rector\Core\RectorDefinition\RectorDefinition;
use Rector\Generic\ValueObject\TypeToStaticCall;
use Rector\Transform\ValueObject\NewToStaticCall;
use Webmozart\Assert\Assert;
/**
* @see \Rector\Generic\Tests\Rector\New_\NewToStaticCallRector\NewToStaticCallRectorTest
* @see \Rector\Transform\Tests\Rector\New_\NewToStaticCallRector\NewToStaticCallRectorTest
*/
final class NewToStaticCallRector extends AbstractRector implements ConfigurableRectorInterface
{
@ -24,7 +24,7 @@ final class NewToStaticCallRector extends AbstractRector implements Configurable
public const TYPE_TO_STATIC_CALLS = 'type_to_static_calls';
/**
* @var TypeToStaticCall[]
* @var NewToStaticCall[]
*/
private $typeToStaticCalls = [];
@ -53,7 +53,7 @@ class SomeClass
PHP
,
[
self::TYPE_TO_STATIC_CALLS => [new TypeToStaticCall('Cookie', 'Cookie', 'create')],
self::TYPE_TO_STATIC_CALLS => [new NewToStaticCall('Cookie', 'Cookie', 'create')],
]
),
]);
@ -90,7 +90,7 @@ PHP
public function configure(array $configuration): void
{
$typeToStaticCalls = $configuration[self::TYPE_TO_STATIC_CALLS] ?? [];
Assert::allIsInstanceOf($typeToStaticCalls, TypeToStaticCall::class);
Assert::allIsInstanceOf($typeToStaticCalls, NewToStaticCall::class);
$this->typeToStaticCalls = $typeToStaticCalls;
}
}

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace Rector\Generic\Rector\StaticCall;
namespace Rector\Transform\Rector\StaticCall;
use PhpParser\Node;
use PhpParser\Node\Expr\FuncCall;
@ -12,13 +12,13 @@ use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\RectorDefinition\ConfiguredCodeSample;
use Rector\Core\RectorDefinition\RectorDefinition;
use Rector\Generic\ValueObject\StaticCallToFunction;
use Rector\Transform\ValueObject\StaticCallToFuncCall;
use Webmozart\Assert\Assert;
/**
* @see \Rector\Generic\Tests\Rector\StaticCall\StaticCallToFunctionRector\StaticCallToFunctionRectorTest
* @see \Rector\Transform\Tests\Rector\StaticCall\StaticCallToFuncCallRector\StaticCallToFuncCallRectorTest
*/
final class StaticCallToFunctionRector extends AbstractRector implements ConfigurableRectorInterface
final class StaticCallToFuncCallRector extends AbstractRector implements ConfigurableRectorInterface
{
/**
* @var string
@ -26,12 +26,12 @@ final class StaticCallToFunctionRector extends AbstractRector implements Configu
public const STATIC_CALLS_TO_FUNCTIONS = 'static_calls_to_functions';
/**
* @var StaticCallToFunction[]
* @var StaticCallToFuncCall[]
*/
private $staticCallsToFunctions = [];
/**
* @param StaticCallToFunction[] $staticCallToFunctions
* @param StaticCallToFuncCall[] $staticCallToFunctions
*/
public function __construct(array $staticCallToFunctions = [])
{
@ -46,7 +46,7 @@ final class StaticCallToFunctionRector extends AbstractRector implements Configu
'new_function("args");',
[
self::STATIC_CALLS_TO_FUNCTIONS => [
new StaticCallToFunction('OldClass', 'oldMethod', 'new_function'),
new StaticCallToFuncCall('OldClass', 'oldMethod', 'new_function'),
],
]
),
@ -84,7 +84,7 @@ final class StaticCallToFunctionRector extends AbstractRector implements Configu
public function configure(array $configuration): void
{
$staticCallsToFunctions = $configuration[self::STATIC_CALLS_TO_FUNCTIONS] ?? [];
Assert::allIsInstanceOf($staticCallsToFunctions, StaticCallToFunction::class);
Assert::allIsInstanceOf($staticCallsToFunctions, StaticCallToFuncCall::class);
$this->staticCallsToFunctions = $staticCallsToFunctions;
}
}

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace Rector\Generic\ValueObject;
namespace Rector\Transform\ValueObject;
final class FuncNameToStaticCallName
{

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace Rector\Generic\ValueObject;
namespace Rector\Transform\ValueObject;
final class MethodCallToService
{

View File

@ -2,9 +2,9 @@
declare(strict_types=1);
namespace Rector\Generic\ValueObject;
namespace Rector\Transform\ValueObject;
final class TypeToStaticCall
final class NewToStaticCall
{
/**
* @var string

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace Rector\Generic\ValueObject;
namespace Rector\Transform\ValueObject;
final class ParentCallToProperty
{

View File

@ -2,9 +2,9 @@
declare(strict_types=1);
namespace Rector\Generic\ValueObject;
namespace Rector\Transform\ValueObject;
final class StaticCallToFunction
final class StaticCallToFuncCall
{
/**
* @var string

View File

@ -0,0 +1,31 @@
<?php
namespace Rector\Transform\Tests\Rector\MethodCall\ReplaceParentCallByPropertyCallRector\Fixture;
use Rector\Transform\Tests\Rector\MethodCall\ReplaceParentCallByPropertyCallRector\Source\TypeClassToReplaceMethodCallBy;
final class SomeClass
{
public function __construct(TypeClassToReplaceMethodCallBy $typeClassToReplaceMethodCallBy)
{
$typeClassToReplaceMethodCallBy->someMethod();
}
}
?>
-----
<?php
namespace Rector\Transform\Tests\Rector\MethodCall\ReplaceParentCallByPropertyCallRector\Fixture;
use Rector\Transform\Tests\Rector\MethodCall\ReplaceParentCallByPropertyCallRector\Source\TypeClassToReplaceMethodCallBy;
final class SomeClass
{
public function __construct(TypeClassToReplaceMethodCallBy $typeClassToReplaceMethodCallBy)
{
$this->someProperty->someMethod();
}
}
?>

View File

@ -2,13 +2,13 @@
declare(strict_types=1);
namespace Rector\Generic\Tests\Rector\MethodCall\ReplaceParentCallByPropertyCallRector;
namespace Rector\Transform\Tests\Rector\MethodCall\ReplaceParentCallByPropertyCallRector;
use Iterator;
use Rector\Core\Testing\PHPUnit\AbstractRectorTestCase;
use Rector\Generic\Rector\MethodCall\ReplaceParentCallByPropertyCallRector;
use Rector\Generic\Tests\Rector\MethodCall\ReplaceParentCallByPropertyCallRector\Source\TypeClassToReplaceMethodCallBy;
use Rector\Generic\ValueObject\ParentCallToProperty;
use Rector\Transform\Tests\Rector\MethodCall\ReplaceParentCallByPropertyCallRector\Source\TypeClassToReplaceMethodCallBy;
use Rector\Transform\ValueObject\ParentCallToProperty;
use Symplify\SmartFileSystem\SmartFileInfo;
final class ReplaceParentCallByPropertyCallRectorTest extends AbstractRectorTestCase

View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Rector\Transform\Tests\Rector\MethodCall\ReplaceParentCallByPropertyCallRector\Source;
abstract class TypeClassToReplaceMethodCallBy
{
}

View File

@ -1,8 +1,8 @@
<?php
namespace Rector\Generic\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Fixture;
namespace Rector\Transform\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Fixture;
use Rector\Generic\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Source\FirstService;
use Rector\Transform\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Source\FirstService;
final class SomeClass
{
@ -27,9 +27,9 @@ final class SomeClass
-----
<?php
namespace Rector\Generic\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Fixture;
namespace Rector\Transform\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Fixture;
use Rector\Generic\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Source\FirstService;
use Rector\Transform\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Source\FirstService;
final class SomeClass
{
@ -38,11 +38,11 @@ final class SomeClass
*/
private $firstService;
/**
* @var \Rector\Generic\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Source\AnotherService
* @var \Rector\Transform\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Source\AnotherService
*/
private $anotherService;
public function __construct(FirstService $firstService, \Rector\Generic\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Source\AnotherService $anotherService)
public function __construct(FirstService $firstService, \Rector\Transform\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Source\AnotherService $anotherService)
{
$this->firstService = $firstService;
$this->anotherService = $anotherService;

View File

@ -2,14 +2,14 @@
declare(strict_types=1);
namespace Rector\Generic\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector;
namespace Rector\Transform\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector;
use Iterator;
use Rector\Core\Testing\PHPUnit\AbstractRectorTestCase;
use Rector\Generic\Rector\MethodCall\ServiceGetterToConstructorInjectionRector;
use Rector\Generic\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Source\AnotherService;
use Rector\Generic\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Source\FirstService;
use Rector\Generic\ValueObject\MethodCallToService;
use Rector\Transform\Rector\MethodCall\ServiceGetterToConstructorInjectionRector;
use Rector\Transform\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Source\AnotherService;
use Rector\Transform\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Source\FirstService;
use Rector\Transform\ValueObject\MethodCallToService;
use Symplify\SmartFileSystem\SmartFileInfo;
final class ServiceGetterToConstructorInjectionRectorTest extends AbstractRectorTestCase

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace Rector\Generic\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Source;
namespace Rector\Transform\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Source;
final class AnotherService
{

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace Rector\Generic\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Source;
namespace Rector\Transform\Tests\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\Source;
class FirstService
{

View File

@ -0,0 +1,31 @@
<?php
namespace Rector\Transform\Tests\Rector\New_\NewToStaticCallRector\Fixture;
use Rector\Transform\Tests\Rector\New_\NewToStaticCallRector\Source\FromNewClass;
class SomeClass
{
public function run()
{
new FromNewClass($name);
}
}
?>
-----
<?php
namespace Rector\Transform\Tests\Rector\New_\NewToStaticCallRector\Fixture;
use Rector\Transform\Tests\Rector\New_\NewToStaticCallRector\Source\FromNewClass;
class SomeClass
{
public function run()
{
\Rector\Transform\Tests\Rector\New_\NewToStaticCallRector\Source\IntoStaticClass::run($name);
}
}
?>

View File

@ -1,6 +1,6 @@
<?php
namespace Rector\Generic\Tests\Rector\New_\NewToStaticCallRector\Fixture;
namespace Rector\Transform\Tests\Rector\New_\NewToStaticCallRector\Fixture;
class SkipAnotherClass
{

View File

@ -2,14 +2,14 @@
declare(strict_types=1);
namespace Rector\Generic\Tests\Rector\New_\NewToStaticCallRector;
namespace Rector\Transform\Tests\Rector\New_\NewToStaticCallRector;
use Iterator;
use Rector\Core\Testing\PHPUnit\AbstractRectorTestCase;
use Rector\Generic\Rector\New_\NewToStaticCallRector;
use Rector\Generic\Tests\Rector\New_\NewToStaticCallRector\Source\FromNewClass;
use Rector\Generic\Tests\Rector\New_\NewToStaticCallRector\Source\IntoStaticClass;
use Rector\Generic\ValueObject\TypeToStaticCall;
use Rector\Transform\Rector\New_\NewToStaticCallRector;
use Rector\Transform\Tests\Rector\New_\NewToStaticCallRector\Source\FromNewClass;
use Rector\Transform\Tests\Rector\New_\NewToStaticCallRector\Source\IntoStaticClass;
use Rector\Transform\ValueObject\NewToStaticCall;
use Symplify\SmartFileSystem\SmartFileInfo;
final class NewToStaticCallRectorTest extends AbstractRectorTestCase
@ -35,7 +35,7 @@ final class NewToStaticCallRectorTest extends AbstractRectorTestCase
return [
NewToStaticCallRector::class => [
NewToStaticCallRector::TYPE_TO_STATIC_CALLS => [
new TypeToStaticCall(FromNewClass::class, IntoStaticClass::class, 'run'),
new NewToStaticCall(FromNewClass::class, IntoStaticClass::class, 'run'),
],
],
];

View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Rector\Transform\Tests\Rector\New_\NewToStaticCallRector\Source;
final class FromNewClass
{
}

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace Rector\Generic\Tests\Rector\New_\NewToStaticCallRector\Source;
namespace Rector\Transform\Tests\Rector\New_\NewToStaticCallRector\Source;
final class IntoStaticClass
{

View File

@ -0,0 +1,31 @@
<?php
namespace Rector\Transform\Tests\Rector\StaticCall\StaticCallToFuncCallRector\Fixture;
use Rector\Transform\Tests\Rector\StaticCall\StaticCallToFuncCallRector\Source\SomeOldStaticClass;
class SomeClass
{
public function someMethod()
{
SomeOldStaticClass::render('template', []);
}
}
?>
-----
<?php
namespace Rector\Transform\Tests\Rector\StaticCall\StaticCallToFuncCallRector\Fixture;
use Rector\Transform\Tests\Rector\StaticCall\StaticCallToFuncCallRector\Source\SomeOldStaticClass;
class SomeClass
{
public function someMethod()
{
\view('template', []);
}
}
?>

View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Rector\Transform\Tests\Rector\StaticCall\StaticCallToFuncCallRector\Source;
final class SomeOldStaticClass
{
}

View File

@ -2,16 +2,16 @@
declare(strict_types=1);
namespace Rector\Generic\Tests\Rector\StaticCall\StaticCallToFunctionRector;
namespace Rector\Transform\Tests\Rector\StaticCall\StaticCallToFuncCallRector;
use Iterator;
use Rector\Core\Testing\PHPUnit\AbstractRectorTestCase;
use Rector\Generic\Rector\StaticCall\StaticCallToFunctionRector;
use Rector\Generic\Tests\Rector\StaticCall\StaticCallToFunctionRector\Source\SomeOldStaticClass;
use Rector\Generic\ValueObject\StaticCallToFunction;
use Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector;
use Rector\Transform\Tests\Rector\StaticCall\StaticCallToFuncCallRector\Source\SomeOldStaticClass;
use Rector\Transform\ValueObject\StaticCallToFuncCall;
use Symplify\SmartFileSystem\SmartFileInfo;
final class StaticCallToFunctionRectorTest extends AbstractRectorTestCase
final class StaticCallToFuncCallRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
@ -32,9 +32,9 @@ final class StaticCallToFunctionRectorTest extends AbstractRectorTestCase
protected function getRectorsWithConfiguration(): array
{
return [
StaticCallToFunctionRector::class => [
StaticCallToFunctionRector::STATIC_CALLS_TO_FUNCTIONS => [
new StaticCallToFunction(SomeOldStaticClass::class, 'render', 'view'),
StaticCallToFuncCallRector::class => [
StaticCallToFuncCallRector::STATIC_CALLS_TO_FUNCTIONS => [
new StaticCallToFuncCall(SomeOldStaticClass::class, 'render', 'view'),
],
],
];