1*077b7fe2SAndreas Gohr<?php 2*077b7fe2SAndreas Gohr 3*077b7fe2SAndreas Gohrdeclare(strict_types=1); 4*077b7fe2SAndreas Gohr 5*077b7fe2SAndreas Gohruse Rector\Caching\ValueObject\Storage\FileCacheStorage; 6*077b7fe2SAndreas Gohruse Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector; 7*077b7fe2SAndreas Gohruse Rector\CodeQuality\Rector\For_\ForRepeatedCountToOwnVariableRector; 8*077b7fe2SAndreas Gohruse Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector; 9*077b7fe2SAndreas Gohruse Rector\CodeQuality\Rector\If_\CombineIfRector; 10*077b7fe2SAndreas Gohruse Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector; 11*077b7fe2SAndreas Gohruse Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector; 12*077b7fe2SAndreas Gohruse Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector; 13*077b7fe2SAndreas Gohruse Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector; 14*077b7fe2SAndreas Gohruse Rector\CodingStyle\Rector\Closure\StaticClosureRector; 15*077b7fe2SAndreas Gohruse Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector; 16*077b7fe2SAndreas Gohruse Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector; 17*077b7fe2SAndreas Gohruse Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector; 18*077b7fe2SAndreas Gohruse Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector; 19*077b7fe2SAndreas Gohruse Rector\Config\RectorConfig; 20*077b7fe2SAndreas Gohruse Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector; 21*077b7fe2SAndreas Gohruse Rector\Php71\Rector\ClassConst\PublicConstantVisibilityRector; 22*077b7fe2SAndreas Gohruse Rector\Set\ValueObject\LevelSetList; 23*077b7fe2SAndreas Gohruse Rector\Set\ValueObject\SetList; 24*077b7fe2SAndreas Gohruse Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector; 25*077b7fe2SAndreas Gohr 26*077b7fe2SAndreas Gohrreturn static function (RectorConfig $rectorConfig): void { 27*077b7fe2SAndreas Gohr $rectorConfig->paths([ 28*077b7fe2SAndreas Gohr __DIR__ . '/../inc', 29*077b7fe2SAndreas Gohr __DIR__ . '/../lib', 30*077b7fe2SAndreas Gohr ]); 31*077b7fe2SAndreas Gohr 32*077b7fe2SAndreas Gohr $rectorConfig->importNames(); 33*077b7fe2SAndreas Gohr $rectorConfig->importShortClasses(false); 34*077b7fe2SAndreas Gohr $rectorConfig->cacheClass(FileCacheStorage::class); 35*077b7fe2SAndreas Gohr $rectorConfig->cacheDirectory(__DIR__ . '/.rector-cache'); 36*077b7fe2SAndreas Gohr 37*077b7fe2SAndreas Gohr // define sets of rules 38*077b7fe2SAndreas Gohr $rectorConfig->sets([ 39*077b7fe2SAndreas Gohr LevelSetList::UP_TO_PHP_74, 40*077b7fe2SAndreas Gohr SetList::CODE_QUALITY, 41*077b7fe2SAndreas Gohr SetList::DEAD_CODE, 42*077b7fe2SAndreas Gohr SetList::CODING_STYLE, 43*077b7fe2SAndreas Gohr ]); 44*077b7fe2SAndreas Gohr 45*077b7fe2SAndreas Gohr $rectorConfig->skip([ 46*077b7fe2SAndreas Gohr // skip paths 47*077b7fe2SAndreas Gohr __DIR__ . '/../inc/lang/*', 48*077b7fe2SAndreas Gohr __DIR__ . '/../lib/plugins/*/_test/*', 49*077b7fe2SAndreas Gohr __DIR__ . '/../lib/tpl/*/_test/*', 50*077b7fe2SAndreas Gohr __DIR__ . '/../lib/plugins/*/lang/*', 51*077b7fe2SAndreas Gohr __DIR__ . '/../lib/tpl/*/lang/*', 52*077b7fe2SAndreas Gohr __DIR__ . '/../lib/plugins/*/vendor/*', 53*077b7fe2SAndreas Gohr __DIR__ . '/../lib/tpl/*/vendor/*', 54*077b7fe2SAndreas Gohr __DIR__ . '/../lib/plugins/*/skel/*', // dev plugin 55*077b7fe2SAndreas Gohr 56*077b7fe2SAndreas Gohr // third party libs, not yet moved to composer 57*077b7fe2SAndreas Gohr __DIR__ . '/../inc/DifferenceEngine.php', 58*077b7fe2SAndreas Gohr __DIR__ . '/../inc/JpegMeta.php', 59*077b7fe2SAndreas Gohr __DIR__ . '/../lib/plugins/authad/adLDAP', 60*077b7fe2SAndreas Gohr 61*077b7fe2SAndreas Gohr // skip rules 62*077b7fe2SAndreas Gohr SimplifyIfElseToTernaryRector::class, 63*077b7fe2SAndreas Gohr NewlineAfterStatementRector::class, 64*077b7fe2SAndreas Gohr CombineIfRector::class, 65*077b7fe2SAndreas Gohr ExplicitBoolCompareRector::class, 66*077b7fe2SAndreas Gohr IssetOnPropertyObjectToPropertyExistsRector::class, // maybe? 67*077b7fe2SAndreas Gohr SymplifyQuoteEscapeRector::class, 68*077b7fe2SAndreas Gohr CatchExceptionNameMatchingTypeRector::class, 69*077b7fe2SAndreas Gohr PublicConstantVisibilityRector::class, // open for discussion 70*077b7fe2SAndreas Gohr EncapsedStringsToSprintfRector::class, 71*077b7fe2SAndreas Gohr CallableThisArrayToAnonymousFunctionRector::class, 72*077b7fe2SAndreas Gohr StaticClosureRector::class, 73*077b7fe2SAndreas Gohr SimplifyUselessVariableRector::class, // seems to strip constructor property initializations 74*077b7fe2SAndreas Gohr PostIncDecToPreIncDecRector::class, 75*077b7fe2SAndreas Gohr RemoveUselessParamTagRector::class, 76*077b7fe2SAndreas Gohr DisallowedEmptyRuleFixerRector::class, 77*077b7fe2SAndreas Gohr ForRepeatedCountToOwnVariableRector::class, // adds unwanted is_countable checks? 78*077b7fe2SAndreas Gohr ]); 79*077b7fe2SAndreas Gohr}; 80