Skip to content

Instantly share code, notes, and snippets.

@vudaltsov
Last active February 19, 2023 19:29
Show Gist options
  • Save vudaltsov/46aa5b57d5da2e745cc861cd9c603689 to your computer and use it in GitHub Desktop.
Save vudaltsov/46aa5b57d5da2e745cc861cd9c603689 to your computer and use it in GitHub Desktop.
<?php
declare(strict_types=1);
use HappyInc\Tool\Rector\ReadOnlyPublicPropertyRector;
use HappyInc\Tool\Rector\UuidTRector;
use Rector\Config\RectorConfig;
use Rector\Core\Configuration\Option;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\Php71\Rector\FuncCall\CountOnNullRector;
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
use Rector\Php74\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Php80\Rector\Class_\StringableForToStringRector;
use Rector\Php80\Rector\FunctionLike\UnionTypesRector;
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
use Rector\Set\ValueObject\LevelSetList;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->parallel();
$rectorConfig->importNames();
$rectorConfig->importShortClasses(false);
$rectorConfig->parameters()->set(Option::APPLY_AUTO_IMPORT_NAMES_ON_CHANGED_FILES_ONLY, true);
$rectorConfig->cacheDirectory(__DIR__.'/var/rector');
$rectorConfig->paths([
__DIR__.'/migrations',
__DIR__.'/src',
__DIR__.'/src-dev',
__DIR__.'/tests',
]);
$rectorConfig->sets([LevelSetList::UP_TO_PHP_81]);
$rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, [
'json_encode' => 'jsonEncode',
'json_decode' => 'jsonDecode',
]);
$rectorConfig->rule(ReadOnlyPublicPropertyRector::class);
$rectorConfig->rule(UuidTRector::class);
$rectorConfig->skip([
// TODO https://yt.happy-inc.ru/issue/V3-3382
ArraySpreadInsteadOfArrayMergeRector::class,
ClassPropertyAssignToConstructorPromotionRector::class => [__DIR__.'/src/Http'],
CountOnNullRector::class,
NullToStrictStringFuncCallArgRector::class,
RemoveExtraParametersRector::class,
ReturnNeverTypeRector::class,
StringableForToStringRector::class,
UnionTypesRector::class,
StringClassNameToClassConstantRector::class => [__DIR__.'/migrations'],
]);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment