Start experimenting with PHP7.4 transpiling via rector
All checks were successful
timw4mail/php-kilo/pipeline/head This commit looks good

This commit is contained in:
Timothy Warren 2021-04-23 14:38:42 -04:00
parent a5223adfa5
commit 8bcc4c6807
3 changed files with 3665 additions and 61 deletions

View File

@ -17,6 +17,7 @@
"ext-json": "*",
"phpunit/phpunit": "^9.5.0",
"phpstan/phpstan": "^0.12.19",
"rector/rector": "^0.10.9",
"spatie/phpunit-snapshot-assertions": "^4.2.0"
},
"scripts": {
@ -27,6 +28,6 @@
},
"require": {
"ext-ffi": "*",
"php": ">= 8.0.0"
"php": ">= 7.4.0"
}
}

3669
composer.lock generated

File diff suppressed because it is too large Load Diff

54
rector.php Normal file
View File

@ -0,0 +1,54 @@
<?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);
}
};