mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-28 23:10:51 +00:00
[Tests] Move from getRectorsWithConfiguration() to provideConfigFileInfo() to make test configs more intuitive (#5468)
Co-authored-by: kaizen-ci <info@kaizen-ci.org>
This commit is contained in:
parent
31ceccc571
commit
e0ad0f960f
|
@ -27,6 +27,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
|
||||
// skip classes used in PHP DocBlocks, like in /** @var \Some\Class */ [default: true]
|
||||
$parameters->set(Option::IMPORT_DOC_BLOCKS, false);
|
||||
|
||||
$services->set(DowngradeClassConstantVisibilityRector::class);
|
||||
$services->set(DowngradePipeToMultiCatchExceptionRector::class);
|
||||
$services->set(SymmetricArrayDestructuringToListRector::class);
|
||||
|
|
|
@ -22,5 +22,6 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
|
||||
// skip classes used in PHP DocBlocks, like in /** @var \Some\Class */ [default: true]
|
||||
$parameters->set(Option::IMPORT_DOC_BLOCKS, false);
|
||||
|
||||
$services->set(DowngradeParameterTypeWideningRector::class);
|
||||
};
|
||||
|
|
|
@ -23,6 +23,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
|
||||
// skip classes used in PHP DocBlocks, like in /** @var \Some\Class */ [default: true]
|
||||
$parameters->set(Option::IMPORT_DOC_BLOCKS, false);
|
||||
|
||||
$services->set(DowngradeTrailingCommasInFunctionCallsRector::class);
|
||||
$services->set(SetCookieOptionsArrayToArgumentsRector::class);
|
||||
};
|
||||
|
|
|
@ -37,6 +37,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
|
||||
// skip classes used in PHP DocBlocks, like in /** @var \Some\Class */ [default: true]
|
||||
$parameters->set(Option::IMPORT_DOC_BLOCKS, false);
|
||||
|
||||
$services->set(DowngradeFreadFwriteFalsyToNegationRector::class);
|
||||
$services->set(DowngradeReturnSelfTypeDeclarationRector::class);
|
||||
};
|
||||
|
|
|
@ -35,6 +35,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
|
||||
// skip classes used in PHP DocBlocks, like in /** @var \Some\Class */ [default: true]
|
||||
$parameters->set(Option::IMPORT_DOC_BLOCKS, false);
|
||||
|
||||
$services->set(DowngradePropertyPromotionRector::class);
|
||||
$services->set(DowngradeNonCapturingCatchesRector::class);
|
||||
$services->set(DowngradeMatchToSwitchRector::class);
|
||||
|
|
|
@ -7,7 +7,7 @@ use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
|
|||
use Rector\Renaming\ValueObject\MethodCallRename;
|
||||
use Rector\Transform\Rector\FuncCall\FuncCallToMethodCallRector;
|
||||
use Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector;
|
||||
use Rector\Transform\ValueObject\FuncNameToMethodCallName;
|
||||
use Rector\Transform\ValueObject\FuncCallToMethodCall;
|
||||
use Rector\Transform\ValueObject\StaticCallToFuncCall;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
@ -19,8 +19,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
$services->set(FluentChainMethodCallToNormalMethodCallRector::class);
|
||||
|
||||
$configuration = [
|
||||
new FuncNameToMethodCallName('GuzzleHttp\json_decode', 'GuzzleHttp\Utils', 'jsonDecode'),
|
||||
new FuncNameToMethodCallName('GuzzleHttp\get_path', 'GuzzleHttp\Utils', 'getPath'),
|
||||
new FuncCallToMethodCall('GuzzleHttp\json_decode', 'GuzzleHttp\Utils', 'jsonDecode'),
|
||||
new FuncCallToMethodCall('GuzzleHttp\get_path', 'GuzzleHttp\Utils', 'getPath'),
|
||||
];
|
||||
|
||||
$services->set(FuncCallToMethodCallRector::class)
|
||||
|
|
|
@ -9544,7 +9544,7 @@ Move array argument from tests into data provider [configurable]
|
|||
- class: `Rector\PHPUnit\Rector\Class_\ArrayArgumentInTestToDataProviderRector`
|
||||
|
||||
```php
|
||||
use Rector\PHPUnit\Rector\Class_\ArrayArgumentInTestToDataProviderRector;
|
||||
use Rector\PHPUnit\Rector\Class_\ArrayArgumentToDataProviderRector;
|
||||
use Rector\PHPUnit\ValueObject\ArrayArgumentToDataProvider;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
@ -9552,9 +9552,9 @@ use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
|||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
|
||||
$services->set(ArrayArgumentInTestToDataProviderRector::class)
|
||||
$services->set(ArrayArgumentToDataProviderRector::class)
|
||||
->call('configure', [[
|
||||
ArrayArgumentInTestToDataProviderRector::ARRAY_ARGUMENTS_TO_DATA_PROVIDERS => ValueObjectInliner::inline([
|
||||
ArrayArgumentToDataProviderRector::ARRAY_ARGUMENTS_TO_DATA_PROVIDERS => ValueObjectInliner::inline([
|
||||
new ArrayArgumentToDataProvider('PHPUnit\Framework\TestCase', 'doTestMultiple', 'doTestSingle', 'number'),
|
||||
]),
|
||||
]]);
|
||||
|
@ -13868,7 +13868,7 @@ In case you have accidentally removed use imports but code still contains partia
|
|||
|
||||
```php
|
||||
use Rector\Restoration\Rector\Namespace_\CompleteImportForPartialAnnotationRector;
|
||||
use Rector\Restoration\ValueObject\UseWithAlias;
|
||||
use Rector\Restoration\ValueObject\CompleteImportForPartialAnnotation;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
|
@ -13878,7 +13878,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
$services->set(CompleteImportForPartialAnnotationRector::class)
|
||||
->call('configure', [[
|
||||
CompleteImportForPartialAnnotationRector::USE_IMPORTS_TO_RESTORE => ValueObjectInliner::inline([
|
||||
new UseWithAlias('Doctrine\ORM\Mapping', 'ORM'),
|
||||
new CompleteImportForPartialAnnotation('Doctrine\ORM\Mapping', 'ORM'),
|
||||
]),
|
||||
]]);
|
||||
};
|
||||
|
@ -15411,7 +15411,7 @@ Replaces constant by value
|
|||
- class: `Rector\Transform\Rector\ClassConstFetch\ClassConstFetchToStringRector`
|
||||
|
||||
```php
|
||||
use Rector\Transform\Rector\ClassConstFetch\ClassConstFetchToStringRector;
|
||||
use Rector\Transform\Rector\ClassConstFetch\ClassConstFetchToValueRector;
|
||||
use Rector\Transform\ValueObject\ClassConstFetchToValue;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
@ -15419,9 +15419,9 @@ use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
|||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
|
||||
$services->set(ClassConstFetchToStringRector::class)
|
||||
$services->set(ClassConstFetchToValueRector::class)
|
||||
->call('configure', [[
|
||||
ClassConstFetchToStringRector::CLASS_CONST_FETCHES_TO_VALUES => ValueObjectInliner::inline([
|
||||
ClassConstFetchToValueRector::CLASS_CONST_FETCHES_TO_VALUES => ValueObjectInliner::inline([
|
||||
new ClassConstFetchToValue('Nette\Configurator', 'DEVELOPMENT', 'development'),
|
||||
new ClassConstFetchToValue('Nette\Configurator', 'PRODUCTION', 'production'),
|
||||
]),
|
||||
|
@ -15493,7 +15493,7 @@ Turns defined function calls to local method calls.
|
|||
|
||||
```php
|
||||
use Rector\Transform\Rector\FuncCall\FuncCallToMethodCallRector;
|
||||
use Rector\Transform\ValueObject\FuncNameToMethodCallName;
|
||||
use Rector\Transform\ValueObject\FuncCallToMethodCall;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
|
@ -15503,7 +15503,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
$services->set(FuncCallToMethodCallRector::class)
|
||||
->call('configure', [[
|
||||
FuncCallToMethodCallRector::FUNC_CALL_TO_CLASS_METHOD_CALL => ValueObjectInliner::inline([
|
||||
new FuncNameToMethodCallName('view', 'Namespaced\SomeRenderer', 'render'),
|
||||
new FuncCallToMethodCall('view', 'Namespaced\SomeRenderer', 'render'),
|
||||
]),
|
||||
]]);
|
||||
};
|
||||
|
@ -16488,7 +16488,7 @@ Turns defined `__isset`/`__unset` calls to specific method calls.
|
|||
|
||||
```php
|
||||
use Rector\Transform\Rector\Isset_\UnsetAndIssetToMethodCallRector;
|
||||
use Rector\Transform\ValueObject\IssetUnsetToMethodCall;
|
||||
use Rector\Transform\ValueObject\UnsetAndIssetToMethodCall;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
|
@ -16498,7 +16498,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
$services->set(UnsetAndIssetToMethodCallRector::class)
|
||||
->call('configure', [[
|
||||
UnsetAndIssetToMethodCallRector::ISSET_UNSET_TO_METHOD_CALL => ValueObjectInliner::inline([
|
||||
new IssetUnsetToMethodCall('SomeContainer', 'hasService', 'removeService'),
|
||||
new UnsetAndIssetToMethodCall('SomeContainer', 'hasService', 'removeService'),
|
||||
]),
|
||||
]]);
|
||||
};
|
||||
|
@ -16516,7 +16516,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
|
||||
```php
|
||||
use Rector\Transform\Rector\Isset_\UnsetAndIssetToMethodCallRector;
|
||||
use Rector\Transform\ValueObject\IssetUnsetToMethodCall;
|
||||
use Rector\Transform\ValueObject\UnsetAndIssetToMethodCall;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
|
@ -16526,7 +16526,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
$services->set(UnsetAndIssetToMethodCallRector::class)
|
||||
->call('configure', [[
|
||||
UnsetAndIssetToMethodCallRector::ISSET_UNSET_TO_METHOD_CALL => ValueObjectInliner::inline([
|
||||
new IssetUnsetToMethodCall('SomeContainer', 'hasService', 'removeService'),
|
||||
new UnsetAndIssetToMethodCall('SomeContainer', 'hasService', 'removeService'),
|
||||
]),
|
||||
]]);
|
||||
};
|
||||
|
@ -16967,7 +16967,7 @@ Change visibility of constant from parent class.
|
|||
|
||||
```php
|
||||
use Rector\Visibility\Rector\ClassConst\ChangeConstantVisibilityRector;
|
||||
use Rector\Visibility\ValueObject\ClassConstantVisibilityChange;
|
||||
use Rector\Visibility\ValueObject\ChangeConstantVisibility;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
|
@ -16977,7 +16977,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
$services->set(ChangeConstantVisibilityRector::class)
|
||||
->call('configure', [[
|
||||
ChangeConstantVisibilityRector::CLASS_CONSTANT_VISIBILITY_CHANGES => ValueObjectInliner::inline([
|
||||
new ClassConstantVisibilityChange('ParentObject', 'SOME_CONSTANT', 2),
|
||||
new ChangeConstantVisibility('ParentObject', 'SOME_CONSTANT', 2),
|
||||
]),
|
||||
]]);
|
||||
};
|
||||
|
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||
namespace Rector\__Package__\Tests\Rector\__Category__\__Name__;
|
||||
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class __Name__Test extends AbstractRectorTestCase
|
||||
{
|
||||
|
@ -22,14 +23,8 @@ final class __Name__Test extends AbstractRectorTestCase
|
|||
yield [new \Symplify\SmartFileSystem\SmartFileInfo(__DIR__ . '/Fixture/some_class.php.inc'), '__ExtraFileName__', __DIR__ . '/Source/extra_file.php'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed[]
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?\Symplify\SmartFileSystem\SmartFileInfo
|
||||
{
|
||||
return [
|
||||
\Rector\__Package__\Rector\__Category__\__Name__::class =>
|
||||
__TestRuleConfiguration__
|
||||
];
|
||||
return new \Symplify\SmartFileSystem\SmartFileInfo(__DIR__ . '/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,14 +21,8 @@ final class __Name__Test extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed[]
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?\Symplify\SmartFileSystem\SmartFileInfo
|
||||
{
|
||||
return [
|
||||
\Rector\__Package__\Rector\__Category__\__Name__::class =>
|
||||
__TestRuleConfiguration__
|
||||
];
|
||||
return new \Symplify\SmartFileSystem\SmartFileInfo(__DIR__ . '/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,14 +21,8 @@ final class WhateverRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed[]
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?\Symplify\SmartFileSystem\SmartFileInfo
|
||||
{
|
||||
return [
|
||||
\Rector\ModeratePackage\Rector\MethodCall\WhateverRector::class =>
|
||||
[\Rector\ModeratePackage\Rector\MethodCall\WhateverRector::CLASS_TYPE_TO_METHOD_NAME => ['SomeClass' => 'configure']]
|
||||
];
|
||||
return new \Symplify\SmartFileSystem\SmartFileInfo(__DIR__ . '/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,14 +21,8 @@ final class WhateverRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed[]
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?\Symplify\SmartFileSystem\SmartFileInfo
|
||||
{
|
||||
return [
|
||||
\Utils\Rector\Rector\MethodCall\WhateverRector::class =>
|
||||
[\Utils\Rector\Rector\MethodCall\WhateverRector::CLASS_TYPE_TO_METHOD_NAME => ['SomeClass' => 'configure']]
|
||||
];
|
||||
return new \Symplify\SmartFileSystem\SmartFileInfo(__DIR__ . '/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ use Rector\Core\PhpParser\Printer\BetterStandardPrinter;
|
|||
use Rector\Core\Stubs\StubLoader;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
use Rector\Core\ValueObject\StaticNonPhpFileSuffixes;
|
||||
use Rector\Naming\Tests\Rector\Class_\RenamePropertyToMatchTypeRector\Source\ContainerInterface;
|
||||
use Rector\Testing\Application\EnabledRectorsProvider;
|
||||
use Rector\Testing\Contract\RunnableInterface;
|
||||
use Rector\Testing\Finder\RectorsFinder;
|
||||
|
@ -31,8 +30,6 @@ use Rector\Testing\PHPUnit\Behavior\RunnableTestTrait;
|
|||
use Rector\Testing\ValueObject\InputFilePathWithExpectedFile;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symplify\EasyTesting\DataProvider\StaticFixtureFinder;
|
||||
use Symplify\EasyTesting\DataProvider\StaticFixtureUpdater;
|
||||
use Symplify\EasyTesting\StaticFixtureSplitter;
|
||||
|
@ -97,7 +94,7 @@ abstract class AbstractRectorTestCase extends AbstractKernelTestCase
|
|||
protected $originalTempFileInfo;
|
||||
|
||||
/**
|
||||
* @var Container|ContainerInterface|null
|
||||
* @var SmartFileInfo
|
||||
*/
|
||||
protected static $allRectorContainer;
|
||||
|
||||
|
@ -125,7 +122,7 @@ abstract class AbstractRectorTestCase extends AbstractKernelTestCase
|
|||
if ($this->provideConfigFileInfo() !== null) {
|
||||
$configFileInfos = $this->resolveConfigs($this->provideConfigFileInfo());
|
||||
|
||||
$this->bootKernelWithConfigInfos(RectorKernel::class, $configFileInfos);
|
||||
$this->bootKernelWithConfigs(RectorKernel::class, $configFileInfos);
|
||||
|
||||
$enabledRectorsProvider = $this->getService(EnabledRectorsProvider::class);
|
||||
$enabledRectorsProvider->reset();
|
||||
|
@ -199,30 +196,10 @@ abstract class AbstractRectorTestCase extends AbstractKernelTestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use config instead, just to narrow 2 ways to add configured config to just 1. Now
|
||||
* with PHP its easy pick.
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
{
|
||||
// can be implemented, has the highest priority
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed[]
|
||||
* @return array<string, null>
|
||||
*/
|
||||
protected function getCurrentTestRectorClassesWithConfiguration(): array
|
||||
{
|
||||
if ($this->getRectorsWithConfiguration() !== []) {
|
||||
foreach (array_keys($this->getRectorsWithConfiguration()) as $rectorClass) {
|
||||
$this->ensureRectorClassIsValid($rectorClass, 'getRectorsWithConfiguration');
|
||||
}
|
||||
|
||||
return $this->getRectorsWithConfiguration();
|
||||
}
|
||||
|
||||
$rectorClass = $this->getRectorClass();
|
||||
$this->ensureRectorClassIsValid($rectorClass, 'getRectorClass');
|
||||
|
||||
|
@ -251,37 +228,12 @@ abstract class AbstractRectorTestCase extends AbstractKernelTestCase
|
|||
$parameterProvider->changeParameter($name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Will be supported in Symplify 9
|
||||
* @param SmartFileInfo[] $configFileInfos
|
||||
*/
|
||||
protected function bootKernelWithConfigInfos(string $class, array $configFileInfos): KernelInterface
|
||||
{
|
||||
$configFiles = [];
|
||||
foreach ($configFileInfos as $configFileInfo) {
|
||||
$configFiles[] = $configFileInfo->getRealPath();
|
||||
}
|
||||
|
||||
return $this->bootKernelWithConfigs($class, $configFiles);
|
||||
}
|
||||
|
||||
protected function getPhpVersion(): int
|
||||
{
|
||||
// to be implemented
|
||||
return self::PHP_VERSION_UNDEFINED;
|
||||
}
|
||||
|
||||
protected function assertFileMissing(string $temporaryFilePath): void
|
||||
{
|
||||
// PHPUnit 9.0 ready
|
||||
if (method_exists($this, 'assertFileDoesNotExist')) {
|
||||
$this->assertFileDoesNotExist($temporaryFilePath);
|
||||
} else {
|
||||
// PHPUnit 8.0 ready
|
||||
$this->assertFileNotExists($temporaryFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
protected function doTestFileInfoWithoutAutoload(SmartFileInfo $fileInfo): void
|
||||
{
|
||||
$this->autoloadTestFixture = false;
|
||||
|
@ -518,6 +470,7 @@ abstract class AbstractRectorTestCase extends AbstractKernelTestCase
|
|||
$coreRectorClasses = $rectorsFinder->findCoreRectorClasses();
|
||||
|
||||
$listForConfig = [];
|
||||
|
||||
foreach ($coreRectorClasses as $rectorClass) {
|
||||
$listForConfig[$rectorClass] = null;
|
||||
}
|
||||
|
|
|
@ -527,3 +527,8 @@ parameters:
|
|||
|
||||
- '#Trait method "printArrayItem\(\)" should not contain any logic, but only delegate to other class call#'
|
||||
- '#Trait method "makeKeysExplicit\(\)" should not contain any logic, but only delegate to other class call#'
|
||||
|
||||
-
|
||||
message: '#For complex configuration use value object over array#'
|
||||
paths:
|
||||
- '*/config/configured_rule.php'
|
||||
|
|
|
@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\Autodiscovery\Tests\Rector\FileNode\MoveServicesBySuffixToDirectoryRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector;
|
||||
use Rector\FileSystemRector\ValueObject\AddedFileWithContent;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
@ -77,20 +76,8 @@ final class MoveServicesBySuffixToDirectoryRectorTest extends AbstractRectorTest
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
MoveServicesBySuffixToDirectoryRector::class => [
|
||||
MoveServicesBySuffixToDirectoryRector::GROUP_NAMES_BY_SUFFIX => [
|
||||
'Repository',
|
||||
'Command',
|
||||
'Mapper',
|
||||
'Controller',
|
||||
],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
use Rector\Autodiscovery\Rector\FileNode\MoveServicesBySuffixToDirectoryRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(MoveServicesBySuffixToDirectoryRector::class)->call(
|
||||
'configure',
|
||||
[[
|
||||
MoveServicesBySuffixToDirectoryRector::GROUP_NAMES_BY_SUFFIX => [
|
||||
'Repository',
|
||||
'Command',
|
||||
'Mapper',
|
||||
'Controller',
|
||||
],
|
||||
]]
|
||||
);
|
||||
};
|
|
@ -5,8 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\Autodiscovery\Tests\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector;
|
||||
use Rector\Autodiscovery\Tests\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector\Source\ObviousValueObjectInterface;
|
||||
use Rector\FileSystemRector\ValueObject\AddedFileWithContent;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
@ -62,17 +60,8 @@ final class MoveValueObjectsToValueObjectDirectoryRectorTest extends AbstractRec
|
|||
yield [new SmartFileInfo(__DIR__ . '/Source/Utils/SomeSuffixedTest.php.inc'), null];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
MoveValueObjectsToValueObjectDirectoryRector::class => [
|
||||
MoveValueObjectsToValueObjectDirectoryRector::TYPES => [ObviousValueObjectInterface::class],
|
||||
MoveValueObjectsToValueObjectDirectoryRector::SUFFIXES => ['Search'],
|
||||
MoveValueObjectsToValueObjectDirectoryRector::ENABLE_VALUE_OBJECT_GUESSING => true,
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
use Rector\Autodiscovery\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector;
|
||||
use Rector\Autodiscovery\Tests\Rector\FileNode\MoveValueObjectsToValueObjectDirectoryRector\Source\ObviousValueObjectInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(MoveValueObjectsToValueObjectDirectoryRector::class)->call(
|
||||
'configure',
|
||||
[[
|
||||
MoveValueObjectsToValueObjectDirectoryRector::TYPES => [ObviousValueObjectInterface::class],
|
||||
]]
|
||||
);
|
||||
$services->set(MoveValueObjectsToValueObjectDirectoryRector::class)->call(
|
||||
'configure',
|
||||
[[
|
||||
MoveValueObjectsToValueObjectDirectoryRector::TYPES => [ObviousValueObjectInterface::class],
|
||||
]]
|
||||
)->call('configure', [[
|
||||
MoveValueObjectsToValueObjectDirectoryRector::SUFFIXES => ['Search'],
|
||||
]]);
|
||||
$services->set(MoveValueObjectsToValueObjectDirectoryRector::class)->call(
|
||||
'configure',
|
||||
[[
|
||||
MoveValueObjectsToValueObjectDirectoryRector::TYPES => [ObviousValueObjectInterface::class],
|
||||
]]
|
||||
)->call('configure', [[
|
||||
MoveValueObjectsToValueObjectDirectoryRector::SUFFIXES => ['Search'],
|
||||
]])->call('configure', [[
|
||||
MoveValueObjectsToValueObjectDirectoryRector::ENABLE_VALUE_OBJECT_GUESSING => true,
|
||||
]]);
|
||||
};
|
|
@ -5,11 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\CakePHP\Tests\Rector\MethodCall\ArrayToFluentCallRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\CakePHP\Rector\MethodCall\ArrayToFluentCallRector;
|
||||
use Rector\CakePHP\Tests\Rector\MethodCall\ArrayToFluentCallRector\Source\ConfigurableClass;
|
||||
use Rector\CakePHP\Tests\Rector\MethodCall\ArrayToFluentCallRector\Source\FactoryClass;
|
||||
use Rector\CakePHP\ValueObject\ArrayToFluentCall;
|
||||
use Rector\CakePHP\ValueObject\FactoryMethod;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -28,23 +23,8 @@ final class ArrayToFluentCallRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
ArrayToFluentCallRector::class => [
|
||||
ArrayToFluentCallRector::ARRAYS_TO_FLUENT_CALLS => [
|
||||
new ArrayToFluentCall(ConfigurableClass::class, [
|
||||
'name' => 'setName',
|
||||
'size' => 'setSize',
|
||||
]),
|
||||
],
|
||||
ArrayToFluentCallRector::FACTORY_METHODS => [
|
||||
new FactoryMethod(FactoryClass::class, 'buildClass', ConfigurableClass::class, 2),
|
||||
],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
use Rector\CakePHP\Rector\MethodCall\ArrayToFluentCallRector;
|
||||
use Rector\CakePHP\Tests\Rector\MethodCall\ArrayToFluentCallRector\Source\ConfigurableClass;
|
||||
use Rector\CakePHP\Tests\Rector\MethodCall\ArrayToFluentCallRector\Source\FactoryClass;
|
||||
use Rector\CakePHP\ValueObject\ArrayToFluentCall;
|
||||
use Rector\CakePHP\ValueObject\FactoryMethod;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(ArrayToFluentCallRector::class)
|
||||
->call('configure', [[
|
||||
ArrayToFluentCallRector::ARRAYS_TO_FLUENT_CALLS => ValueObjectInliner::inline([
|
||||
new ArrayToFluentCall(ConfigurableClass::class, [
|
||||
'name' => 'setName',
|
||||
'size' => 'setSize',
|
||||
]),
|
||||
]),
|
||||
ArrayToFluentCallRector::FACTORY_METHODS => ValueObjectInliner::inline([
|
||||
new FactoryMethod(FactoryClass::class, 'buildClass', ConfigurableClass::class, 2),
|
||||
]),
|
||||
]]);
|
||||
};
|
|
@ -5,9 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\CakePHP\Tests\Rector\MethodCall\ModalToGetSetRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\CakePHP\Rector\MethodCall\ModalToGetSetRector;
|
||||
use Rector\CakePHP\Tests\Rector\MethodCall\ModalToGetSetRector\Source\SomeModelType;
|
||||
use Rector\CakePHP\ValueObject\ModalToGetSet;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -26,27 +23,8 @@ final class ModalToGetSetRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
ModalToGetSetRector::class => [
|
||||
ModalToGetSetRector::UNPREFIXED_METHODS_TO_GET_SET => [
|
||||
new ModalToGetSet(SomeModelType::class, 'config', null, null, 2, 'array'),
|
||||
new ModalToGetSet(
|
||||
SomeModelType::class,
|
||||
'customMethod',
|
||||
'customMethodGetName',
|
||||
'customMethodSetName',
|
||||
2,
|
||||
'array'
|
||||
),
|
||||
new ModalToGetSet(SomeModelType::class, 'makeEntity', 'createEntity', 'generateEntity'),
|
||||
new ModalToGetSet(SomeModelType::class, 'method'),
|
||||
],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
use Rector\CakePHP\Rector\MethodCall\ModalToGetSetRector;
|
||||
use Rector\CakePHP\Tests\Rector\MethodCall\ModalToGetSetRector\Source\SomeModelType;
|
||||
use Rector\CakePHP\ValueObject\ModalToGetSet;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(ModalToGetSetRector::class)->call('configure', [[
|
||||
ModalToGetSetRector::UNPREFIXED_METHODS_TO_GET_SET => ValueObjectInliner::inline([
|
||||
|
||||
new ModalToGetSet(SomeModelType::class, 'config', null, null, 2, 'array'),
|
||||
new ModalToGetSet(
|
||||
SomeModelType::class,
|
||||
'customMethod',
|
||||
'customMethodGetName',
|
||||
'customMethodSetName',
|
||||
2,
|
||||
'array'
|
||||
),
|
||||
new ModalToGetSet(SomeModelType::class, 'makeEntity', 'createEntity', 'generateEntity'),
|
||||
new ModalToGetSet(SomeModelType::class, 'method'),
|
||||
|
||||
]),
|
||||
]]);
|
||||
};
|
|
@ -5,9 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\CakePHP\Tests\Rector\MethodCall\RenameMethodCallBasedOnParameterRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\CakePHP\Rector\MethodCall\RenameMethodCallBasedOnParameterRector;
|
||||
use Rector\CakePHP\Tests\Rector\MethodCall\RenameMethodCallBasedOnParameterRector\Source\SomeModelType;
|
||||
use Rector\CakePHP\ValueObject\RenameMethodCallBasedOnParameter;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -29,18 +26,8 @@ final class RenameMethodCallBasedOnParameterRectorTest extends AbstractRectorTes
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
RenameMethodCallBasedOnParameterRector::class => [
|
||||
RenameMethodCallBasedOnParameterRector::CALLS_WITH_PARAM_RENAMES => [
|
||||
new RenameMethodCallBasedOnParameter(SomeModelType::class, 'getParam', 'paging', 'getAttribute'),
|
||||
new RenameMethodCallBasedOnParameter(SomeModelType::class, 'withParam', 'paging', 'withAttribute'),
|
||||
],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
use Rector\CakePHP\Rector\MethodCall\RenameMethodCallBasedOnParameterRector;
|
||||
use Rector\CakePHP\Tests\Rector\MethodCall\RenameMethodCallBasedOnParameterRector\Source\SomeModelType;
|
||||
use Rector\CakePHP\ValueObject\RenameMethodCallBasedOnParameter;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(RenameMethodCallBasedOnParameterRector::class)->call(
|
||||
'configure',
|
||||
[[
|
||||
RenameMethodCallBasedOnParameterRector::CALLS_WITH_PARAM_RENAMES => ValueObjectInliner::inline([
|
||||
|
||||
new RenameMethodCallBasedOnParameter(SomeModelType::class, 'getParam', 'paging', 'getAttribute'),
|
||||
new RenameMethodCallBasedOnParameter(SomeModelType::class, 'withParam', 'paging', 'withAttribute'),
|
||||
|
||||
]),
|
||||
]]
|
||||
);
|
||||
};
|
|
@ -5,11 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\CodingStyle\Tests\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector;
|
||||
|
||||
use Iterator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Rector\CodingStyle\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector;
|
||||
use Rector\CodingStyle\Tests\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector\Source\EventSubscriberInterface;
|
||||
use Rector\CodingStyle\Tests\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector\Source\ParentTestCase;
|
||||
use Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -28,20 +23,8 @@ final class ReturnArrayClassMethodToYieldRectorTest extends AbstractRectorTestCa
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
ReturnArrayClassMethodToYieldRector::class => [
|
||||
ReturnArrayClassMethodToYieldRector::METHODS_TO_YIELDS => [
|
||||
new ReturnArrayClassMethodToYield(EventSubscriberInterface::class, 'getSubscribedEvents'),
|
||||
new ReturnArrayClassMethodToYield(ParentTestCase::class, 'provide*'),
|
||||
new ReturnArrayClassMethodToYield(ParentTestCase::class, 'dataProvider*'),
|
||||
new ReturnArrayClassMethodToYield(TestCase::class, 'provideData'),
|
||||
],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Rector\CodingStyle\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector;
|
||||
use Rector\CodingStyle\Tests\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector\Source\EventSubscriberInterface;
|
||||
use Rector\CodingStyle\Tests\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector\Source\ParentTestCase;
|
||||
use Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(ReturnArrayClassMethodToYieldRector::class)->call(
|
||||
'configure',
|
||||
[[
|
||||
ReturnArrayClassMethodToYieldRector::METHODS_TO_YIELDS => ValueObjectInliner::inline([
|
||||
|
||||
new ReturnArrayClassMethodToYield(EventSubscriberInterface::class, 'getSubscribedEvents'),
|
||||
new ReturnArrayClassMethodToYield(ParentTestCase::class, 'provide*'),
|
||||
new ReturnArrayClassMethodToYield(ParentTestCase::class, 'dataProvider*'),
|
||||
new ReturnArrayClassMethodToYield(TestCase::class, 'provideData'),
|
||||
|
||||
]),
|
||||
]]
|
||||
);
|
||||
};
|
|
@ -5,8 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\CodingStyle\Tests\Rector\ClassMethod\YieldClassMethodToArrayClassMethodRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\CodingStyle\Rector\ClassMethod\YieldClassMethodToArrayClassMethodRector;
|
||||
use Rector\CodingStyle\Tests\Rector\ClassMethod\YieldClassMethodToArrayClassMethodRector\Source\EventSubscriberInterface;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -25,17 +23,8 @@ final class YieldClassMethodToArrayClassMethodRectorTest extends AbstractRectorT
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
YieldClassMethodToArrayClassMethodRector::class => [
|
||||
YieldClassMethodToArrayClassMethodRector::METHODS_BY_TYPE => [
|
||||
EventSubscriberInterface::class => ['getSubscribedEvents'],
|
||||
],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
use Rector\CodingStyle\Rector\ClassMethod\YieldClassMethodToArrayClassMethodRector;
|
||||
use Rector\CodingStyle\Tests\Rector\ClassMethod\YieldClassMethodToArrayClassMethodRector\Source\EventSubscriberInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(YieldClassMethodToArrayClassMethodRector::class)->call(
|
||||
'configure',
|
||||
[[
|
||||
YieldClassMethodToArrayClassMethodRector::METHODS_BY_TYPE => [
|
||||
EventSubscriberInterface::class => ['getSubscribedEvents'],
|
||||
],
|
||||
]]
|
||||
);
|
||||
};
|
|
@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\CodingStyle\Tests\Rector\FuncCall\FunctionCallToConstantRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\CodingStyle\Rector\FuncCall\FunctionCallToConstantRector;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -24,18 +23,8 @@ final class FunctionCallToConstantRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
FunctionCallToConstantRector::class => [
|
||||
FunctionCallToConstantRector::FUNCTIONS_TO_CONSTANTS => [
|
||||
'php_sapi_name' => 'PHP_SAPI',
|
||||
'pi' => 'M_PI',
|
||||
],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
use Rector\CodingStyle\Rector\FuncCall\FunctionCallToConstantRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(FunctionCallToConstantRector::class)->call('configure', [[
|
||||
FunctionCallToConstantRector::FUNCTIONS_TO_CONSTANTS => [
|
||||
'php_sapi_name' => 'PHP_SAPI',
|
||||
'pi' => 'M_PI',
|
||||
],
|
||||
]]);
|
||||
};
|
|
@ -5,10 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector;
|
||||
|
||||
use Iterator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Rector\CodingStyle\Rector\MethodCall\PreferThisOrSelfMethodCallRector;
|
||||
use Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source\AbstractTestCase;
|
||||
use Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source\BeLocalClass;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -27,19 +23,8 @@ final class PreferThisOrSelfMethodCallRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
PreferThisOrSelfMethodCallRector::class => [
|
||||
PreferThisOrSelfMethodCallRector::TYPE_TO_PREFERENCE => [
|
||||
AbstractTestCase::class => 'self',
|
||||
BeLocalClass::class => 'this',
|
||||
TestCase::class => 'self',
|
||||
],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Rector\CodingStyle\Rector\MethodCall\PreferThisOrSelfMethodCallRector;
|
||||
use Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source\AbstractTestCase;
|
||||
use Rector\CodingStyle\Tests\Rector\MethodCall\PreferThisOrSelfMethodCallRector\Source\BeLocalClass;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(PreferThisOrSelfMethodCallRector::class)->call('configure', [[
|
||||
PreferThisOrSelfMethodCallRector::TYPE_TO_PREFERENCE => [
|
||||
AbstractTestCase::class => 'self',
|
||||
BeLocalClass::class => 'this',
|
||||
TestCase::class => 'self',
|
||||
],
|
||||
]]);
|
||||
};
|
|
@ -5,8 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\DeadDocBlock\Tests\Rector\ClassLike\RemoveAnnotationRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\BetterPhpDocParser\ValueObject\PhpDocNode\JMS\JMSInjectParamsTagValueNode;
|
||||
use Rector\DeadDocBlock\Rector\ClassLike\RemoveAnnotationRector;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -25,15 +23,8 @@ final class RemoveAnnotationRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
RemoveAnnotationRector::class => [
|
||||
RemoveAnnotationRector::ANNOTATIONS_TO_REMOVE => ['method', JMSInjectParamsTagValueNode::class],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
use Rector\BetterPhpDocParser\ValueObject\PhpDocNode\JMS\JMSInjectParamsTagValueNode;
|
||||
use Rector\DeadDocBlock\Rector\ClassLike\RemoveAnnotationRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(RemoveAnnotationRector::class)->call('configure', [[
|
||||
RemoveAnnotationRector::ANNOTATIONS_TO_REMOVE => ['method', JMSInjectParamsTagValueNode::class],
|
||||
]]);
|
||||
};
|
|
@ -5,8 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\DependencyInjection\Tests\Rector\Class_\MultiParentingToAbstractDependencyRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Core\ValueObject\FrameworkName;
|
||||
use Rector\DependencyInjection\Rector\Class_\MultiParentingToAbstractDependencyRector;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -25,15 +23,8 @@ final class MultiParentingToAbstractDependencyRectorTest extends AbstractRectorT
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
MultiParentingToAbstractDependencyRector::class => [
|
||||
MultiParentingToAbstractDependencyRector::FRAMEWORK => FrameworkName::NETTE,
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/nette_config.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\DependencyInjection\Tests\Rector\Class_\MultiParentingToAbstractDependencyRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Core\ValueObject\FrameworkName;
|
||||
use Rector\DependencyInjection\Rector\Class_\MultiParentingToAbstractDependencyRector;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -25,15 +23,8 @@ final class SymfonyMultiParentingToAbstractDependencyRectorTest extends Abstract
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/FixtureSymfony');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
MultiParentingToAbstractDependencyRector::class => [
|
||||
MultiParentingToAbstractDependencyRector::FRAMEWORK => FrameworkName::SYMFONY,
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/symfony_config.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Core\ValueObject\FrameworkName;
|
||||
use Rector\DependencyInjection\Rector\Class_\MultiParentingToAbstractDependencyRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
|
||||
$services->set(MultiParentingToAbstractDependencyRector::class)
|
||||
->call('configure', [[
|
||||
MultiParentingToAbstractDependencyRector::FRAMEWORK => FrameworkName::NETTE,
|
||||
]]);
|
||||
};
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Core\ValueObject\FrameworkName;
|
||||
use Rector\DependencyInjection\Rector\Class_\MultiParentingToAbstractDependencyRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
|
||||
$services->set(MultiParentingToAbstractDependencyRector::class)
|
||||
->call('configure', [[
|
||||
MultiParentingToAbstractDependencyRector::FRAMEWORK => FrameworkName::SYMFONY,
|
||||
]]);
|
||||
};
|
|
@ -5,9 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\DoctrineCodeQuality\Tests\Rector\DoctrineRepositoryAsService;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Doctrine\Rector\Class_\RemoveRepositoryFromEntityAnnotationRector;
|
||||
use Rector\Doctrine\Rector\MethodCall\ReplaceParentRepositoryCallsByRepositoryPropertyRector;
|
||||
use Rector\DoctrineCodeQuality\Rector\Class_\MoveRepositoryFromParentToConstructorRector;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -31,16 +28,8 @@ final class DoctrineRepositoryAsServiceTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
# order matters, this needs to be first to correctly detect parent repository
|
||||
MoveRepositoryFromParentToConstructorRector::class => [],
|
||||
ReplaceParentRepositoryCallsByRepositoryPropertyRector::class => [],
|
||||
RemoveRepositoryFromEntityAnnotationRector::class => [],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
use Rector\Doctrine\Rector\Class_\RemoveRepositoryFromEntityAnnotationRector;
|
||||
use Rector\Doctrine\Rector\MethodCall\ReplaceParentRepositoryCallsByRepositoryPropertyRector;
|
||||
use Rector\DoctrineCodeQuality\Rector\Class_\MoveRepositoryFromParentToConstructorRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(
|
||||
# order matters, this needs to be first to correctly detect parent repository
|
||||
MoveRepositoryFromParentToConstructorRector::class
|
||||
);
|
||||
$services->set(ReplaceParentRepositoryCallsByRepositoryPropertyRector::class);
|
||||
$services->set(RemoveRepositoryFromEntityAnnotationRector::class);
|
||||
};
|
|
@ -5,8 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\Doctrine\Tests\Rector\Class_\AddEntityIdByConditionRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Doctrine\Rector\Class_\AddEntityIdByConditionRector;
|
||||
use Rector\Doctrine\Tests\Rector\Class_\AddEntityIdByConditionRector\Source\SomeTrait;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -25,15 +23,8 @@ final class AddEntityIdByConditionRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
AddEntityIdByConditionRector::class => [
|
||||
AddEntityIdByConditionRector::DETECTED_TRAITS => [SomeTrait::class],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
use Rector\Doctrine\Rector\Class_\AddEntityIdByConditionRector;
|
||||
use Rector\Doctrine\Tests\Rector\Class_\AddEntityIdByConditionRector\Source\SomeTrait;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(AddEntityIdByConditionRector::class)->call('configure', [[
|
||||
AddEntityIdByConditionRector::DETECTED_TRAITS => [SomeTrait::class],
|
||||
]]);
|
||||
};
|
|
@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\Doctrine\Tests\Rector\MethodCall\EntityAliasToClassConstantReferenceRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Doctrine\Rector\MethodCall\EntityAliasToClassConstantReferenceRector;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -24,17 +23,8 @@ final class EntityAliasToClassConstantReferenceRectorTest extends AbstractRector
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
EntityAliasToClassConstantReferenceRector::class => [
|
||||
EntityAliasToClassConstantReferenceRector::ALIASES_TO_NAMESPACES => [
|
||||
'App' => 'App\Entity',
|
||||
],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
use Rector\Doctrine\Rector\MethodCall\EntityAliasToClassConstantReferenceRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(EntityAliasToClassConstantReferenceRector::class)->call(
|
||||
'configure',
|
||||
[[
|
||||
EntityAliasToClassConstantReferenceRector::ALIASES_TO_NAMESPACES => [
|
||||
'App' => 'App\Entity',
|
||||
],
|
||||
]]
|
||||
);
|
||||
};
|
|
@ -5,8 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\Generic\Tests\Rector\ClassMethod\AddMethodParentCallRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Generic\Rector\ClassMethod\AddMethodParentCallRector;
|
||||
use Rector\Generic\Tests\Rector\ClassMethod\AddMethodParentCallRector\Source\ParentClassWithNewConstructor;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -25,17 +23,8 @@ final class AddMethodParentCallRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
AddMethodParentCallRector::class => [
|
||||
AddMethodParentCallRector::METHODS_BY_PARENT_TYPES => [
|
||||
ParentClassWithNewConstructor::class => '__construct',
|
||||
],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
use Rector\Generic\Rector\ClassMethod\AddMethodParentCallRector;
|
||||
use Rector\Generic\Tests\Rector\ClassMethod\AddMethodParentCallRector\Source\ParentClassWithNewConstructor;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(AddMethodParentCallRector::class)->call('configure', [[
|
||||
AddMethodParentCallRector::METHODS_BY_PARENT_TYPES => [
|
||||
ParentClassWithNewConstructor::class => '__construct',
|
||||
],
|
||||
]]);
|
||||
};
|
|
@ -5,11 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\Generic\Tests\Rector\ClassMethod\ArgumentAdderRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Generic\NodeAnalyzer\ArgumentAddingScope;
|
||||
use Rector\Generic\Rector\ClassMethod\ArgumentAdderRector;
|
||||
use Rector\Generic\Tests\Rector\ClassMethod\ArgumentAdderRector\Source\SomeContainerBuilder;
|
||||
use Rector\Generic\Tests\Rector\ClassMethod\ArgumentAdderRector\Source\SomeParentClient;
|
||||
use Rector\Generic\ValueObject\ArgumentAdder;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -28,48 +23,8 @@ final class ArgumentAdderRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
ArgumentAdderRector::class => [
|
||||
ArgumentAdderRector::ADDED_ARGUMENTS => [
|
||||
// covers https://github.com/rectorphp/rector/issues/4267
|
||||
new ArgumentAdder(
|
||||
SomeContainerBuilder::class,
|
||||
'sendResetLinkResponse',
|
||||
0,
|
||||
'request',
|
||||
null,
|
||||
'Illuminate\Http\Illuminate\Http'
|
||||
),
|
||||
|
||||
new ArgumentAdder(SomeContainerBuilder::class, 'compile', 0, 'isCompiled', false),
|
||||
new ArgumentAdder(SomeContainerBuilder::class, 'addCompilerPass', 2, 'priority', 0, 'int'),
|
||||
|
||||
// scoped
|
||||
new ArgumentAdder(
|
||||
SomeParentClient::class,
|
||||
'submit',
|
||||
2,
|
||||
'serverParameters',
|
||||
[],
|
||||
'array',
|
||||
ArgumentAddingScope::SCOPE_PARENT_CALL
|
||||
),
|
||||
new ArgumentAdder(
|
||||
SomeParentClient::class,
|
||||
'submit',
|
||||
2,
|
||||
'serverParameters',
|
||||
[],
|
||||
'array',
|
||||
ArgumentAddingScope::SCOPE_CLASS_METHOD
|
||||
),
|
||||
],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
use Rector\Generic\NodeAnalyzer\ArgumentAddingScope;
|
||||
use Rector\Generic\Rector\ClassMethod\ArgumentAdderRector;
|
||||
use Rector\Generic\Tests\Rector\ClassMethod\ArgumentAdderRector\Source\SomeContainerBuilder;
|
||||
use Rector\Generic\Tests\Rector\ClassMethod\ArgumentAdderRector\Source\SomeParentClient;
|
||||
use Rector\Generic\ValueObject\ArgumentAdder;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(ArgumentAdderRector::class)->call('configure', [[
|
||||
ArgumentAdderRector::ADDED_ARGUMENTS => ValueObjectInliner::inline([
|
||||
// covers https://github.com/rectorphp/rector/issues/4267
|
||||
new ArgumentAdder(
|
||||
SomeContainerBuilder::class,
|
||||
'sendResetLinkResponse',
|
||||
0,
|
||||
'request',
|
||||
null,
|
||||
'Illuminate\Http\Illuminate\Http'
|
||||
),
|
||||
new ArgumentAdder(SomeContainerBuilder::class, 'compile', 0, 'isCompiled', false),
|
||||
new ArgumentAdder(SomeContainerBuilder::class, 'addCompilerPass', 2, 'priority', 0, 'int'),
|
||||
// scoped
|
||||
new ArgumentAdder(
|
||||
SomeParentClient::class,
|
||||
'submit',
|
||||
2,
|
||||
'serverParameters',
|
||||
[],
|
||||
'array',
|
||||
ArgumentAddingScope::SCOPE_PARENT_CALL
|
||||
),
|
||||
new ArgumentAdder(
|
||||
SomeParentClient::class,
|
||||
'submit',
|
||||
2,
|
||||
'serverParameters',
|
||||
[],
|
||||
'array',
|
||||
ArgumentAddingScope::SCOPE_CLASS_METHOD
|
||||
),
|
||||
]),
|
||||
]]);
|
||||
};
|
|
@ -5,8 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\Generic\Tests\Rector\ClassMethod\ArgumentDefaultValueReplacerRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Generic\Rector\ClassMethod\ArgumentDefaultValueReplacerRector;
|
||||
use Rector\Generic\ValueObject\ArgumentDefaultValueReplacer;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -25,53 +23,8 @@ final class ArgumentDefaultValueReplacerRectorTest extends AbstractRectorTestCas
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
ArgumentDefaultValueReplacerRector::class => [
|
||||
ArgumentDefaultValueReplacerRector::REPLACED_ARGUMENTS => [
|
||||
new ArgumentDefaultValueReplacer(
|
||||
'Symfony\Component\DependencyInjection\Definition',
|
||||
'setScope',
|
||||
0,
|
||||
'Symfony\Component\DependencyInjection\ContainerBuilder::SCOPE_PROTOTYPE',
|
||||
false
|
||||
),
|
||||
|
||||
new ArgumentDefaultValueReplacer('Symfony\Component\Yaml\Yaml', 'parse', 1, [
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
], 'Symfony\Component\Yaml\Yaml::PARSE_OBJECT_FOR_MAP'),
|
||||
|
||||
new ArgumentDefaultValueReplacer('Symfony\Component\Yaml\Yaml', 'parse', 1, [
|
||||
false,
|
||||
true,
|
||||
], 'Symfony\Component\Yaml\Yaml::PARSE_OBJECT'),
|
||||
new ArgumentDefaultValueReplacer('Symfony\Component\Yaml\Yaml', 'parse', 1, false, 0),
|
||||
new ArgumentDefaultValueReplacer(
|
||||
'Symfony\Component\Yaml\Yaml',
|
||||
'parse',
|
||||
1,
|
||||
true,
|
||||
'Symfony\Component\Yaml\Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE'
|
||||
),
|
||||
new ArgumentDefaultValueReplacer('Symfony\Component\Yaml\Yaml', 'dump', 3, [
|
||||
false,
|
||||
true,
|
||||
], 'Symfony\Component\Yaml\Yaml::DUMP_OBJECT'),
|
||||
new ArgumentDefaultValueReplacer(
|
||||
'Symfony\Component\Yaml\Yaml',
|
||||
'dump',
|
||||
3,
|
||||
true,
|
||||
'Symfony\Component\Yaml\Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE'
|
||||
),
|
||||
],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
use Rector\Generic\Rector\ClassMethod\ArgumentDefaultValueReplacerRector;
|
||||
use Rector\Generic\ValueObject\ArgumentDefaultValueReplacer;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(ArgumentDefaultValueReplacerRector::class)->call('configure', [[
|
||||
ArgumentDefaultValueReplacerRector::REPLACED_ARGUMENTS => ValueObjectInliner::inline([
|
||||
|
||||
new ArgumentDefaultValueReplacer(
|
||||
'Symfony\Component\DependencyInjection\Definition',
|
||||
'setScope',
|
||||
0,
|
||||
'Symfony\Component\DependencyInjection\ContainerBuilder::SCOPE_PROTOTYPE',
|
||||
false
|
||||
),
|
||||
new ArgumentDefaultValueReplacer('Symfony\Component\Yaml\Yaml', 'parse', 1, [
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
], 'Symfony\Component\Yaml\Yaml::PARSE_OBJECT_FOR_MAP'),
|
||||
new ArgumentDefaultValueReplacer('Symfony\Component\Yaml\Yaml', 'parse', 1, [
|
||||
false,
|
||||
true,
|
||||
], 'Symfony\Component\Yaml\Yaml::PARSE_OBJECT'),
|
||||
new ArgumentDefaultValueReplacer('Symfony\Component\Yaml\Yaml', 'parse', 1, false, 0),
|
||||
new ArgumentDefaultValueReplacer(
|
||||
'Symfony\Component\Yaml\Yaml',
|
||||
'parse',
|
||||
1,
|
||||
true,
|
||||
'Symfony\Component\Yaml\Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE'
|
||||
),
|
||||
new ArgumentDefaultValueReplacer('Symfony\Component\Yaml\Yaml', 'dump', 3, [
|
||||
false,
|
||||
true,
|
||||
], 'Symfony\Component\Yaml\Yaml::DUMP_OBJECT'),
|
||||
new ArgumentDefaultValueReplacer(
|
||||
'Symfony\Component\Yaml\Yaml',
|
||||
'dump',
|
||||
3,
|
||||
true,
|
||||
'Symfony\Component\Yaml\Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE'
|
||||
),
|
||||
|
||||
]),
|
||||
]]);
|
||||
};
|
|
@ -5,9 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\Generic\Tests\Rector\ClassMethod\NormalToFluentRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Generic\Rector\ClassMethod\NormalToFluentRector;
|
||||
use Rector\Generic\Tests\Rector\ClassMethod\NormalToFluentRector\Source\FluentInterfaceClass;
|
||||
use Rector\Generic\ValueObject\NormalToFluent;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -26,21 +23,8 @@ final class NormalToFluentRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
NormalToFluentRector::class => [
|
||||
NormalToFluentRector::CALLS_TO_FLUENT => [
|
||||
new NormalToFluent(FluentInterfaceClass::class, [
|
||||
'someFunction',
|
||||
'otherFunction',
|
||||
'joinThisAsWell',
|
||||
]),
|
||||
],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
use Rector\Generic\Rector\ClassMethod\NormalToFluentRector;
|
||||
use Rector\Generic\Tests\Rector\ClassMethod\NormalToFluentRector\Source\FluentInterfaceClass;
|
||||
use Rector\Generic\ValueObject\NormalToFluent;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(NormalToFluentRector::class)->call('configure', [[
|
||||
NormalToFluentRector::CALLS_TO_FLUENT => ValueObjectInliner::inline([
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
new NormalToFluent(
|
||||
FluentInterfaceClass::class,
|
||||
['someFunction', 'otherFunction', 'joinThisAsWell']),
|
||||
]
|
||||
),
|
||||
]]);
|
||||
};
|
|
@ -5,9 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\Generic\Tests\Rector\ClassMethod\SingleToManyMethodRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Generic\Rector\ClassMethod\SingleToManyMethodRector;
|
||||
use Rector\Generic\Tests\Rector\ClassMethod\SingleToManyMethodRector\Source\OneToManyInterface;
|
||||
use Rector\Generic\ValueObject\SingleToManyMethod;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -26,17 +23,8 @@ final class SingleToManyMethodRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
SingleToManyMethodRector::class => [
|
||||
SingleToManyMethodRector::SINGLES_TO_MANY_METHODS => [
|
||||
new SingleToManyMethod(OneToManyInterface::class, 'getNode', 'getNodes'),
|
||||
],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
use Rector\Generic\Rector\ClassMethod\SingleToManyMethodRector;
|
||||
use Rector\Generic\Tests\Rector\ClassMethod\SingleToManyMethodRector\Source\OneToManyInterface;
|
||||
use Rector\Generic\ValueObject\SingleToManyMethod;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(SingleToManyMethodRector::class)->call('configure', [[
|
||||
SingleToManyMethodRector::SINGLES_TO_MANY_METHODS => ValueObjectInliner::inline([
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
new SingleToManyMethod(OneToManyInterface::class, 'getNode', 'getNodes'),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
]),
|
||||
]]);
|
||||
};
|
|
@ -5,9 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\Generic\Tests\Rector\ClassMethod\WrapReturnRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Generic\Rector\ClassMethod\WrapReturnRector;
|
||||
use Rector\Generic\Tests\Rector\ClassMethod\WrapReturnRector\Source\SomeReturnClass;
|
||||
use Rector\Generic\ValueObject\WrapReturn;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -26,15 +23,8 @@ final class WrapReturnRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
WrapReturnRector::class => [
|
||||
WrapReturnRector::TYPE_METHOD_WRAPS => [new WrapReturn(SomeReturnClass::class, 'getItem', true)],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
use Rector\Generic\Rector\ClassMethod\WrapReturnRector;
|
||||
use Rector\Generic\Tests\Rector\ClassMethod\WrapReturnRector\Source\SomeReturnClass;
|
||||
use Rector\Generic\ValueObject\WrapReturn;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(WrapReturnRector::class)->call('configure', [[
|
||||
WrapReturnRector::TYPE_METHOD_WRAPS => ValueObjectInliner::inline([
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
new WrapReturn(SomeReturnClass::class, 'getItem', true),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
]),
|
||||
]]);
|
||||
};
|
|
@ -5,9 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\Generic\Tests\Rector\Class_\AddInterfaceByTraitRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Generic\Rector\Class_\AddInterfaceByTraitRector;
|
||||
use Rector\Generic\Tests\Rector\Class_\AddInterfaceByTraitRector\Source\SomeInterface;
|
||||
use Rector\Generic\Tests\Rector\Class_\AddInterfaceByTraitRector\Source\SomeTrait;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -26,17 +23,8 @@ final class AddInterfaceByTraitRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
AddInterfaceByTraitRector::class => [
|
||||
AddInterfaceByTraitRector::INTERFACE_BY_TRAIT => [
|
||||
SomeTrait::class => SomeInterface::class,
|
||||
],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
use Rector\Generic\Rector\Class_\AddInterfaceByTraitRector;
|
||||
use Rector\Generic\Tests\Rector\Class_\AddInterfaceByTraitRector\Source\SomeInterface;
|
||||
use Rector\Generic\Tests\Rector\Class_\AddInterfaceByTraitRector\Source\SomeTrait;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(AddInterfaceByTraitRector::class)->call('configure', [[
|
||||
AddInterfaceByTraitRector::INTERFACE_BY_TRAIT => [
|
||||
SomeTrait::class => SomeInterface::class,
|
||||
],
|
||||
]]);
|
||||
};
|
|
@ -5,9 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\Generic\Tests\Rector\Class_\AddPropertyByParentRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Generic\Rector\Class_\AddPropertyByParentRector;
|
||||
use Rector\Generic\Tests\Rector\Class_\AddPropertyByParentRector\Source\SomeParentClassToAddDependencyBy;
|
||||
use Rector\Generic\ValueObject\AddPropertyByParent;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -26,17 +23,8 @@ final class AddPropertyByParentRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
AddPropertyByParentRector::class => [
|
||||
AddPropertyByParentRector::PARENT_DEPENDENCIES => [
|
||||
new AddPropertyByParent(SomeParentClassToAddDependencyBy::class, 'SomeDependency'),
|
||||
],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
use Rector\Generic\Rector\Class_\AddPropertyByParentRector;
|
||||
use Rector\Generic\Tests\Rector\Class_\AddPropertyByParentRector\Source\SomeParentClassToAddDependencyBy;
|
||||
use Rector\Generic\ValueObject\AddPropertyByParent;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(AddPropertyByParentRector::class)->call('configure', [[
|
||||
AddPropertyByParentRector::PARENT_DEPENDENCIES => ValueObjectInliner::inline([
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
new AddPropertyByParent(
|
||||
SomeParentClassToAddDependencyBy::class,
|
||||
'SomeDependency'
|
||||
),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
]),
|
||||
]]);
|
||||
};
|
|
@ -5,9 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\Generic\Tests\Rector\Class_\MergeInterfacesRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Generic\Rector\Class_\MergeInterfacesRector;
|
||||
use Rector\Generic\Tests\Rector\Class_\MergeInterfacesRector\Source\SomeInterface;
|
||||
use Rector\Generic\Tests\Rector\Class_\MergeInterfacesRector\Source\SomeOldInterface;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -26,17 +23,8 @@ final class MergeInterfacesRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
MergeInterfacesRector::class => [
|
||||
MergeInterfacesRector::OLD_TO_NEW_INTERFACES => [
|
||||
SomeOldInterface::class => SomeInterface::class,
|
||||
],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
use Rector\Generic\Rector\Class_\MergeInterfacesRector;
|
||||
use Rector\Generic\Tests\Rector\Class_\MergeInterfacesRector\Source\SomeInterface;
|
||||
use Rector\Generic\Tests\Rector\Class_\MergeInterfacesRector\Source\SomeOldInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(MergeInterfacesRector::class)->call('configure', [[
|
||||
MergeInterfacesRector::OLD_TO_NEW_INTERFACES => [
|
||||
SomeOldInterface::class => SomeInterface::class,
|
||||
],
|
||||
]]);
|
||||
};
|
|
@ -5,8 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\Generic\Tests\Rector\FuncCall\SwapFuncCallArgumentsRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Generic\Rector\FuncCall\SwapFuncCallArgumentsRector;
|
||||
use Rector\Generic\ValueObject\SwapFuncCallArguments;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -25,17 +23,8 @@ final class SwapFuncCallArgumentsRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
SwapFuncCallArgumentsRector::class => [
|
||||
SwapFuncCallArgumentsRector::FUNCTION_ARGUMENT_SWAPS => [
|
||||
new SwapFuncCallArguments('some_function', [1, 0]),
|
||||
],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
use Rector\Generic\Rector\FuncCall\SwapFuncCallArgumentsRector;
|
||||
use Rector\Generic\ValueObject\SwapFuncCallArguments;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(SwapFuncCallArgumentsRector::class)->call('configure', [[
|
||||
SwapFuncCallArgumentsRector::FUNCTION_ARGUMENT_SWAPS => ValueObjectInliner::inline([
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
new SwapFuncCallArguments('some_function', [1, 0]),
|
||||
]
|
||||
),
|
||||
]]);
|
||||
};
|
|
@ -4,11 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Rector\Generic\Tests\Rector\Property\InjectAnnotationClassRector;
|
||||
|
||||
use DI\Annotation\Inject as PHPDIInject;
|
||||
use Iterator;
|
||||
use JMS\DiExtraBundle\Annotation\Inject;
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Generic\Rector\Property\InjectAnnotationClassRector;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -32,15 +29,8 @@ final class InjectAnnotationClassRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
InjectAnnotationClassRector::class => [
|
||||
InjectAnnotationClassRector::ANNOTATION_CLASSES => [Inject::class, PHPDIInject::class],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
use JMS\DiExtraBundle\Annotation\Inject;
|
||||
use Rector\Generic\Rector\Property\InjectAnnotationClassRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(InjectAnnotationClassRector::class)->call('configure', [[
|
||||
InjectAnnotationClassRector::ANNOTATION_CLASSES => [Inject::class, \DI\Annotation\Inject::class],
|
||||
]]);
|
||||
};
|
|
@ -5,9 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\Generic\Tests\Rector\RectorOrder;
|
||||
|
||||
use Iterator;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertComparisonToSpecificMethodRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertFalseStrposToContainsRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertSameBoolNullToSpecificMethodRector;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -29,16 +26,8 @@ final class RectorOrderTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
// order matters
|
||||
return [
|
||||
AssertComparisonToSpecificMethodRector::class => [],
|
||||
AssertSameBoolNullToSpecificMethodRector::class => [],
|
||||
AssertFalseStrposToContainsRector::class => [],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertComparisonToSpecificMethodRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertFalseStrposToContainsRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertSameBoolNullToSpecificMethodRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(AssertComparisonToSpecificMethodRector::class);
|
||||
$services->set(AssertSameBoolNullToSpecificMethodRector::class);
|
||||
$services->set(AssertFalseStrposToContainsRector::class);
|
||||
};
|
|
@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\Legacy\Tests\Rector\FileWithoutNamespace\AddTopIncludeRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Legacy\Rector\FileWithoutNamespace\AddTopIncludeRector;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -24,15 +23,8 @@ final class AddTopIncludeRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
AddTopIncludeRector::class => [
|
||||
AddTopIncludeRector::AUTOLOAD_FILE_PATH => '/../autoloader.php',
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
use Rector\Legacy\Rector\FileWithoutNamespace\AddTopIncludeRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(AddTopIncludeRector::class)->call('configure', [[
|
||||
AddTopIncludeRector::AUTOLOAD_FILE_PATH => '/../autoloader.php',
|
||||
]]);
|
||||
};
|
|
@ -5,8 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\NetteTesterToPHPUnit\Tests\Rector\Class_\NetteTesterClassToPHPUnitClassRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\NetteTesterToPHPUnit\Rector\Class_\NetteTesterClassToPHPUnitClassRector;
|
||||
use Rector\NetteTesterToPHPUnit\Rector\StaticCall\NetteAssertToPHPUnitAssertRector;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -25,14 +23,8 @@ final class NetteTesterPHPUnitRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
NetteAssertToPHPUnitAssertRector::class => [],
|
||||
NetteTesterClassToPHPUnitClassRector::class => [],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
use Rector\NetteTesterToPHPUnit\Rector\Class_\NetteTesterClassToPHPUnitClassRector;
|
||||
use Rector\NetteTesterToPHPUnit\Rector\StaticCall\NetteAssertToPHPUnitAssertRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(NetteAssertToPHPUnitAssertRector::class);
|
||||
$services->set(NetteTesterClassToPHPUnitClassRector::class);
|
||||
};
|
|
@ -5,12 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\PhpSpecToPHPUnit\Tests\Rector\Variable\PhpSpecToPHPUnitRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\Class_\AddMockPropertiesRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\Class_\PhpSpecClassToPHPUnitClassRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\ClassMethod\PhpSpecMethodToPHPUnitMethodRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\MethodCall\PhpSpecMocksToPHPUnitMocksRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\MethodCall\PhpSpecPromisesToPHPUnitAssertRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\Variable\MockVariableToPropertyFetchRector;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -29,19 +23,8 @@ final class PhpSpecToPHPUnitRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
# 1. first convert mocks
|
||||
PhpSpecMocksToPHPUnitMocksRector::class => [],
|
||||
PhpSpecPromisesToPHPUnitAssertRector::class => [],
|
||||
PhpSpecMethodToPHPUnitMethodRector::class => [],
|
||||
PhpSpecClassToPHPUnitClassRector::class => [],
|
||||
AddMockPropertiesRector::class => [],
|
||||
MockVariableToPropertyFetchRector::class => [],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
use Rector\PhpSpecToPHPUnit\Rector\Class_\AddMockPropertiesRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\Class_\PhpSpecClassToPHPUnitClassRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\ClassMethod\PhpSpecMethodToPHPUnitMethodRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\MethodCall\PhpSpecMocksToPHPUnitMocksRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\MethodCall\PhpSpecPromisesToPHPUnitAssertRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\Variable\MockVariableToPropertyFetchRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(
|
||||
# 1. first convert mocks
|
||||
PhpSpecMocksToPHPUnitMocksRector::class
|
||||
);
|
||||
$services->set(PhpSpecPromisesToPHPUnitAssertRector::class);
|
||||
$services->set(PhpSpecMethodToPHPUnitMethodRector::class);
|
||||
$services->set(PhpSpecClassToPHPUnitClassRector::class);
|
||||
$services->set(AddMockPropertiesRector::class);
|
||||
$services->set(MockVariableToPropertyFetchRector::class);
|
||||
};
|
|
@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\Php71\Tests\Rector\Name\ReservedObjectRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Php71\Rector\Name\ReservedObjectRector;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -24,18 +23,8 @@ final class ReservedObjectRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
ReservedObjectRector::class => [
|
||||
ReservedObjectRector::RESERVED_KEYWORDS_TO_REPLACEMENTS => [
|
||||
'ReservedObject' => 'SmartObject',
|
||||
'Object' => 'AnotherSmartObject',
|
||||
],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
use Rector\Php71\Rector\Name\ReservedObjectRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(ReservedObjectRector::class)->call('configure', [[
|
||||
ReservedObjectRector::RESERVED_KEYWORDS_TO_REPLACEMENTS => [
|
||||
'ReservedObject' => 'SmartObject',
|
||||
'Object' => 'AnotherSmartObject',
|
||||
],
|
||||
]]);
|
||||
};
|
|
@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\Php74\Tests\Rector\Function_\ReservedFnFunctionRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Php74\Rector\Function_\ReservedFnFunctionRector;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -24,18 +23,8 @@ final class ReservedFnFunctionRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
ReservedFnFunctionRector::class => [
|
||||
ReservedFnFunctionRector::RESERVED_NAMES_TO_NEW_ONES => [
|
||||
// for testing purposes of "fn" even on PHP 7.3-
|
||||
'reservedFn' => 'f',
|
||||
],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
use Rector\Php74\Rector\Function_\ReservedFnFunctionRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(ReservedFnFunctionRector::class)->call('configure', [[
|
||||
ReservedFnFunctionRector::RESERVED_NAMES_TO_NEW_ONES => [
|
||||
// for testing purposes of "fn" even on PHP 7.3-
|
||||
'reservedFn' => 'f',
|
||||
],
|
||||
]]);
|
||||
};
|
|
@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\Php74\Tests\Rector\LNumber\AddLiteralSeparatorToNumberRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -24,15 +23,8 @@ final class AddLiteralSeparatorToNumberRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
AddLiteralSeparatorToNumberRector::class => [
|
||||
AddLiteralSeparatorToNumberRector::LIMIT_VALUE => 1000000,
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
use Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(AddLiteralSeparatorToNumberRector::class)->call('configure', [[
|
||||
AddLiteralSeparatorToNumberRector::LIMIT_VALUE => 1000000,
|
||||
]]);
|
||||
};
|
|
@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\Php74\Tests\Rector\Property\TypedPropertyRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Php74\Rector\Property\TypedPropertyRector;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -24,15 +23,8 @@ final class ClassLikeTypesOnlyTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/FixtureClassLikeTypeOnly');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
TypedPropertyRector::class => [
|
||||
TypedPropertyRector::CLASS_LIKE_TYPE_ONLY => true,
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/class_types_only.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ namespace Rector\Php74\Tests\Rector\Property\TypedPropertyRector;
|
|||
|
||||
use Iterator;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\Php74\Rector\Property\TypedPropertyRector;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -25,16 +24,9 @@ final class DoctrineTypedPropertyRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/FixtureDoctrine');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
TypedPropertyRector::class => [
|
||||
TypedPropertyRector::CLASS_LIKE_TYPE_ONLY => false,
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
|
||||
protected function getPhpVersion(): int
|
||||
|
|
|
@ -6,7 +6,6 @@ namespace Rector\Php74\Tests\Rector\Property\TypedPropertyRector;
|
|||
|
||||
use Iterator;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\Php74\Rector\Property\TypedPropertyRector;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -30,15 +29,8 @@ final class TypedPropertyRectorTest extends AbstractRectorTestCase
|
|||
return PhpVersionFeature::UNION_TYPES - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
TypedPropertyRector::class => [
|
||||
TypedPropertyRector::CLASS_LIKE_TYPE_ONLY => false,
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
use Rector\Php74\Rector\Property\TypedPropertyRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(TypedPropertyRector::class)->call('configure', [[
|
||||
TypedPropertyRector::CLASS_LIKE_TYPE_ONLY => true,
|
||||
]]);
|
||||
};
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
use Rector\Php74\Rector\Property\TypedPropertyRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(TypedPropertyRector::class)->call('configure', [[
|
||||
TypedPropertyRector::CLASS_LIKE_TYPE_ONLY => false,
|
||||
]]);
|
||||
};
|
|
@ -34,11 +34,11 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
|||
use Webmozart\Assert\Assert;
|
||||
|
||||
/**
|
||||
* @see \Rector\PHPUnit\Tests\Rector\Class_\ArrayArgumentInTestToDataProviderRector\ArrayArgumentInTestToDataProviderRectorTest
|
||||
* @see \Rector\PHPUnit\Tests\Rector\Class_\ArrayArgumentToDataProviderRector\ArrayArgumentToDataProviderRectorTest
|
||||
*
|
||||
* @see why → https://blog.martinhujer.cz/how-to-use-data-providers-in-phpunit/
|
||||
*/
|
||||
final class ArrayArgumentInTestToDataProviderRector extends AbstractRector implements ConfigurableRectorInterface
|
||||
final class ArrayArgumentToDataProviderRector extends AbstractRector implements ConfigurableRectorInterface
|
||||
{
|
||||
/**
|
||||
* @api
|
|
@ -1,46 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\PHPUnit\Tests\Rector\Class_\ArrayArgumentInTestToDataProviderRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\PHPUnit\Rector\Class_\ArrayArgumentInTestToDataProviderRector;
|
||||
use Rector\PHPUnit\ValueObject\ArrayArgumentToDataProvider;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class ArrayArgumentInTestToDataProviderRectorTest extends AbstractRectorTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideData()
|
||||
*/
|
||||
public function test(SmartFileInfo $fileInfo): void
|
||||
{
|
||||
$this->doTestFileInfo($fileInfo);
|
||||
}
|
||||
|
||||
public function provideData(): Iterator
|
||||
{
|
||||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
{
|
||||
return [
|
||||
ArrayArgumentInTestToDataProviderRector::class => [
|
||||
ArrayArgumentInTestToDataProviderRector::ARRAY_ARGUMENTS_TO_DATA_PROVIDERS => [
|
||||
new ArrayArgumentToDataProvider(
|
||||
'PHPUnit\Framework\TestCase',
|
||||
'doTestMultiple',
|
||||
'doTestSingle',
|
||||
'variable'
|
||||
),
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\PHPUnit\Tests\Rector\Class_\ArrayArgumentToDataProviderRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class ArrayArgumentToDataProviderRectorTest extends AbstractRectorTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideData()
|
||||
*/
|
||||
public function test(SmartFileInfo $fileInfo): void
|
||||
{
|
||||
$this->doTestFileInfo($fileInfo);
|
||||
}
|
||||
|
||||
public function provideData(): Iterator
|
||||
{
|
||||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\Rector\Class_\ArrayArgumentInTestToDataProviderRector\Fixture;
|
||||
namespace Rector\PHPUnit\Tests\Rector\Class_\ArrayArgumentToDataProviderRector\Fixture;
|
||||
|
||||
class SomeServiceTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ class SomeServiceTest extends \PHPUnit\Framework\TestCase
|
|||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\Rector\Class_\ArrayArgumentInTestToDataProviderRector\Fixture;
|
||||
namespace Rector\PHPUnit\Tests\Rector\Class_\ArrayArgumentToDataProviderRector\Fixture;
|
||||
|
||||
class SomeServiceTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\Rector\Class_\ArrayArgumentInTestToDataProviderRector\Fixture;
|
||||
namespace Rector\PHPUnit\Tests\Rector\Class_\ArrayArgumentToDataProviderRector\Fixture;
|
||||
|
||||
class TwoArgumentsTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ class TwoArgumentsTest extends \PHPUnit\Framework\TestCase
|
|||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\Rector\Class_\ArrayArgumentInTestToDataProviderRector\Fixture;
|
||||
namespace Rector\PHPUnit\Tests\Rector\Class_\ArrayArgumentToDataProviderRector\Fixture;
|
||||
|
||||
class TwoArgumentsTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\Rector\Class_\ArrayArgumentInTestToDataProviderRector\Fixture;
|
||||
namespace Rector\PHPUnit\Tests\Rector\Class_\ArrayArgumentToDataProviderRector\Fixture;
|
||||
|
||||
class VariousTypesTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ class VariousTypesTest extends \PHPUnit\Framework\TestCase
|
|||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\Rector\Class_\ArrayArgumentInTestToDataProviderRector\Fixture;
|
||||
namespace Rector\PHPUnit\Tests\Rector\Class_\ArrayArgumentToDataProviderRector\Fixture;
|
||||
|
||||
class VariousTypesTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
use Rector\PHPUnit\Rector\Class_\ArrayArgumentToDataProviderRector;
|
||||
use Rector\PHPUnit\ValueObject\ArrayArgumentToDataProvider;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
|
||||
$services->set(ArrayArgumentToDataProviderRector::class)
|
||||
->call('configure', [[
|
||||
ArrayArgumentToDataProviderRector::ARRAY_ARGUMENTS_TO_DATA_PROVIDERS => ValueObjectInliner::inline([
|
||||
new ArrayArgumentToDataProvider(
|
||||
'PHPUnit\Framework\TestCase',
|
||||
'doTestMultiple',
|
||||
'doTestSingle',
|
||||
'variable'
|
||||
),
|
||||
]),
|
||||
]]);
|
||||
};
|
|
@ -5,8 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\RemovingStatic\Tests\Rector\Class_\PHPUnitStaticToKernelTestCaseGetRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\RemovingStatic\Rector\Class_\PHPUnitStaticToKernelTestCaseGetRector;
|
||||
use Rector\RemovingStatic\Tests\Rector\Class_\PHPUnitStaticToKernelTestCaseGetRector\Source\ClassWithStaticMethods;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -25,15 +23,8 @@ final class PHPUnitStaticToKernelTestCaseGetRectorTest extends AbstractRectorTes
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
PHPUnitStaticToKernelTestCaseGetRector::class => [
|
||||
PHPUnitStaticToKernelTestCaseGetRector::STATIC_CLASS_TYPES => [ClassWithStaticMethods::class],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
use Rector\RemovingStatic\Rector\Class_\PHPUnitStaticToKernelTestCaseGetRector;
|
||||
use Rector\RemovingStatic\Tests\Rector\Class_\PHPUnitStaticToKernelTestCaseGetRector\Source\ClassWithStaticMethods;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(PHPUnitStaticToKernelTestCaseGetRector::class)->call(
|
||||
'configure',
|
||||
[[
|
||||
PHPUnitStaticToKernelTestCaseGetRector::STATIC_CLASS_TYPES => [ClassWithStaticMethods::class],
|
||||
]]
|
||||
);
|
||||
};
|
|
@ -5,9 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\RemovingStatic\Tests\Rector\Class_\PassFactoryToEntityRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\RemovingStatic\Rector\Class_\NewUniqueObjectToEntityFactoryRector;
|
||||
use Rector\RemovingStatic\Rector\Class_\PassFactoryToUniqueObjectRector;
|
||||
use Rector\RemovingStatic\Tests\Rector\Class_\PassFactoryToEntityRector\Source\TurnMeToService;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\EasyTesting\StaticFixtureSplitter;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
@ -35,20 +32,8 @@ final class PassFactoryToEntityRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/FixtureWithMultipleArguments');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
$typesToServices = [TurnMeToService::class];
|
||||
|
||||
return [
|
||||
PassFactoryToUniqueObjectRector::class => [
|
||||
PassFactoryToUniqueObjectRector::TYPES_TO_SERVICES => $typesToServices,
|
||||
],
|
||||
NewUniqueObjectToEntityFactoryRector::class => [
|
||||
NewUniqueObjectToEntityFactoryRector::TYPES_TO_SERVICES => $typesToServices,
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\RemovingStatic\Rector\Class_\NewUniqueObjectToEntityFactoryRector;
|
||||
use Rector\RemovingStatic\Rector\Class_\PassFactoryToUniqueObjectRector;
|
||||
use Rector\RemovingStatic\Tests\Rector\Class_\PassFactoryToEntityRector\Source\TurnMeToService;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
|
||||
$typesToServices = [TurnMeToService::class];
|
||||
|
||||
$services->set(PassFactoryToUniqueObjectRector::class)
|
||||
->call('configure', [[
|
||||
PassFactoryToUniqueObjectRector::TYPES_TO_SERVICES => $typesToServices,
|
||||
]]);
|
||||
|
||||
$services->set(NewUniqueObjectToEntityFactoryRector::class)
|
||||
->call('configure', [[
|
||||
NewUniqueObjectToEntityFactoryRector::TYPES_TO_SERVICES => $typesToServices,
|
||||
]]);
|
||||
};
|
|
@ -5,9 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\RemovingStatic\Tests\Rector\Class_\StaticTypeToSetterInjectionRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\RemovingStatic\Rector\Class_\StaticTypeToSetterInjectionRector;
|
||||
use Rector\RemovingStatic\Tests\Rector\Class_\StaticTypeToSetterInjectionRector\Source\GenericEntityFactory;
|
||||
use Rector\RemovingStatic\Tests\Rector\Class_\StaticTypeToSetterInjectionRector\Source\GenericEntityFactoryWithInterface;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -26,19 +23,8 @@ final class StaticTypeToSetterInjectionRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
StaticTypeToSetterInjectionRector::class => [
|
||||
StaticTypeToSetterInjectionRector::STATIC_TYPES => [
|
||||
GenericEntityFactory::class,
|
||||
// with adding a parent interface to the class
|
||||
'ParentSetterEnforcingInterface' => GenericEntityFactoryWithInterface::class,
|
||||
],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
use Rector\RemovingStatic\Rector\Class_\StaticTypeToSetterInjectionRector;
|
||||
use Rector\RemovingStatic\Tests\Rector\Class_\StaticTypeToSetterInjectionRector\Source\GenericEntityFactory;
|
||||
use Rector\RemovingStatic\Tests\Rector\Class_\StaticTypeToSetterInjectionRector\Source\GenericEntityFactoryWithInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(StaticTypeToSetterInjectionRector::class)->call('configure', [[
|
||||
StaticTypeToSetterInjectionRector::STATIC_TYPES => [
|
||||
GenericEntityFactory::class,
|
||||
// with adding a parent interface to the class
|
||||
'ParentSetterEnforcingInterface' => GenericEntityFactoryWithInterface::class,
|
||||
],
|
||||
]]);
|
||||
};
|
|
@ -5,12 +5,7 @@ declare(strict_types=1);
|
|||
namespace Rector\Removing\Tests\Rector\ClassMethod\ArgumentRemoverRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Removing\Rector\ClassMethod\ArgumentRemoverRector;
|
||||
use Rector\Removing\Tests\Rector\ClassMethod\ArgumentRemoverRector\Source\Persister;
|
||||
use Rector\Removing\Tests\Rector\ClassMethod\ArgumentRemoverRector\Source\RemoveInTheMiddle;
|
||||
use Rector\Removing\ValueObject\ArgumentRemover;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class ArgumentRemoverRectorTest extends AbstractRectorTestCase
|
||||
|
@ -28,26 +23,8 @@ final class ArgumentRemoverRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
ArgumentRemoverRector::class => [
|
||||
ArgumentRemoverRector::REMOVED_ARGUMENTS => [
|
||||
new ArgumentRemover(Persister::class, 'getSelectJoinColumnSQL', 4, null),
|
||||
new ArgumentRemover(Yaml::class, 'parse', 1, [
|
||||
'Symfony\Component\Yaml\Yaml::PARSE_KEYS_AS_STRINGS',
|
||||
'hey',
|
||||
55,
|
||||
5.5,
|
||||
]),
|
||||
new ArgumentRemover(RemoveInTheMiddle::class, 'run', 1, [
|
||||
'name' => 'second',
|
||||
]),
|
||||
],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
use Rector\Removing\Rector\ClassMethod\ArgumentRemoverRector;
|
||||
use Rector\Removing\Tests\Rector\ClassMethod\ArgumentRemoverRector\Source\Persister;
|
||||
use Rector\Removing\Tests\Rector\ClassMethod\ArgumentRemoverRector\Source\RemoveInTheMiddle;
|
||||
use Rector\Removing\ValueObject\ArgumentRemover;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(ArgumentRemoverRector::class)->call('configure', [[
|
||||
ArgumentRemoverRector::REMOVED_ARGUMENTS => ValueObjectInliner::inline([
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
new ArgumentRemover(
|
||||
Persister::class,
|
||||
'getSelectJoinColumnSQL',
|
||||
4,
|
||||
null
|
||||
), new ArgumentRemover(
|
||||
Yaml::class,
|
||||
'parse',
|
||||
1,
|
||||
[
|
||||
'Symfony\Component\Yaml\Yaml::PARSE_KEYS_AS_STRINGS',
|
||||
'hey',
|
||||
55,
|
||||
5.5,
|
||||
|
||||
]), new ArgumentRemover(RemoveInTheMiddle::class, 'run', 1, [
|
||||
'name' => 'second',
|
||||
]), ]
|
||||
),
|
||||
]]);
|
||||
};
|
|
@ -5,8 +5,6 @@ declare(strict_types=1);
|
|||
namespace Rector\Removing\Tests\Rector\Class_\RemoveInterfacesRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Removing\Rector\Class_\RemoveInterfacesRector;
|
||||
use Rector\Removing\Tests\Rector\Class_\RemoveInterfacesRector\Source\SomeInterface;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
|
@ -25,15 +23,8 @@ final class RemoveInterfacesRectorTest extends AbstractRectorTestCase
|
|||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
protected function getRectorsWithConfiguration(): array
|
||||
protected function provideConfigFileInfo(): ?SmartFileInfo
|
||||
{
|
||||
return [
|
||||
RemoveInterfacesRector::class => [
|
||||
RemoveInterfacesRector::INTERFACES_TO_REMOVE => [SomeInterface::class],
|
||||
],
|
||||
];
|
||||
return new SmartFileInfo(__DIR__ . '/config/configured_rule.php');
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user