1077b7fe2SAndreas Gohr<?php 2077b7fe2SAndreas Gohr 3077b7fe2SAndreas Gohrdeclare(strict_types=1); 4077b7fe2SAndreas Gohr 5077b7fe2SAndreas Gohruse Rector\Caching\ValueObject\Storage\FileCacheStorage; 6077b7fe2SAndreas Gohruse Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector; 7e2d055f5SAndreas Gohruse Rector\CodeQuality\Rector\Concat\JoinStringConcatRector; 8077b7fe2SAndreas Gohruse Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector; 9077b7fe2SAndreas Gohruse Rector\CodeQuality\Rector\If_\CombineIfRector; 10077b7fe2SAndreas Gohruse Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector; 11077b7fe2SAndreas Gohruse Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector; 121490c177SAndreas Gohruse Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector; 13077b7fe2SAndreas Gohruse Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector; 14077b7fe2SAndreas Gohruse Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector; 15104a3b7cSAndreas Gohruse Rector\CodingStyle\Rector\Class_\AddArrayDefaultToArrayPropertyRector; 16077b7fe2SAndreas Gohruse Rector\CodingStyle\Rector\Closure\StaticClosureRector; 17077b7fe2SAndreas Gohruse Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector; 186723156fSAndreas Gohruse Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector; 19a469bafbSAndreas Gohruse Rector\CodingStyle\Rector\FuncCall\StrictArraySearchRector; 20077b7fe2SAndreas Gohruse Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector; 21077b7fe2SAndreas Gohruse Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector; 22077b7fe2SAndreas Gohruse Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector; 23077b7fe2SAndreas Gohruse Rector\Config\RectorConfig; 24077b7fe2SAndreas Gohruse Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector; 2524870174SAndreas Gohruse Rector\DeadCode\Rector\For_\RemoveDeadContinueRector; 2624870174SAndreas Gohruse Rector\DeadCode\Rector\For_\RemoveDeadIfForeachForRector; 2724870174SAndreas Gohruse Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector; 28bcaec9f4SAndreas Gohruse Rector\DeadCode\Rector\If_\RemoveUnusedNonEmptyArrayBeforeForeachRector; 29104a3b7cSAndreas Gohruse Rector\DeadCode\Rector\Property\RemoveUselessVarTagRector; 306723156fSAndreas Gohruse Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector; 3124870174SAndreas Gohruse Rector\DeadCode\Rector\Stmt\RemoveUnreachableStatementRector; 32077b7fe2SAndreas Gohruse Rector\Php71\Rector\ClassConst\PublicConstantVisibilityRector; 330603e565SAndreas Gohruse Rector\Php71\Rector\FuncCall\CountOnNullRector; 346e695190SAndreas Gohruse Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector; 35077b7fe2SAndreas Gohruse Rector\Set\ValueObject\LevelSetList; 36077b7fe2SAndreas Gohruse Rector\Set\ValueObject\SetList; 37077b7fe2SAndreas Gohruse Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector; 38104a3b7cSAndreas Gohruse Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector; 39077b7fe2SAndreas Gohr 40077b7fe2SAndreas Gohrreturn static function (RectorConfig $rectorConfig): void { 41077b7fe2SAndreas Gohr $rectorConfig->paths([ 42*b1f206e1SAndreas Gohr __DIR__ . '/../inc/', 43*b1f206e1SAndreas Gohr __DIR__ . '/../lib/', 44*b1f206e1SAndreas Gohr __DIR__ . '/../bin/', 45*b1f206e1SAndreas Gohr __DIR__ . '/../*.php', 46077b7fe2SAndreas Gohr ]); 47077b7fe2SAndreas Gohr 481490c177SAndreas Gohr $rectorConfig->bootstrapFiles([ 4924870174SAndreas Gohr __DIR__ . '/../inc/init.php', 501490c177SAndreas Gohr ]); 511490c177SAndreas Gohr 52077b7fe2SAndreas Gohr $rectorConfig->importNames(); 53077b7fe2SAndreas Gohr $rectorConfig->importShortClasses(false); 54077b7fe2SAndreas Gohr $rectorConfig->cacheClass(FileCacheStorage::class); 55077b7fe2SAndreas Gohr $rectorConfig->cacheDirectory(__DIR__ . '/.rector-cache'); 56077b7fe2SAndreas Gohr 57077b7fe2SAndreas Gohr // define sets of rules 58077b7fe2SAndreas Gohr $rectorConfig->sets([ 59077b7fe2SAndreas Gohr LevelSetList::UP_TO_PHP_74, 60077b7fe2SAndreas Gohr SetList::CODE_QUALITY, 61077b7fe2SAndreas Gohr SetList::DEAD_CODE, 62077b7fe2SAndreas Gohr SetList::CODING_STYLE, 63077b7fe2SAndreas Gohr ]); 64077b7fe2SAndreas Gohr 65077b7fe2SAndreas Gohr $rectorConfig->skip([ 66077b7fe2SAndreas Gohr // skip paths 67077b7fe2SAndreas Gohr __DIR__ . '/../inc/lang/*', 68077b7fe2SAndreas Gohr __DIR__ . '/../lib/plugins/*/_test/*', 69077b7fe2SAndreas Gohr __DIR__ . '/../lib/tpl/*/_test/*', 70077b7fe2SAndreas Gohr __DIR__ . '/../lib/plugins/*/lang/*', 71077b7fe2SAndreas Gohr __DIR__ . '/../lib/tpl/*/lang/*', 72467c1427SAndreas Gohr __DIR__ . '/../lib/plugins/*/conf/*', // maybe later 73467c1427SAndreas Gohr __DIR__ . '/../lib/tpl/*/conf/*', // maybe later 74077b7fe2SAndreas Gohr __DIR__ . '/../lib/plugins/*/vendor/*', 75077b7fe2SAndreas Gohr __DIR__ . '/../lib/tpl/*/vendor/*', 76077b7fe2SAndreas Gohr __DIR__ . '/../lib/plugins/*/skel/*', // dev plugin 7724870174SAndreas Gohr __DIR__ . '/../inc/deprecated.php', 7824870174SAndreas Gohr __DIR__ . '/../inc/form.php', 79077b7fe2SAndreas Gohr 80077b7fe2SAndreas Gohr // third party libs, not yet moved to composer 81077b7fe2SAndreas Gohr __DIR__ . '/../inc/DifferenceEngine.php', 82077b7fe2SAndreas Gohr __DIR__ . '/../inc/JpegMeta.php', 83077b7fe2SAndreas Gohr __DIR__ . '/../lib/plugins/authad/adLDAP', 84077b7fe2SAndreas Gohr 85077b7fe2SAndreas Gohr // skip rules 86077b7fe2SAndreas Gohr SimplifyIfElseToTernaryRector::class, 87077b7fe2SAndreas Gohr NewlineAfterStatementRector::class, 88077b7fe2SAndreas Gohr CombineIfRector::class, 89077b7fe2SAndreas Gohr ExplicitBoolCompareRector::class, 90077b7fe2SAndreas Gohr IssetOnPropertyObjectToPropertyExistsRector::class, // maybe? 91077b7fe2SAndreas Gohr SymplifyQuoteEscapeRector::class, 92077b7fe2SAndreas Gohr CatchExceptionNameMatchingTypeRector::class, 93077b7fe2SAndreas Gohr EncapsedStringsToSprintfRector::class, 94077b7fe2SAndreas Gohr CallableThisArrayToAnonymousFunctionRector::class, 95077b7fe2SAndreas Gohr StaticClosureRector::class, 96077b7fe2SAndreas Gohr SimplifyUselessVariableRector::class, // seems to strip constructor property initializations 97077b7fe2SAndreas Gohr PostIncDecToPreIncDecRector::class, 98077b7fe2SAndreas Gohr RemoveUselessParamTagRector::class, 99077b7fe2SAndreas Gohr DisallowedEmptyRuleFixerRector::class, 1000603e565SAndreas Gohr CountOnNullRector::class, // adds unwanted is_countable checks? 1016723156fSAndreas Gohr RemoveParentCallWithoutParentRector::class, 1026723156fSAndreas Gohr WrapEncapsedVariableInCurlyBracesRector::class, 1031490c177SAndreas Gohr SimplifyIfReturnBoolRector::class, 104a469bafbSAndreas Gohr StrictArraySearchRector::class, // we cannot assume strict search is always wanted 105104a3b7cSAndreas Gohr AddArrayDefaultToArrayPropertyRector::class, // may break code differentiating between null and empty array 106104a3b7cSAndreas Gohr RemoveUselessVarTagRector::class, 107104a3b7cSAndreas Gohr TypedPropertyFromAssignsRector::class, // maybe? 108e2d055f5SAndreas Gohr JoinStringConcatRector::class, // this does not count variables, so it creates overlong lines 1096e695190SAndreas Gohr RemoveExtraParametersRector::class, // this actually broke code 110bcaec9f4SAndreas Gohr RemoveUnusedNonEmptyArrayBeforeForeachRector::class, // seems unreliable when checking on array keys 11124870174SAndreas Gohr RemoveAlwaysTrueIfConditionRector::class, // fails with if(defined(...)) constructs 112ab9790caSAndreas Gohr RemoveUnreachableStatementRector::class, // fails GOTO in authpdo -> should be rewritten with exceptions 113077b7fe2SAndreas Gohr ]); 114077b7fe2SAndreas Gohr}; 115