[DX] Update dump nodes to not-use symfony style (#4356)

* [DX] Update dump nodes to not-use symfony style

* [rector] [DX] Update dump nodes to not-use symfony style

* [cs] [DX] Update dump nodes to not-use symfony style

Co-authored-by: rector-bot <tomas@getrector.org>
This commit is contained in:
Tomas Votruba 2020-10-05 11:29:07 +02:00 committed by GitHub
parent 1c8fac5242
commit a8f55f339f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 450 additions and 887 deletions

View File

@ -304,7 +304,7 @@
],
"docs": [
"bin/rector dump-rectors --output-file docs/rector_rules_overview.md --ansi",
"bin/rector dump-nodes > docs/nodes_overview.md"
"bin/rector dump-nodes --output-file docs/nodes_overview.md --ansi"
],
"rector-ci": "bin/rector process --config rector-ci.php --dry-run --ansi",
"rector": "bin/rector process --config rector-ci.php --ansi",

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,7 @@
- [DowngradePhp80](#downgradephp80) (6)
- [DynamicTypeAnalysis](#dynamictypeanalysis) (3)
- [FileSystemRector](#filesystemrector) (1)
- [Generic](#generic) (37)
- [Generic](#generic) (36)
- [JMS](#jms) (2)
- [Laravel](#laravel) (3)
- [Legacy](#legacy) (4)
@ -61,7 +61,7 @@
- [Privatization](#privatization) (7)
- [RectorGenerator](#rectorgenerator) (1)
- [RemovingStatic](#removingstatic) (6)
- [Renaming](#renaming) (9)
- [Renaming](#renaming) (10)
- [Restoration](#restoration) (8)
- [SOLID](#solid) (12)
- [Sensio](#sensio) (3)
@ -304,17 +304,14 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(ArrayToFluentCallRector::class)
->call(
'configure',
[[
->call('configure', [[
ArrayToFluentCallRector::ARRAYS_TO_FLUENT_CALLS => inline_value_objects(
[new ArrayToFluentCall('ArticlesTable', [
'foreignKey' => 'setForeignKey',
'propertyName' => 'setProperty',
])]
),
]]
);
]]);
};
```
@ -400,14 +397,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(ModalToGetSetRector::class)
->call(
'configure',
[[
->call('configure', [[
ModalToGetSetRector::UNPREFIXED_METHODS_TO_GET_SET => inline_value_objects(
[new ModalToGetSet('InstanceConfigTrait', 'config', 'getConfig', 'setConfig', 1, null)]
),
]]
);
]]);
};
```
@ -450,24 +444,16 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(RenameMethodCallBasedOnParameterRector::class)
->call(
'configure',
[[
->call('configure', [[
RenameMethodCallBasedOnParameterRector::CALLS_WITH_PARAM_RENAMES => inline_value_objects(
[new RenameMethodCallBasedOnParameter(
'getParam',
'paging',
'getAttribute',
'ServerRequest'
), new RenameMethodCallBasedOnParameter(
'withParam',
'paging',
'withAttribute',
'ServerRequest'
)]
), new RenameMethodCallBasedOnParameter('withParam', 'paging', 'withAttribute', 'ServerRequest')]
),
]]
);
]]);
};
```
@ -2227,14 +2213,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(ReturnArrayClassMethodToYieldRector::class)
->call(
'configure',
[[
->call('configure', [[
ReturnArrayClassMethodToYieldRector::METHODS_TO_YIELDS => inline_value_objects(
[new ReturnArrayClassMethodToYield('EventSubscriberInterface', 'getSubscribedEvents')]
),
]]
);
]]);
};
```
@ -5495,14 +5478,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(AddReturnTypeDeclarationRector::class)
->call(
'configure',
[[
->call('configure', [[
AddReturnTypeDeclarationRector::METHOD_RETURN_TYPES => inline_value_objects(
[new AddReturnTypeDeclaration('SomeClass', 'getData', 'array')]
),
]]
);
]]);
};
```
@ -5564,24 +5544,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(ArgumentAdderRector::class)
->call(
'configure',
[[
->call('configure', [[
ArgumentAdderRector::ADDED_ARGUMENTS => inline_value_objects(
[
new ArgumentAdder(
'SomeExampleClass',
'someMethod',
0,
'someArgument',
'true',
'SomeType',
null
[new ArgumentAdder('SomeExampleClass', 'someMethod', 0, 'someArgument', 'true', 'SomeType', null)]
),
]
),
]]
);
]]);
};
```
@ -5606,24 +5573,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(ArgumentAdderRector::class)
->call(
'configure',
[[
->call('configure', [[
ArgumentAdderRector::ADDED_ARGUMENTS => inline_value_objects(
[
new ArgumentAdder(
'SomeExampleClass',
'someMethod',
0,
'someArgument',
'true',
'SomeType',
null
[new ArgumentAdder('SomeExampleClass', 'someMethod', 0, 'someArgument', 'true', 'SomeType', null)]
),
]
),
]]
);
]]);
};
```
@ -5662,20 +5616,19 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(ArgumentDefaultValueReplacerRector::class)
->call(
'configure',
[[
->call('configure', [[
ArgumentDefaultValueReplacerRector::REPLACED_ARGUMENTS => inline_value_objects(
[new ArgumentDefaultValueReplacer(
[
new ArgumentDefaultValueReplacer(
'SomeExampleClass',
'someMethod',
0,
'SomeClass::OLD_CONSTANT',
'false'
)]
),
]]
);
]
),
]]);
};
```
@ -5710,14 +5663,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(ArgumentRemoverRector::class)
->call(
'configure',
[[
->call('configure', [[
ArgumentRemoverRector::REMOVED_ARGUMENTS => inline_value_objects(
[new ArgumentRemover('ExampleClass', 'someMethod', 0, 'true')]
),
]]
);
]]);
};
```
@ -5752,14 +5702,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(ChangeConstantVisibilityRector::class)
->call(
'configure',
[[
->call('configure', [[
ChangeConstantVisibilityRector::CLASS_CONSTANT_VISIBILITY_CHANGES => inline_value_objects(
[new ClassConstantVisibilityChange('ParentObject', 'SOME_CONSTANT', 'protected')]
),
]]
);
]]);
};
```
@ -5849,14 +5796,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(ChangeMethodVisibilityRector::class)
->call(
'configure',
[[
->call('configure', [[
ChangeMethodVisibilityRector::METHOD_VISIBILITIES => inline_value_objects(
[new ChangeMethodVisibility('FrameworkClass', 'someMethod', 'protected')]
),
]]
);
]]);
};
```
@ -6014,14 +5958,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(FuncCallToStaticCallRector::class)
->call(
'configure',
[[
->call('configure', [[
FuncCallToStaticCallRector::FUNC_CALLS_TO_STATIC_CALLS => inline_value_objects(
[new FuncCallToStaticCall('view', 'SomeStaticClass', 'render')]
),
]]
);
]]);
};
```
@ -6277,14 +6218,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(NormalToFluentRector::class)
->call(
'configure',
[[
->call('configure', [[
NormalToFluentRector::CALLS_TO_FLUENT => inline_value_objects(
[new NormalToFluent('SomeClass', ['someFunction', 'otherFunction'])]
),
]]
);
]]);
};
```
@ -6339,50 +6277,6 @@ return static function (ContainerConfigurator $containerConfigurator): void {
<br><br>
### `PseudoNamespaceToNamespaceRector`
- class: [`Rector\Renaming\Rector\FileWithoutNamespace\PseudoNamespaceToNamespaceRector`](/rules/generic/src/Rector/Name/PseudoNamespaceToNamespaceRector.php)
- [test fixtures](/rules/generic/tests/Rector/Name/PseudoNamespaceToNamespaceRector/Fixture)
Replaces defined Pseudo_Namespaces by Namespace\Ones.
```php
<?php
declare(strict_types=1);
use Rector\Generic\ValueObject\PseudoNamespaceToNamespace;
use Rector\Renaming\Rector\FileWithoutNamespace\PseudoNamespaceToNamespaceRector;
use function Rector\SymfonyPhpConfig\inline_value_objects;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(PseudoNamespaceToNamespaceRector::class)
->call(
'configure',
[[
PseudoNamespaceToNamespaceRector::NAMESPACE_PREFIXES_WITH_EXCLUDED_CLASSES => inline_value_objects(
[new PseudoNamespaceToNamespace('Some_', ['Some_Class_To_Keep'])]
),
]]
);
};
```
```diff
-/** @var Some_Chicken $someService */
-$someService = new Some_Chicken;
+/** @var Some\Chicken $someService */
+$someService = new Some\Chicken;
$someClassToKeep = new Some_Class_To_Keep;
```
<br><br>
### `RemoveAnnotationRector`
- class: [`Rector\Generic\Rector\ClassLike\RemoveAnnotationRector`](/rules/generic/src/Rector/ClassLike/RemoveAnnotationRector.php)
@ -6442,14 +6336,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(RemoveFuncCallArgRector::class)
->call(
'configure',
[[
->call('configure', [[
RemoveFuncCallArgRector::REMOVED_FUNCTION_ARGUMENTS => inline_value_objects(
[new RemoveFuncCallArg('remove_last_arg', 1)]
),
]]
);
]]);
};
```
@ -6664,20 +6555,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(ReplaceParentCallByPropertyCallRector::class)
->call(
'configure',
[[
->call('configure', [[
ReplaceParentCallByPropertyCallRector::PARENT_CALLS_TO_PROPERTIES => inline_value_objects(
[
new ReplaceParentCallByPropertyCall(
'SomeTypeToReplace',
'someMethodCall',
'someProperty'
[new ReplaceParentCallByPropertyCall('SomeTypeToReplace', 'someMethodCall', 'someProperty')]
),
]
),
]]
);
]]);
};
```
@ -6746,14 +6628,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(StringToClassConstantRector::class)
->call(
'configure',
[[
->call('configure', [[
StringToClassConstantRector::STRINGS_TO_CLASS_CONSTANTS => inline_value_objects(
[new StringToClassConstant('compiler.post_dump', 'Yet\AnotherClass', 'CONSTANT')]
),
]]
);
]]);
};
```
@ -6793,14 +6672,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(SwapClassMethodArgumentsRector::class)
->call(
'configure',
[[
->call('configure', [[
SwapClassMethodArgumentsRector::ARGUMENT_SWAPS => inline_value_objects(
[new SwapClassMethodArguments('SomeClass', 'run', [1, 0])]
),
]]
);
]]);
};
```
@ -6841,14 +6717,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(SwapFuncCallArgumentsRector::class)
->call(
'configure',
[[
->call('configure', [[
SwapFuncCallArgumentsRector::FUNCTION_ARGUMENT_SWAPS => inline_value_objects(
[new SwapFuncCallArguments('some_function', [1, 0])]
),
]]
);
]]);
};
```
@ -6888,14 +6761,9 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(WrapReturnRector::class)
->call(
'configure',
[[
WrapReturnRector::TYPE_METHOD_WRAPS => inline_value_objects(
[new WrapReturn('SomeClass', 'getItem', true)]
),
]]
);
->call('configure', [[
WrapReturnRector::TYPE_METHOD_WRAPS => inline_value_objects([new WrapReturn('SomeClass', 'getItem', true)]),
]]);
};
```
@ -7375,14 +7243,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(UnsetAndIssetToMethodCallRector::class)
->call(
'configure',
[[
->call('configure', [[
UnsetAndIssetToMethodCallRector::ISSET_UNSET_TO_METHOD_CALL => inline_value_objects(
[new IssetUnsetToMethodCall('SomeContainer', 'hasService', 'removeService')]
),
]]
);
]]);
};
```
@ -7407,14 +7272,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(UnsetAndIssetToMethodCallRector::class)
->call(
'configure',
[[
->call('configure', [[
UnsetAndIssetToMethodCallRector::ISSET_UNSET_TO_METHOD_CALL => inline_value_objects(
[new IssetUnsetToMethodCall('SomeContainer', 'hasService', 'removeService')]
),
]]
);
]]);
};
```
@ -9597,19 +9459,18 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(ArrayArgumentInTestToDataProviderRector::class)
->call(
'configure',
[[
->call('configure', [[
ArrayArgumentInTestToDataProviderRector::ARRAY_ARGUMENTS_TO_DATA_PROVIDERS => inline_value_objects(
[new ArrayArgumentToDataProvider(
[
new ArrayArgumentToDataProvider(
'PHPUnit\Framework\TestCase',
'doTestMultiple',
'doTestSingle',
'number'
)]
),
]]
);
]
),
]]);
};
```
@ -13279,6 +13140,47 @@ return static function (ContainerConfigurator $containerConfigurator): void {
## Renaming
### `PseudoNamespaceToNamespaceRector`
- class: [`Rector\Renaming\Rector\FileWithoutNamespace\PseudoNamespaceToNamespaceRector`](/rules/renaming/src/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector.php)
- [test fixtures](/rules/renaming/tests/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/Fixture)
Replaces defined Pseudo_Namespaces by Namespace\Ones.
```php
<?php
declare(strict_types=1);
use Rector\Generic\ValueObject\PseudoNamespaceToNamespace;
use Rector\Renaming\Rector\FileWithoutNamespace\PseudoNamespaceToNamespaceRector;
use function Rector\SymfonyPhpConfig\inline_value_objects;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(PseudoNamespaceToNamespaceRector::class)
->call('configure', [[
PseudoNamespaceToNamespaceRector::NAMESPACE_PREFIXES_WITH_EXCLUDED_CLASSES => inline_value_objects(
[new PseudoNamespaceToNamespace('Some_', ['Some_Class_To_Keep'])]
),
]]);
};
```
```diff
-/** @var Some_Chicken $someService */
-$someService = new Some_Chicken;
+/** @var Some\Chicken $someService */
+$someService = new Some\Chicken;
$someClassToKeep = new Some_Class_To_Keep;
```
<br><br>
### `RenameAnnotationRector`
- class: [`Rector\Renaming\Rector\ClassMethod\RenameAnnotationRector`](/rules/renaming/src/Rector/ClassMethod/RenameAnnotationRector.php)
@ -13300,14 +13202,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(RenameAnnotationRector::class)
->call(
'configure',
[[
->call('configure', [[
RenameAnnotationRector::RENAMED_ANNOTATIONS_IN_TYPES => inline_value_objects(
[new RenameAnnotation('PHPUnit\Framework\TestCase', 'test', 'scenario')]
),
]]
);
]]);
};
```
@ -13349,21 +13248,15 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(RenameClassConstantRector::class)
->call(
'configure',
[[
->call('configure', [[
RenameClassConstantRector::CLASS_CONSTANT_RENAME => inline_value_objects(
[
new RenameClassConstant('SomeClass', 'OLD_CONSTANT', 'NEW_CONSTANT'),
new RenameClassConstant(
[new RenameClassConstant('SomeClass', 'OLD_CONSTANT', 'NEW_CONSTANT'), new RenameClassConstant(
'SomeClass',
'OTHER_OLD_CONSTANT',
'DifferentClass::NEW_CONSTANT'
)]
),
]
),
]]
);
]]);
};
```
@ -13526,14 +13419,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(RenameMethodRector::class)
->call(
'configure',
[[
->call('configure', [[
RenameMethodRector::METHOD_CALL_RENAMES => inline_value_objects(
[new MethodCallRename('SomeExampleClass', 'oldMethod', 'newMethod')]
),
]]
);
]]);
};
```
@ -13604,14 +13494,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(RenamePropertyRector::class)
->call(
'configure',
[[
->call('configure', [[
RenamePropertyRector::RENAMED_PROPERTIES => inline_value_objects(
[new RenameProperty('SomeClass', 'someOldProperty', 'someNewProperty')]
),
]]
);
]]);
};
```
@ -13645,21 +13532,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(RenameStaticMethodRector::class)
->call(
'configure',
[[
->call('configure', [[
RenameStaticMethodRector::OLD_TO_NEW_METHODS_BY_CLASSES => inline_value_objects(
[
new RenameStaticMethod(
'SomeClass',
'oldMethod',
'AnotherExampleClass',
'newStaticMethod'
[new RenameStaticMethod('SomeClass', 'oldMethod', 'AnotherExampleClass', 'newStaticMethod')]
),
]
),
]]
);
]]);
};
```
@ -13683,14 +13560,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(RenameStaticMethodRector::class)
->call(
'configure',
[[
->call('configure', [[
RenameStaticMethodRector::OLD_TO_NEW_METHODS_BY_CLASSES => inline_value_objects(
[new RenameStaticMethod('SomeClass', 'oldMethod', 'SomeClass', 'newStaticMethod')]
),
]]
);
]]);
};
```
@ -13726,14 +13600,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(CompleteImportForPartialAnnotationRector::class)
->call(
'configure',
[[
->call('configure', [[
CompleteImportForPartialAnnotationRector::USE_IMPORTS_TO_RESTORE => inline_value_objects(
[new UseWithAlias('Doctrine\ORM\Mapping', 'ORM')]
),
]]
);
]]);
};
```
@ -15401,21 +15272,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(ArgumentFuncCallToMethodCallRector::class)
->call(
'configure',
[[
->call('configure', [[
ArgumentFuncCallToMethodCallRector::FUNCTIONS_TO_METHOD_CALLS => inline_value_objects(
[
new ArgumentFuncCallToMethodCall(
'view',
'Illuminate\Contracts\View\Factory',
null,
'make'
[new ArgumentFuncCallToMethodCall('view', 'Illuminate\Contracts\View\Factory', null, 'make')]
),
]
),
]]
);
]]);
};
```
@ -15467,14 +15328,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(FuncCallToMethodCallRector::class)
->call(
'configure',
[[
->call('configure', [[
FuncCallToMethodCallRector::FUNC_CALL_TO_CLASS_METHOD_CALL => inline_value_objects(
[new FuncNameToMethodCallName('view', 'Namespaced\SomeRenderer', 'render')]
),
]]
);
]]);
};
```
@ -15524,14 +15382,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(MethodCallToAnotherMethodCallWithArgumentsRector::class)
->call(
'configure',
[[
->call('configure', [[
MethodCallToAnotherMethodCallWithArgumentsRector::METHOD_CALL_RENAMES_WITH_ADDED_ARGUMENTS => inline_value_objects(
[new MethodCallRenameWithArrayKey('Nette\DI\ServiceDefinition', 'setInject', 'addTag', 'inject')]
),
]]
);
]]);
};
```
@ -15608,21 +15463,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(MethodCallToStaticCallRector::class)
->call(
'configure',
[[
->call('configure', [[
MethodCallToStaticCallRector::METHOD_CALLS_TO_STATIC_CALLS => inline_value_objects(
[
new MethodCallToStaticCall(
'AnotherDependency',
'process',
'StaticCaller',
'anotherMethod'
[new MethodCallToStaticCall('AnotherDependency', 'process', 'StaticCaller', 'anotherMethod')]
),
]
),
]]
);
]]);
};
```
@ -15669,14 +15514,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(NewToStaticCallRector::class)
->call(
'configure',
[[
->call('configure', [[
NewToStaticCallRector::TYPE_TO_STATIC_CALLS => inline_value_objects(
[new NewToStaticCall('Cookie', 'Cookie', 'create')]
),
]]
);
]]);
};
```
@ -15716,14 +15558,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(PropertyAssignToMethodCallRector::class)
->call(
'configure',
[[
->call('configure', [[
PropertyAssignToMethodCallRector::PROPERTY_ASSIGNS_TO_METHODS_CALLS => inline_value_objects(
[new PropertyAssignToMethodCall('SomeClass', 'oldProperty', 'newMethodCall')]
),
]]
);
]]);
};
```
@ -15758,14 +15597,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(PropertyToMethodRector::class)
->call(
'configure',
[[
->call('configure', [[
PropertyToMethodRector::PROPERTIES_TO_METHOD_CALLS => inline_value_objects(
[new PropertyToMethod('SomeObject', 'property', 'getProperty', [], 'setProperty')]
),
]]
);
]]);
};
```
@ -15791,14 +15627,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(PropertyToMethodRector::class)
->call(
'configure',
[[
->call('configure', [[
PropertyToMethodRector::PROPERTIES_TO_METHOD_CALLS => inline_value_objects(
[new PropertyToMethod('SomeObject', 'property', 'getConfig', ['someArg'], null)]
),
]]
);
]]);
};
```
@ -15832,20 +15665,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(ServiceGetterToConstructorInjectionRector::class)
->call(
'configure',
[[
->call('configure', [[
ServiceGetterToConstructorInjectionRector::METHOD_CALL_TO_SERVICES => inline_value_objects(
[
new ServiceGetterToConstructorInjection(
'FirstService',
'getAnotherService',
'AnotherService'
[new ServiceGetterToConstructorInjection('FirstService', 'getAnotherService', 'AnotherService')]
),
]
),
]]
);
]]);
};
```
@ -15918,14 +15742,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(StaticCallToFuncCallRector::class)
->call(
'configure',
[[
->call('configure', [[
StaticCallToFuncCallRector::STATIC_CALLS_TO_FUNCTIONS => inline_value_objects(
[new StaticCallToFuncCall('OldClass', 'oldMethod', 'new_function')]
),
]]
);
]]);
};
```
@ -15959,9 +15780,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(StaticCallToMethodCallRector::class)
->call(
'configure',
[[
->call('configure', [[
StaticCallToMethodCallRector::STATIC_CALLS_TO_METHOD_CALLS => inline_value_objects(
[new StaticCallToMethodCall(
'Nette\Utils\FileSystem',
@ -15970,8 +15789,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
'dumpFile'
)]
),
]]
);
]]);
};
```
@ -16163,14 +15981,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(AddParamTypeDeclarationRector::class)
->call(
'configure',
[[
->call('configure', [[
AddParamTypeDeclarationRector::PARAMETER_TYPEHINTS => inline_value_objects(
[new AddParamTypeDeclaration('SomeClass', 'process', 0, 'string')]
),
]]
);
]]);
};
```

View File

@ -6,30 +6,53 @@ namespace Rector\Utils\NodeDocumentationGenerator\Command;
use Rector\Core\Console\Command\AbstractCommand;
use Rector\Utils\NodeDocumentationGenerator\NodeInfosFactory;
use Rector\Utils\NodeDocumentationGenerator\OutputFormatter\MarkdownDumpNodesOutputFormatter;
use Rector\Utils\NodeDocumentationGenerator\Printer\MarkdownNodeInfosPrinter;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symplify\PackageBuilder\Console\Command\CommandNaming;
use Symplify\PackageBuilder\Console\ShellCode;
use Symplify\SmartFileSystem\SmartFileInfo;
use Symplify\SmartFileSystem\SmartFileSystem;
final class DumpNodesCommand extends AbstractCommand
{
/**
* @var MarkdownDumpNodesOutputFormatter
* @var string
*/
private $markdownDumpNodesOutputFormatter;
private const OUTPUT_FILE = 'output-file';
/**
* @var MarkdownNodeInfosPrinter
*/
private $markdownNodeInfosPrinter;
/**
* @var NodeInfosFactory
*/
private $nodeInfosFactory;
/**
* @var SmartFileSystem
*/
private $smartFileSystem;
/**
* @var SymfonyStyle
*/
private $symfonyStyle;
public function __construct(
MarkdownDumpNodesOutputFormatter $markdownDumpNodesOutputFormatter,
NodeInfosFactory $nodeInfosFactory
MarkdownNodeInfosPrinter $markdownNodeInfosPrinter,
NodeInfosFactory $nodeInfosFactory,
SmartFileSystem $smartFileSystem,
SymfonyStyle $symfonyStyle
) {
$this->markdownDumpNodesOutputFormatter = $markdownDumpNodesOutputFormatter;
$this->markdownNodeInfosPrinter = $markdownNodeInfosPrinter;
$this->nodeInfosFactory = $nodeInfosFactory;
$this->smartFileSystem = $smartFileSystem;
$this->symfonyStyle = $symfonyStyle;
parent::__construct();
}
@ -38,12 +61,32 @@ final class DumpNodesCommand extends AbstractCommand
{
$this->setName(CommandNaming::classToName(self::class));
$this->setDescription('[DOCS] Dump overview of all Nodes');
$this->addOption(
self::OUTPUT_FILE,
null,
InputOption::VALUE_REQUIRED,
'Where to output the file',
getcwd() . '/docs/nodes_overview.md'
);
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$outputFile = (string) $input->getOption(self::OUTPUT_FILE);
$nodeInfos = $this->nodeInfosFactory->create();
$this->markdownDumpNodesOutputFormatter->format($nodeInfos);
$printedContent = $this->markdownNodeInfosPrinter->print($nodeInfos);
$this->smartFileSystem->dumpFile($outputFile, $printedContent);
$outputFileFileInfo = new SmartFileInfo($outputFile);
$message = sprintf(
'Documentation for "%d" PhpParser Nodes was generated to "%s"',
count($nodeInfos),
$outputFileFileInfo->getRelativeFilePathFromCwd()
);
$this->symfonyStyle->success($message);
return ShellCode::SUCCESS;
}

View File

@ -4,8 +4,8 @@ declare(strict_types=1);
namespace Rector\Utils\NodeDocumentationGenerator;
use Rector\Utils\NodeDocumentationGenerator\Sorter\NodeInfoSorter;
use Rector\Utils\NodeDocumentationGenerator\ValueObject\NodeInfo;
use Rector\Utils\NodeDocumentationGenerator\ValueObject\NodeInfos;
/**
* @see \Rector\Utils\NodeDocumentationGenerator\Tests\NodeInfosFactoryTest
@ -17,18 +17,27 @@ final class NodeInfosFactory
*/
private $nodeCodeSampleProvider;
public function __construct(NodeCodeSampleProvider $nodeCodeSampleProvider)
/**
* @var NodeInfoSorter
*/
private $nodeInfoSorter;
public function __construct(NodeCodeSampleProvider $nodeCodeSampleProvider, NodeInfoSorter $nodeInfoSorter)
{
$this->nodeCodeSampleProvider = $nodeCodeSampleProvider;
$this->nodeInfoSorter = $nodeInfoSorter;
}
public function create(): NodeInfos
/**
* @return NodeInfo[]
*/
public function create(): array
{
$nodeInfos = [];
foreach ($this->nodeCodeSampleProvider->provide() as $nodeClass => $nodeCodeSamples) {
$nodeInfos[] = new NodeInfo($nodeClass, $nodeCodeSamples);
}
return new NodeInfos($nodeInfos);
return $this->nodeInfoSorter->sortNodeInfosByClass($nodeInfos);
}
}

View File

@ -1,96 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Utils\NodeDocumentationGenerator\OutputFormatter;
use Rector\Utils\NodeDocumentationGenerator\ValueObject\NodeCodeSample;
use Rector\Utils\NodeDocumentationGenerator\ValueObject\NodeInfo;
use Rector\Utils\NodeDocumentationGenerator\ValueObject\NodeInfos;
use Symfony\Component\Console\Style\SymfonyStyle;
final class MarkdownDumpNodesOutputFormatter
{
/**
* @var SymfonyStyle
*/
private $symfonyStyle;
public function __construct(SymfonyStyle $symfonyStyle)
{
$this->symfonyStyle = $symfonyStyle;
}
public function format(NodeInfos $nodeInfos): void
{
$this->symfonyStyle->writeln('# Node Overview');
$this->symfonyStyle->newLine();
$this->symfonyStyle->newLine();
foreach ($nodeInfos->provide() as $nodeInfo) {
$message = sprintf('## `%s`', $nodeInfo->getClass());
$this->symfonyStyle->writeln($message);
$this->symfonyStyle->newLine();
$this->printCodeExample($nodeInfo);
$this->printPublicProperties($nodeInfo);
$this->symfonyStyle->newLine();
$this->symfonyStyle->writeln('<br>');
$this->symfonyStyle->newLine();
}
}
private function printCodeExample(NodeInfo $nodeInfo): void
{
$this->symfonyStyle->newLine();
$this->symfonyStyle->writeln('### Example PHP Code');
$this->symfonyStyle->newLine();
foreach ($nodeInfo->getNodeCodeSamples() as $nodeCodeSample) {
$this->printNodeCodeSample($nodeCodeSample);
$this->newLine();
}
}
private function printPublicProperties(NodeInfo $nodeInfo): void
{
if (! $nodeInfo->hasPublicProperties()) {
return;
}
$this->symfonyStyle->newLine();
$this->symfonyStyle->writeln('### Public Properties');
$this->symfonyStyle->newLine();
foreach ($nodeInfo->getPublicPropertyInfos() as $publicPropertyInfo) {
$this->symfonyStyle->writeln($publicPropertyInfo);
}
}
private function printNodeCodeSample(NodeCodeSample $nodeCodeSample): void
{
$this->printPhpSnippet($nodeCodeSample->getPhpCode());
$this->symfonyStyle->newLine();
$this->symfonyStyle->writeln('↓');
$this->symfonyStyle->newLine();
$this->printPhpSnippet($nodeCodeSample->getPrintedContent());
}
private function newLine(): void
{
$this->symfonyStyle->newLine();
$this->symfonyStyle->writeln('<br>');
$this->symfonyStyle->newLine();
}
private function printPhpSnippet(string $printedContent): void
{
$message = sprintf('```php%s%s%s```', PHP_EOL, $printedContent, PHP_EOL);
$this->symfonyStyle->writeln($message);
}
}

View File

@ -0,0 +1,83 @@
<?php
declare(strict_types=1);
namespace Rector\Utils\NodeDocumentationGenerator\Printer;
use Rector\Utils\NodeDocumentationGenerator\ValueObject\NodeCodeSample;
use Rector\Utils\NodeDocumentationGenerator\ValueObject\NodeInfo;
final class MarkdownNodeInfosPrinter
{
/**
* @param NodeInfo[] $nodeInfos
*/
public function print(array $nodeInfos): string
{
$contentLines = [];
$contentLines[] = '# Node Overview';
foreach ($nodeInfos as $nodeInfo) {
$contentLines[] = sprintf('## `%s`', $nodeInfo->getClass());
$contentLines[] = $this->printCodeExample($nodeInfo);
$contentLines[] = $this->printPublicProperties($nodeInfo);
$contentLines[] = '<br>';
}
return $this->implodeLinesWithSpace($contentLines);
}
private function printCodeExample(NodeInfo $nodeInfo): string
{
$contentLines = [];
$contentLines[] = '### Example PHP Code';
foreach ($nodeInfo->getNodeCodeSamples() as $nodeCodeSample) {
$contentLines[] = $this->printNodeCodeSample($nodeCodeSample);
$contentLines[] = '<br>';
}
return $this->implodeLinesWithSpace($contentLines);
}
private function printPublicProperties(NodeInfo $nodeInfo): string
{
if (! $nodeInfo->hasPublicProperties()) {
return '';
}
$contentLines = [];
$contentLines[] = '### Public Properties';
$contentLines[] = $this->implodeLines($nodeInfo->getPublicPropertyInfos());
return $this->implodeLinesWithSpace($contentLines);
}
private function implodeLinesWithSpace(array $contentLines): string
{
return implode(PHP_EOL . PHP_EOL, $contentLines);
}
private function printNodeCodeSample(NodeCodeSample $nodeCodeSample): string
{
$contentLines = [
$this->printPhpSnippet($nodeCodeSample->getPhpCode()),
'↓',
$this->printPhpSnippet($nodeCodeSample->getPrintedContent()),
];
return $this->implodeLinesWithSpace($contentLines);
}
private function implodeLines(array $contentLines): string
{
return implode(PHP_EOL, $contentLines);
}
private function printPhpSnippet(string $printedContent): string
{
return sprintf('```php%s%s%s```', PHP_EOL, $printedContent, PHP_EOL);
}
}

View File

@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace Rector\Utils\NodeDocumentationGenerator\Sorter;
use Rector\Utils\NodeDocumentationGenerator\ValueObject\NodeInfo;
final class NodeInfoSorter
{
/**
* @param NodeInfo[] $nodeInfos
* @return NodeInfo[]
*/
public function sortNodeInfosByClass(array $nodeInfos): array
{
usort($nodeInfos, function (NodeInfo $firstNodeInfo, NodeInfo $secondNodeInfo): int {
return $firstNodeInfo->getClass() <=> $secondNodeInfo->getClass();
});
return $nodeInfos;
}
}

View File

@ -1,42 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Utils\NodeDocumentationGenerator\ValueObject;
final class NodeInfos
{
/**
* @var NodeInfo[]
*/
private $nodeInfos = [];
/**
* @param NodeInfo[] $nodeInfos
*/
public function __construct(array $nodeInfos)
{
$this->nodeInfos = $this->sortNodeInfosByClass($nodeInfos);
}
/**
* @return NodeInfo[]
*/
public function provide(): array
{
return $this->nodeInfos;
}
/**
* @param NodeInfo[] $nodeInfos
* @return NodeInfo[]
*/
private function sortNodeInfosByClass(array $nodeInfos): array
{
usort($nodeInfos, function (NodeInfo $firstNodeInfo, NodeInfo $secondNodeInfo): int {
return $firstNodeInfo->getClass() <=> $secondNodeInfo->getClass();
});
return $nodeInfos;
}
}

View File

@ -26,7 +26,7 @@ final class NodeInfosFactoryTest extends AbstractKernelTestCase
{
$nodeInfos = $this->nodeInfosFactory->create();
$nodeInfoCount = count($nodeInfos->provide());
$nodeInfoCount = count($nodeInfos);
$this->assertGreaterThan(130, $nodeInfoCount);
}
}