php-kilo/rector.php
Timothy Warren 8bcc4c6807
All checks were successful
timw4mail/php-kilo/pipeline/head This commit looks good
Start experimenting with PHP7.4 transpiling via rector
2021-04-23 14:38:42 -04:00

55 lines
2.1 KiB
PHP

<?php
declare(strict_types=1);
use Rector\Core\Configuration\Option;
use Rector\DowngradePhp80\Rector\Catch_\DowngradeNonCapturingCatchesRector;
use Rector\DowngradePhp80\Rector\Class_\DowngradePropertyPromotionRector;
use Rector\DowngradePhp80\Rector\ClassConstFetch\DowngradeClassOnObjectToGetClassRector;
use Rector\DowngradePhp80\Rector\ClassMethod\DowngradeStaticTypeDeclarationRector;
use Rector\DowngradePhp80\Rector\ClassMethod\DowngradeTrailingCommasInParamUseRector;
use Rector\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector;
use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeMixedTypeDeclarationRector;
use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDeclarationRector;
use Rector\DowngradePhp80\Rector\NullsafeMethodCall\DowngradeNullsafeToTernaryOperatorRector;
use Rector\DowngradePhp80\Rector\Property\DowngradeUnionTypeTypedPropertyRector;
use Rector\Generics\Rector\Class_\GenericsPHPStormMethodAnnotationRector;
use Rector\Set\ValueObject\SetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
// get parameters
// $parameters = $containerConfigurator->parameters();
//
// // Define what rule sets will be applied
// $parameters->set(Option::SETS, [
// SetList::DEAD_CODE,
// SetList::PHP_80,
// ]);
// get services (needed for register a single rule)
$services = $containerConfigurator->services();
$rules = [
// PHP8 downgrade
DowngradeClassOnObjectToGetClassRector::class,
DowngradeMatchToSwitchRector::class,
DowngradeMixedTypeDeclarationRector::class,
DowngradeNonCapturingCatchesRector::class,
DowngradeNullsafeToTernaryOperatorRector::class,
DowngradePropertyPromotionRector::class,
DowngradeStaticTypeDeclarationRector::class,
DowngradeTrailingCommasInParamUseRector::class,
DowngradeUnionTypeDeclarationRector::class,
DowngradeUnionTypeTypedPropertyRector::class,
GenericsPHPStormMethodAnnotationRector::class,
];
foreach ($rules as $rule)
{
$services->set($rule);
}
};