2020-07-18 20:26:57 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-12-25 19:11:33 +01:00
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use Rector\CodingStyle\Rector\MethodCall\PreferThisOrSelfMethodCallRector;
|
|
|
|
use Rector\CodingStyle\Rector\String_\SplitStringClassConstantToClassConstFetchRector;
|
2020-07-18 20:26:57 +02:00
|
|
|
use Rector\Core\Configuration\Option;
|
2020-12-25 19:11:33 +01:00
|
|
|
use Rector\Core\Rector\AbstractRector;
|
2020-11-26 23:09:21 +01:00
|
|
|
use Rector\Core\ValueObject\PhpVersion;
|
2020-12-25 19:11:33 +01:00
|
|
|
use Rector\DeadCode\Rector\ClassConst\RemoveUnusedClassConstantRector;
|
|
|
|
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
|
|
|
|
use Rector\Restoration\Rector\ClassMethod\InferParamFromClassMethodReturnRector;
|
|
|
|
use Rector\Restoration\ValueObject\InferParamFromClassMethodReturn;
|
2020-12-09 23:25:53 +01:00
|
|
|
use Rector\Set\ValueObject\SetList;
|
2020-12-25 19:11:33 +01:00
|
|
|
use Rector\SymfonyPhpConfig\Rector\MethodCall\AutoInPhpSymfonyConfigRector;
|
2020-07-18 20:26:57 +02:00
|
|
|
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
2020-12-25 19:11:33 +01:00
|
|
|
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
2020-07-18 20:26:57 +02:00
|
|
|
|
|
|
|
return static function (ContainerConfigurator $containerConfigurator): void {
|
2020-12-25 19:11:33 +01:00
|
|
|
$services = $containerConfigurator->services();
|
|
|
|
|
|
|
|
$configuration = ValueObjectInliner::inline([
|
|
|
|
new InferParamFromClassMethodReturn(AbstractRector::class, 'refactor', 'getNodeTypes'),
|
|
|
|
]);
|
|
|
|
$services->set(InferParamFromClassMethodReturnRector::class)
|
|
|
|
->call('configure', [[
|
|
|
|
InferParamFromClassMethodReturnRector::INFER_PARAMS_FROM_CLASS_METHOD_RETURNS => $configuration,
|
|
|
|
]]);
|
|
|
|
|
|
|
|
$services->set(PreferThisOrSelfMethodCallRector::class)
|
|
|
|
->call('configure', [[
|
|
|
|
PreferThisOrSelfMethodCallRector::TYPE_TO_PREFERENCE => [
|
|
|
|
TestCase::class => PreferThisOrSelfMethodCallRector::PREFER_THIS,
|
|
|
|
],
|
|
|
|
]]);
|
|
|
|
|
|
|
|
$services->set(AutoInPhpSymfonyConfigRector::class);
|
|
|
|
|
2020-07-18 20:26:57 +02:00
|
|
|
$parameters = $containerConfigurator->parameters();
|
2020-08-24 23:25:26 +02:00
|
|
|
|
2020-12-25 19:11:33 +01:00
|
|
|
$parameters->set(Option::SETS, [
|
|
|
|
SetList::CODING_STYLE,
|
|
|
|
SetList::CODE_QUALITY,
|
|
|
|
SetList::CODE_QUALITY_STRICT,
|
|
|
|
SetList::DEAD_CODE,
|
|
|
|
SetList::DEAD_DOC_BLOCK,
|
|
|
|
SetList::NETTE_UTILS_CODE_QUALITY,
|
|
|
|
SetList::PRIVATIZATION,
|
|
|
|
SetList::NAMING,
|
2021-01-22 19:47:02 +01:00
|
|
|
SetList::ORDER,
|
2020-12-25 19:11:33 +01:00
|
|
|
SetList::DEFLUENT,
|
|
|
|
SetList::TYPE_DECLARATION,
|
|
|
|
SetList::PHPUNIT_CODE_QUALITY,
|
|
|
|
Setlist::SYMFONY_AUTOWIRE,
|
|
|
|
Setlist::PHP_71,
|
|
|
|
Setlist::PHP_72,
|
|
|
|
Setlist::PHP_73,
|
|
|
|
Setlist::EARLY_RETURN,
|
|
|
|
]);
|
|
|
|
|
2020-07-27 11:26:41 +02:00
|
|
|
$parameters->set(Option::PATHS, [
|
|
|
|
__DIR__ . '/src',
|
|
|
|
__DIR__ . '/rules',
|
|
|
|
__DIR__ . '/packages',
|
2020-12-25 19:11:33 +01:00
|
|
|
__DIR__ . '/tests',
|
|
|
|
__DIR__ . '/utils',
|
|
|
|
__DIR__ . '/config/set',
|
2020-07-27 11:26:41 +02:00
|
|
|
]);
|
|
|
|
|
2020-12-25 19:11:33 +01:00
|
|
|
$parameters->set(Option::AUTO_IMPORT_NAMES, true);
|
2020-12-09 23:25:53 +01:00
|
|
|
|
2020-11-26 23:09:21 +01:00
|
|
|
$parameters->set(Option::SKIP, [
|
2020-12-25 19:11:33 +01:00
|
|
|
StringClassNameToClassConstantRector::class,
|
|
|
|
SplitStringClassConstantToClassConstFetchRector::class,
|
|
|
|
// false positives on constants used in rector.php
|
|
|
|
RemoveUnusedClassConstantRector::class,
|
|
|
|
|
|
|
|
// test paths
|
2020-12-09 23:25:53 +01:00
|
|
|
'*/Fixture/*',
|
2020-12-25 19:11:33 +01:00
|
|
|
'*/Source/*',
|
2020-12-09 23:25:53 +01:00
|
|
|
'*/Expected/*',
|
2020-07-18 20:26:57 +02:00
|
|
|
|
2020-12-25 19:11:33 +01:00
|
|
|
__DIR__ . '/packages/doctrine-annotation-generated/src',
|
|
|
|
// template files
|
|
|
|
__DIR__ . '/packages/rector-generator/templates',
|
|
|
|
__DIR__ . '/packages/rector-generator/src/ValueObject/RectorRecipe.php',
|
|
|
|
]);
|
2020-09-01 19:56:30 +02:00
|
|
|
|
2020-12-25 19:11:33 +01:00
|
|
|
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_73);
|
|
|
|
$parameters->set(Option::ENABLE_CACHE, true);
|
2020-07-18 20:26:57 +02:00
|
|
|
};
|