Last active
February 7, 2025 14:46
-
-
Save wilsenhc/288191f1c49fa59263f78dcd9814b1d1 to your computer and use it in GitHub Desktop.
Rector config example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Rector\CodeQuality\Rector\ClassMethod\ExplicitReturnNullRector; | |
use Rector\CodeQuality\Rector\If_\ConsecutiveNullCompareReturnsToNullCoalesceQueueRector; | |
use Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector; | |
use Rector\CodingStyle\Rector\ArrowFunction\StaticArrowFunctionRector; | |
use Rector\CodingStyle\Rector\Closure\StaticClosureRector; | |
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector; | |
use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector; | |
use Rector\CodingStyle\Rector\Use_\SeparateMultiUseImportsRector; | |
use Rector\Config\RectorConfig; | |
use Rector\DeadCode\Rector\TryCatch\RemoveDeadTryCatchRector; | |
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector; | |
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector; | |
use Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector; | |
use Rector\Php81\Rector\Array_\FirstClassCallableRector; | |
use Rector\Renaming\Rector\Name\RenameClassRector; | |
use Rector\Set\ValueObject\LevelSetList; | |
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector; | |
use RectorLaravel\Rector\Class_\AnonymousMigrationsRector; | |
use RectorLaravel\Rector\ClassMethod\AddGenericReturnTypeToRelationsRector; | |
use RectorLaravel\Rector\Empty_\EmptyToBlankAndFilledFuncRector; | |
use RectorLaravel\Rector\StaticCall\EloquentMagicMethodToQueryBuilderRector; | |
use RectorLaravel\Set\LaravelLevelSetList; | |
return RectorConfig::configure() | |
->withPaths([ | |
__DIR__.'/app', | |
__DIR__.'/database', | |
__DIR__.'/routes', | |
]) | |
->withImportNames( | |
importNames: true, | |
importDocBlockNames: false, | |
importShortClasses: true, | |
removeUnusedImports: true, | |
) | |
->withPreparedSets( | |
deadCode: true, | |
codeQuality: true, | |
codingStyle: true, | |
typeDeclarations: false, | |
privatization: false, | |
naming: false, | |
instanceOf: true, | |
earlyReturn: true, | |
strictBooleans: false, | |
carbon: true, | |
rectorPreset: true, | |
) | |
->withSets([ | |
LevelSetList::UP_TO_PHP_83, | |
LaravelLevelSetList::UP_TO_LARAVEL_110, | |
]) | |
->withRules([ | |
AddLiteralSeparatorToNumberRector::class, | |
AddGenericReturnTypeToRelationsRector::class, | |
EmptyToBlankAndFilledFuncRector::class, | |
EloquentMagicMethodToQueryBuilderRector::class, | |
AnonymousMigrationsRector::class, | |
// RemoveDumpDataDeadCodeRector::class, | |
]) | |
->withConfiguredRule(RenameClassRector::class, [ | |
'Illuminate\\Support\\Carbon' => 'Carbon\\Carbon', | |
]) | |
->withSkip([ | |
__DIR__.'/app/Annotations', | |
DeclareStrictTypesRector::class, | |
EncapsedStringsToSprintfRector::class, | |
PostIncDecToPreIncDecRector::class, | |
JsonThrowOnErrorRector::class, | |
StaticClosureRector::class, | |
StaticArrowFunctionRector::class, | |
IssetOnPropertyObjectToPropertyExistsRector::class, | |
FirstClassCallableRector::class, | |
SeparateMultiUseImportsRector::class, | |
ExplicitReturnNullRector::class, | |
RemoveDeadTryCatchRector::class, | |
FirstClassCallableRector::class, | |
ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class, | |
EmptyToBlankAndFilledFuncRector::class, | |
ClosureToArrowFunctionRector::class => [ | |
__DIR__.'/routes', | |
], | |
EloquentMagicMethodToQueryBuilderRector::class => [ | |
__DIR__.'/app/Http/Controllers/V2/ObservationController.php', | |
], | |
]) | |
->withCache(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment