[Transform] Decouple new set that changes nodes (#4073)

* [Transform] Move PropertyToMethodRector from Generic to Transform category

* move AbstractIsAbleRector to Generic

* [Transform] Move MethodCallToPropertyFetchRector from Generic to Transform

* [Transform] Move MethodCallToStaticCallRector from Generic to Transform

* [Transform] Move MethodCallToAnotherMethodCallWithArgumentsRector from Generic to Transform
This commit is contained in:
Tomas Votruba 2020-08-30 15:47:36 +02:00 committed by GitHub
parent 5d521b4d9f
commit e698e83687
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 278 additions and 262 deletions

View File

@ -100,6 +100,7 @@
"Rector\\NodeCollector\\": "packages/node-collector/src",
"Rector\\Decouple\\": "rules/decouple/src",
"Rector\\NodeNameResolver\\": "packages/node-name-resolver/src",
"Rector\\NodeNestingScope\\": "packages/node-nesting-scope/src",
"Rector\\NodeTypeResolver\\": "packages/node-type-resolver/src",
"Rector\\PhpAttribute\\": "packages/php-attribute/src",
"Rector\\PHPStanStaticTypeMapper\\": "packages/phpstan-static-type-mapper/src",
@ -115,7 +116,6 @@
"Rector\\Php55\\": "rules/php55/src",
"Rector\\Php56\\": "rules/php56/src",
"Rector\\Php70\\": "rules/php70/src",
"Rector\\Php\\": "rules/php/src",
"Rector\\Php71\\": "rules/php71/src",
"Rector\\Php72\\": "rules/php72/src",
"Rector\\Php73\\": "rules/php73/src",
@ -127,12 +127,12 @@
"Rector\\Polyfill\\": "rules/polyfill/src",
"Rector\\Privatization\\": "rules/privatization/src",
"Rector\\RectorGenerator\\": "packages/rector-generator/src",
"Rector\\Set\\": "packages/set/src",
"Rector\\RemovingStatic\\": "rules/removing-static/src",
"Rector\\Renaming\\": "rules/renaming/src",
"Rector\\Restoration\\": "rules/restoration/src",
"Rector\\Set\\": "packages/set/src",
"Rector\\SOLID\\": "rules/solid/src",
"Rector\\NodeNestingScope\\": "packages/node-nesting-scope/src",
"Rector\\Transform\\": "rules/transform/src",
"Rector\\Sensio\\": "rules/sensio/src",
"Rector\\StaticTypeMapper\\": "packages/static-type-mapper/src",
"Rector\\StrictCodeQuality\\": "rules/strict-code-quality/src",
@ -219,6 +219,7 @@
"Rector\\SymfonyCodeQuality\\Tests\\": "rules/symfony-code-quality/tests",
"Rector\\SymfonyPHPUnit\\Tests\\": "rules/symfony-phpunit/tests",
"Rector\\Symfony\\Tests\\": "rules/symfony/tests",
"Rector\\Transform\\Tests\\": "rules/transform/tests",
"Rector\\Twig\\Tests\\": "rules/twig/tests",
"Rector\\TypeDeclaration\\Tests\\": "rules/type-declaration/tests",
"Rector\\Utils\\DocumentationGenerator\\": "utils/documentation-generator/src",

View File

@ -4,18 +4,18 @@ declare(strict_types=1);
use Rector\CakePHP\Rector\MethodCall\ModalToGetSetRector;
use Rector\CakePHP\ValueObject\UnprefixedMethodToGetSet;
use Rector\Generic\Rector\Assign\PropertyToMethodRector;
use Rector\Generic\Rector\ClassMethod\ChangeMethodVisibilityRector;
use Rector\Generic\Rector\ClassMethod\NormalToFluentRector;
use Rector\Generic\Rector\PropertyFetch\RenamePropertyRector;
use Rector\Generic\ValueObject\CallToFluent;
use Rector\Generic\ValueObject\MethodVisibility;
use Rector\Generic\ValueObject\PropertyToMethodCall;
use Rector\Generic\ValueObject\RenamedProperty;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\Rector\Name\RenameClassRector;
use Rector\Renaming\ValueObject\MethodCallRename;
use function Rector\SymfonyPhpConfig\inline_value_objects;
use Rector\Transform\Rector\Assign\PropertyToMethodRector;
use Rector\Transform\ValueObject\PropertyToMethodCall;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {

View File

@ -2,12 +2,12 @@
declare(strict_types=1);
use Rector\Generic\Rector\Assign\PropertyToMethodRector;
use Rector\Generic\ValueObject\PropertyToMethodCall;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\Rector\Name\RenameClassRector;
use Rector\Renaming\ValueObject\MethodCallRename;
use function Rector\SymfonyPhpConfig\inline_value_objects;
use Rector\Transform\Rector\Assign\PropertyToMethodRector;
use Rector\Transform\ValueObject\PropertyToMethodCall;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {

View File

@ -5,13 +5,13 @@ declare(strict_types=1);
use Rector\CakePHP\Rector\MethodCall\ModalToGetSetRector;
use Rector\CakePHP\Rector\Property\ChangeSnakedFixtureNameToPascalRector;
use Rector\CakePHP\ValueObject\UnprefixedMethodToGetSet;
use Rector\Generic\Rector\Assign\PropertyToMethodRector;
use Rector\Generic\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector;
use Rector\Generic\ValueObject\MethodCallRenameWithAddedArguments;
use Rector\Generic\ValueObject\PropertyToMethodCall;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\ValueObject\MethodCallRename;
use function Rector\SymfonyPhpConfig\inline_value_objects;
use Rector\Transform\Rector\Assign\PropertyToMethodRector;
use Rector\Transform\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector;
use Rector\Transform\ValueObject\MethodCallRenameWithAddedArguments;
use Rector\Transform\ValueObject\PropertyToMethodCall;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
# source: https://book.cakephp.org/3.0/en/appendices/3-7-migration-guide.html

View File

@ -10,11 +10,11 @@ use Rector\Doctrine\Rector\ClassMethod\ServiceEntityRepositoryConstructorToDepen
use Rector\Generic\Rector\Class_\AddPropertyByParentRector;
use Rector\Generic\Rector\Class_\RemoveParentRector;
use Rector\Generic\Rector\ClassLike\RemoveAnnotationRector;
use Rector\Generic\Rector\MethodCall\MethodCallToPropertyFetchRector;
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 Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
/**

View File

@ -19,7 +19,7 @@
- [Downgrade](#downgrade) (1)
- [DynamicTypeAnalysis](#dynamictypeanalysis) (3)
- [FileSystemRector](#filesystemrector) (1)
- [Generic](#generic) (47)
- [Generic](#generic) (43)
- [Guzzle](#guzzle) (1)
- [Injection](#injection) (1)
- [JMS](#jms) (2)
@ -70,6 +70,7 @@
- [SymfonyCodeQuality](#symfonycodequality) (1)
- [SymfonyPHPUnit](#symfonyphpunit) (1)
- [SymfonyPhpConfig](#symfonyphpconfig) (2)
- [Transform](#transform) (4)
- [Twig](#twig) (1)
- [TypeDeclaration](#typedeclaration) (9)
@ -5337,77 +5338,6 @@ return function (ContainerConfigurator $containerConfigurator) : void {
<br><br>
### `MethodCallToAnotherMethodCallWithArgumentsRector`
- class: [`Rector\Generic\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector`](/../master/rules/generic/src/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector.php)
- [test fixtures](/../master/rules/generic/tests/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector/Fixture)
Turns old method call with specific types to new one with arguments
```php
<?php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Rector\Generic\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector;
return function (ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$services->set(MethodCallToAnotherMethodCallWithArgumentsRector::class)
->call('configure', [[
MethodCallToAnotherMethodCallWithArgumentsRector::METHOD_CALL_RENAMES_WITH_ADDED_ARGUMENTS => [
\Rector\SymfonyPhpConfig\inline_value_object(new Rector\Renaming\ValueObject\MethodCallRenameWithArrayKey('Nette\DI\ServiceDefinition', 'setInject', 'addTag', 'inject'))]
]]);
};
```
```diff
$serviceDefinition = new Nette\DI\ServiceDefinition;
-$serviceDefinition->setInject();
+$serviceDefinition->addTag('inject');
```
<br><br>
### `MethodCallToPropertyFetchRector`
- class: [`Rector\Generic\Rector\MethodCall\MethodCallToPropertyFetchRector`](/../master/rules/generic/src/Rector/MethodCall/MethodCallToPropertyFetchRector.php)
- [test fixtures](/../master/rules/generic/tests/Rector/MethodCall/MethodCallToPropertyFetchRector/Fixture)
Turns method call "$this->something()" to property fetch "$this->something"
```php
<?php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Rector\Generic\Rector\MethodCall\MethodCallToPropertyFetchRector;
return function (ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$services->set(MethodCallToPropertyFetchRector::class)
->call('configure', [[
MethodCallToPropertyFetchRector::METHOD_CALL_TO_PROPERTY_FETCHES => [
'someMethod' => 'someProperty']
]]);
};
```
```diff
class SomeClass
{
public function run()
{
- $this->someMethod();
+ $this->someProperty;
}
}
```
<br><br>
### `MethodCallToReturnRector`
- class: [`Rector\Generic\Rector\Expression\MethodCallToReturnRector`](/../master/rules/generic/src/Rector/Expression/MethodCallToReturnRector.php)
@ -5452,51 +5382,6 @@ return function (ContainerConfigurator $containerConfigurator) : void {
<br><br>
### `MethodCallToStaticCallRector`
- class: [`Rector\Generic\Rector\MethodCall\MethodCallToStaticCallRector`](/../master/rules/generic/src/Rector/MethodCall/MethodCallToStaticCallRector.php)
- [test fixtures](/../master/rules/generic/tests/Rector/MethodCall/MethodCallToStaticCallRector/Fixture)
Change method call to desired static call
```php
<?php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Rector\Generic\Rector\MethodCall\MethodCallToStaticCallRector;
return function (ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$services->set(MethodCallToStaticCallRector::class)
->call('configure', [[
MethodCallToStaticCallRector::METHOD_CALLS_TO_STATIC_CALLS => [
\Rector\SymfonyPhpConfig\inline_value_object(new Rector\Generic\ValueObject\MethodCallToStaticCall('AnotherDependency', 'process', 'StaticCaller', 'anotherMethod'))]
]]);
};
```
```diff
final class SomeClass
{
private $anotherDependency;
public function __construct(AnotherDependency $anotherDependency)
{
$this->anotherDependency = $anotherDependency;
}
public function loadConfiguration()
{
- return $this->anotherDependency->process('value');
+ return StaticCaller::anotherMethod('value');
}
}
```
<br><br>
### `NewObjectToFactoryCreateRector`
- class: [`Rector\Generic\Rector\New_\NewObjectToFactoryCreateRector`](/../master/rules/generic/src/Rector/New_/NewObjectToFactoryCreateRector.php)
@ -5683,63 +5568,6 @@ return function (ContainerConfigurator $containerConfigurator) : void {
<br><br>
### `PropertyToMethodRector`
- class: [`Rector\Generic\Rector\Assign\PropertyToMethodRector`](/../master/rules/generic/src/Rector/Assign/PropertyToMethodRector.php)
- [test fixtures](/../master/rules/generic/tests/Rector/Assign/PropertyToMethodRector/Fixture)
Replaces properties assign calls be defined methods.
```php
<?php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Rector\Generic\Rector\Assign\PropertyToMethodRector;
return function (ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$services->set(PropertyToMethodRector::class)
->call('configure', [[
PropertyToMethodRector::PROPERTIES_TO_METHOD_CALLS => [
\Rector\SymfonyPhpConfig\inline_value_object(new Rector\Generic\ValueObject\PropertyToMethodCall('SomeObject', 'property', 'getProperty', [], 'setProperty'))]
]]);
};
```
```diff
-$result = $object->property;
-$object->property = $value;
+$result = $object->getProperty();
+$object->setProperty($value);
```
```php
<?php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Rector\Generic\Rector\Assign\PropertyToMethodRector;
return function (ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$services->set(PropertyToMethodRector::class)
->call('configure', [[
PropertyToMethodRector::PROPERTIES_TO_METHOD_CALLS => [
\Rector\SymfonyPhpConfig\inline_value_object(new Rector\Generic\ValueObject\PropertyToMethodCall('SomeObject', 'property', 'getConfig', ['someArg'], null))]
]]);
};
```
```diff
-$result = $object->property;
+$result = $object->getProperty('someArg');
```
<br><br>
### `PseudoNamespaceToNamespaceRector`
- class: [`Rector\Generic\Rector\Name\PseudoNamespaceToNamespaceRector`](/../master/rules/generic/src/Rector/Name/PseudoNamespaceToNamespaceRector.php)
@ -14331,6 +14159,180 @@ return function (ContainerConfigurator $containerConfigurator) : void {
<br><br>
## Transform
### `MethodCallToAnotherMethodCallWithArgumentsRector`
- class: [`Rector\Transform\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector`](/../master/rules/transform/src/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector.php)
Turns old method call with specific types to new one with arguments
```php
<?php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Rector\Transform\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector;
return function (ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$services->set(MethodCallToAnotherMethodCallWithArgumentsRector::class)
->call('configure', [[
MethodCallToAnotherMethodCallWithArgumentsRector::METHOD_CALL_RENAMES_WITH_ADDED_ARGUMENTS => [
\Rector\SymfonyPhpConfig\inline_value_object(new Rector\Renaming\ValueObject\MethodCallRenameWithArrayKey('Nette\DI\ServiceDefinition', 'setInject', 'addTag', 'inject'))]
]]);
};
```
```diff
$serviceDefinition = new Nette\DI\ServiceDefinition;
-$serviceDefinition->setInject();
+$serviceDefinition->addTag('inject');
```
<br><br>
### `MethodCallToPropertyFetchRector`
- class: [`Rector\Transform\Rector\MethodCall\MethodCallToPropertyFetchRector`](/../master/rules/transform/src/Rector/MethodCall/MethodCallToPropertyFetchRector.php)
- [test fixtures](/../master/rules/transform/tests/Rector/MethodCall/MethodCallToPropertyFetchRector/Fixture)
Turns method call "$this->something()" to property fetch "$this->something"
```php
<?php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Rector\Transform\Rector\MethodCall\MethodCallToPropertyFetchRector;
return function (ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$services->set(MethodCallToPropertyFetchRector::class)
->call('configure', [[
MethodCallToPropertyFetchRector::METHOD_CALL_TO_PROPERTY_FETCHES => [
'someMethod' => 'someProperty']
]]);
};
```
```diff
class SomeClass
{
public function run()
{
- $this->someMethod();
+ $this->someProperty;
}
}
```
<br><br>
### `MethodCallToStaticCallRector`
- class: [`Rector\Transform\Rector\MethodCall\MethodCallToStaticCallRector`](/../master/rules/transform/src/Rector/MethodCall/MethodCallToStaticCallRector.php)
- [test fixtures](/../master/rules/transform/tests/Rector/MethodCall/MethodCallToStaticCallRector/Fixture)
Change method call to desired static call
```php
<?php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Rector\Transform\Rector\MethodCall\MethodCallToStaticCallRector;
return function (ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$services->set(MethodCallToStaticCallRector::class)
->call('configure', [[
MethodCallToStaticCallRector::METHOD_CALLS_TO_STATIC_CALLS => [
\Rector\SymfonyPhpConfig\inline_value_object(new Rector\Transform\ValueObject\MethodCallToStaticCall('AnotherDependency', 'process', 'StaticCaller', 'anotherMethod'))]
]]);
};
```
```diff
final class SomeClass
{
private $anotherDependency;
public function __construct(AnotherDependency $anotherDependency)
{
$this->anotherDependency = $anotherDependency;
}
public function loadConfiguration()
{
- return $this->anotherDependency->process('value');
+ return StaticCaller::anotherMethod('value');
}
}
```
<br><br>
### `PropertyToMethodRector`
- class: [`Rector\Transform\Rector\Assign\PropertyToMethodRector`](/../master/rules/transform/src/Rector/Assign/PropertyToMethodRector.php)
- [test fixtures](/../master/rules/transform/tests/Rector/Assign/PropertyToMethodRector/Fixture)
Replaces properties assign calls be defined methods.
```php
<?php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Rector\Transform\Rector\Assign\PropertyToMethodRector;
return function (ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$services->set(PropertyToMethodRector::class)
->call('configure', [[
PropertyToMethodRector::PROPERTIES_TO_METHOD_CALLS => [
\Rector\SymfonyPhpConfig\inline_value_object(new Rector\Transform\ValueObject\PropertyToMethodCall('SomeObject', 'property', 'getProperty', [], 'setProperty'))]
]]);
};
```
```diff
-$result = $object->property;
-$object->property = $value;
+$result = $object->getProperty();
+$object->setProperty($value);
```
```php
<?php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Rector\Transform\Rector\Assign\PropertyToMethodRector;
return function (ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$services->set(PropertyToMethodRector::class)
->call('configure', [[
PropertyToMethodRector::PROPERTIES_TO_METHOD_CALLS => [
\Rector\SymfonyPhpConfig\inline_value_object(new Rector\Transform\ValueObject\PropertyToMethodCall('SomeObject', 'property', 'getConfig', ['someArg'], null))]
]]);
};
```
```diff
-$result = $object->property;
+$result = $object->getProperty('someArg');
```
<br><br>
## Twig
### `SimpleFunctionAndFilterRector`

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace Rector\Php\Rector;
namespace Rector\Generic\Rector;
use PhpParser\Node;
use PhpParser\Node\Expr\BinaryOp\BooleanOr;

View File

@ -1,6 +1,6 @@
<?php
use Rector\Generic\Tests\Rector\Assign\PropertyToMethodRector\Source\Translator;
use Rector\Transform\Tests\Rector\Assign\PropertyToMethodRector\Source\Translator;
class CustomTranslator extends Translator
{
@ -18,7 +18,7 @@ class CustomTranslator extends Translator
-----
<?php
use Rector\Generic\Tests\Rector\Assign\PropertyToMethodRector\Source\Translator;
use Rector\Transform\Tests\Rector\Assign\PropertyToMethodRector\Source\Translator;
class CustomTranslator extends Translator
{

View File

@ -1,10 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Generic\Tests\Rector\Assign\PropertyToMethodRector\Source;
class Translator
{
}

View File

@ -1,6 +1,6 @@
<?php
use Rector\Generic\Tests\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector\Source\NetteServiceDefinition;
use Rector\Transform\Tests\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector\Source\NetteServiceDefinition;
class SomeNetteExtension
{
@ -15,7 +15,7 @@ class SomeNetteExtension
-----
<?php
use Rector\Generic\Tests\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector\Source\NetteServiceDefinition;
use Rector\Transform\Tests\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector\Source\NetteServiceDefinition;
class SomeNetteExtension
{

View File

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

View File

@ -1,9 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Generic\Tests\Rector\MethodCall\MethodCallToStaticCallRector;
final class AnotherDependency
{
}

View File

@ -7,7 +7,7 @@ namespace Rector\Php71\Rector\BinaryOp;
use Rector\Core\RectorDefinition\CodeSample;
use Rector\Core\RectorDefinition\RectorDefinition;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\Php\Rector\AbstractIsAbleRector;
use Rector\Generic\Rector\AbstractIsAbleRector;
/**
* @see \Rector\Php71\Tests\Rector\BinaryOp\IsIterableRector\IsIterableRectorTest

View File

@ -7,7 +7,7 @@ namespace Rector\Php73\Rector\BinaryOp;
use Rector\Core\RectorDefinition\CodeSample;
use Rector\Core\RectorDefinition\RectorDefinition;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\Php\Rector\AbstractIsAbleRector;
use Rector\Generic\Rector\AbstractIsAbleRector;
/**
* @see \Rector\Php73\Tests\Rector\BinaryOp\IsCountableRector\IsCountableRectorTest

View File

@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->defaults()
->public()
->autowire();
$services->load('Rector\Transform\\', __DIR__ . '/../src')
->exclude([__DIR__ . '/../src/Rector', __DIR__ . '/../src/ValueObject']);
};

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace Rector\Generic\Rector\Assign;
namespace Rector\Transform\Rector\Assign;
use PhpParser\Node;
use PhpParser\Node\Expr\Assign;
@ -13,14 +13,11 @@ use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\RectorDefinition\ConfiguredCodeSample;
use Rector\Core\RectorDefinition\RectorDefinition;
use Rector\Generic\ValueObject\PropertyToMethodCall;
use Rector\Transform\ValueObject\PropertyToMethodCall;
use Webmozart\Assert\Assert;
/**
* @todo extract to "transform" or similar set, along with other static call to something else,
* it's like rename, just with node type change
*
* @see \Rector\Generic\Tests\Rector\Assign\PropertyToMethodRector\PropertyToMethodRectorTest
* @see \Rector\Transform\Tests\Rector\Assign\PropertyToMethodRector\PropertyToMethodRectorTest
*/
final class PropertyToMethodRector extends AbstractRector implements ConfigurableRectorInterface
{

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;
@ -11,12 +11,12 @@ 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\MethodCallRenameWithAddedArguments;
use Rector\Renaming\ValueObject\MethodCallRenameWithArrayKey;
use Rector\Transform\ValueObject\MethodCallRenameWithAddedArguments;
use Webmozart\Assert\Assert;
/**
* @see \Rector\Generic\Tests\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector\MethodCallToAnotherMethodCallWithArgumentsRectorTest
* @see \Rector\Transform\Tests\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector\MethodCallToAnotherMethodCallWithArgumentsRectorTest
*/
final class MethodCallToAnotherMethodCallWithArgumentsRector extends AbstractRector implements ConfigurableRectorInterface
{

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;
@ -13,7 +13,7 @@ use Rector\Core\RectorDefinition\ConfiguredCodeSample;
use Rector\Core\RectorDefinition\RectorDefinition;
/**
* @see \Rector\Generic\Tests\Rector\MethodCall\MethodCallToPropertyFetchRector\MethodCallToPropertyFetchRectorTest
* @see \Rector\Transform\Tests\Rector\MethodCall\MethodCallToPropertyFetchRector\MethodCallToPropertyFetchRectorTest
*/
final class MethodCallToPropertyFetchRector extends AbstractRector implements ConfigurableRectorInterface
{
@ -21,7 +21,7 @@ final class MethodCallToPropertyFetchRector extends AbstractRector implements Co
* @api
* @var string
*/
public const METHOD_CALL_TO_PROPERTY_FETCHES = '$methodCallToPropertyFetchCollection';
public const METHOD_CALL_TO_PROPERTY_FETCHES = 'method_call_to_property_fetch_collection';
/**
* @var array<string, string>

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;
@ -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\MethodCallToStaticCall;
use Rector\Transform\ValueObject\MethodCallToStaticCall;
use Webmozart\Assert\Assert;
/**
* @see \Rector\Generic\Tests\Rector\MethodCall\MethodCallToStaticCallRector\MethodCallToStaticCallRectorTest
* @see \Rector\Transform\Tests\Rector\MethodCall\MethodCallToStaticCallRector\MethodCallToStaticCallRectorTest
*/
final class MethodCallToStaticCallRector extends AbstractRector implements ConfigurableRectorInterface
{

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
<?php
namespace Rector\Generic\Tests\Rector\Assign\PropertyToMethodRector\Fixture;
namespace Rector\Transform\Tests\Rector\Assign\PropertyToMethodRector\Fixture;
final class SomeClassWithParameters
{
@ -16,7 +16,7 @@ final class SomeClassWithParameters
-----
<?php
namespace Rector\Generic\Tests\Rector\Assign\PropertyToMethodRector\Fixture;
namespace Rector\Transform\Tests\Rector\Assign\PropertyToMethodRector\Fixture;
final class SomeClassWithParameters
{

View File

@ -2,13 +2,13 @@
declare(strict_types=1);
namespace Rector\Generic\Tests\Rector\Assign\PropertyToMethodRector;
namespace Rector\Transform\Tests\Rector\Assign\PropertyToMethodRector;
use Iterator;
use Rector\Core\Testing\PHPUnit\AbstractRectorTestCase;
use Rector\Generic\Rector\Assign\PropertyToMethodRector;
use Rector\Generic\Tests\Rector\Assign\PropertyToMethodRector\Source\Translator;
use Rector\Generic\ValueObject\PropertyToMethodCall;
use Rector\Transform\Rector\Assign\PropertyToMethodRector;
use Rector\Transform\Tests\Rector\Assign\PropertyToMethodRector\Source\Translator;
use Rector\Transform\ValueObject\PropertyToMethodCall;
use Symplify\SmartFileSystem\SmartFileInfo;
final class PropertyToMethodRectorTest extends AbstractRectorTestCase
@ -36,7 +36,7 @@ final class PropertyToMethodRectorTest extends AbstractRectorTestCase
PropertyToMethodRector::PROPERTIES_TO_METHOD_CALLS => [
new PropertyToMethodCall(Translator::class, 'locale', 'getLocale', 'setLocale'),
new PropertyToMethodCall(
'Rector\Generic\Tests\Rector\Assign\PropertyToMethodRector\Fixture\SomeClassWithParameters',
'Rector\Transform\Tests\Rector\Assign\PropertyToMethodRector\Fixture\SomeClassWithParameters',
'parameter',
'getConfig',
null,

View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Rector\Transform\Tests\Rector\Assign\PropertyToMethodRector\Source;
class Translator
{
}

View File

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

View File

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

View File

@ -1,6 +1,6 @@
<?php
namespace Rector\Generic\Tests\Rector\MethodCall\MethodCallToPropertyFetchRector\Fixture;
namespace Rector\Transform\Tests\Rector\MethodCall\MethodCallToPropertyFetchRector\Fixture;
class SomeClass
{
@ -14,7 +14,7 @@ class SomeClass
-----
<?php
namespace Rector\Generic\Tests\Rector\MethodCall\MethodCallToPropertyFetchRector\Fixture;
namespace Rector\Transform\Tests\Rector\MethodCall\MethodCallToPropertyFetchRector\Fixture;
class SomeClass
{

View File

@ -2,11 +2,11 @@
declare(strict_types=1);
namespace Rector\Generic\Tests\Rector\MethodCall\MethodCallToPropertyFetchRector;
namespace Rector\Transform\Tests\Rector\MethodCall\MethodCallToPropertyFetchRector;
use Iterator;
use Rector\Core\Testing\PHPUnit\AbstractRectorTestCase;
use Rector\Generic\Rector\MethodCall\MethodCallToPropertyFetchRector;
use Rector\Transform\Rector\MethodCall\MethodCallToPropertyFetchRector;
use Symplify\SmartFileSystem\SmartFileInfo;
final class MethodCallToPropertyFetchRectorTest extends AbstractRectorTestCase

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Rector\Transform\Tests\Rector\MethodCall\MethodCallToStaticCallRector;
final class AnotherDependency
{
}

View File

@ -1,8 +1,8 @@
<?php
namespace Rector\Generic\Tests\Rector\MethodCall\MethodCallToStaticCallRector\Fixture;
namespace Rector\Transform\Tests\Rector\MethodCall\MethodCallToStaticCallRector\Fixture;
use Rector\Generic\Tests\Rector\MethodCall\MethodCallToStaticCallRector\AnotherDependency;
use Rector\Transform\Tests\Rector\MethodCall\MethodCallToStaticCallRector\AnotherDependency;
final class SomeClass
{
@ -23,9 +23,9 @@ final class SomeClass
-----
<?php
namespace Rector\Generic\Tests\Rector\MethodCall\MethodCallToStaticCallRector\Fixture;
namespace Rector\Transform\Tests\Rector\MethodCall\MethodCallToStaticCallRector\Fixture;
use Rector\Generic\Tests\Rector\MethodCall\MethodCallToStaticCallRector\AnotherDependency;
use Rector\Transform\Tests\Rector\MethodCall\MethodCallToStaticCallRector\AnotherDependency;
final class SomeClass
{

View File

@ -2,12 +2,12 @@
declare(strict_types=1);
namespace Rector\Generic\Tests\Rector\MethodCall\MethodCallToStaticCallRector;
namespace Rector\Transform\Tests\Rector\MethodCall\MethodCallToStaticCallRector;
use Iterator;
use Rector\Core\Testing\PHPUnit\AbstractRectorTestCase;
use Rector\Generic\Rector\MethodCall\MethodCallToStaticCallRector;
use Rector\Generic\ValueObject\MethodCallToStaticCall;
use Rector\Transform\Rector\MethodCall\MethodCallToStaticCallRector;
use Rector\Transform\ValueObject\MethodCallToStaticCall;
use Symplify\SmartFileSystem\SmartFileInfo;
final class MethodCallToStaticCallRectorTest extends AbstractRectorTestCase