xref: /dokuwiki/_test/rector.php (revision 0603e565f99519c35708bab370f1c5f3271c1365)
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;
7077b7fe2SAndreas Gohruse Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
8077b7fe2SAndreas Gohruse Rector\CodeQuality\Rector\If_\CombineIfRector;
9077b7fe2SAndreas Gohruse Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
10077b7fe2SAndreas Gohruse Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector;
111490c177SAndreas Gohruse Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector;
12077b7fe2SAndreas Gohruse Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector;
13077b7fe2SAndreas Gohruse Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector;
14077b7fe2SAndreas Gohruse Rector\CodingStyle\Rector\Closure\StaticClosureRector;
15077b7fe2SAndreas Gohruse Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
166723156fSAndreas Gohruse Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector;
17077b7fe2SAndreas Gohruse Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector;
18077b7fe2SAndreas Gohruse Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
19077b7fe2SAndreas Gohruse Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector;
20077b7fe2SAndreas Gohruse Rector\Config\RectorConfig;
21077b7fe2SAndreas Gohruse Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector;
226723156fSAndreas Gohruse Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector;
23077b7fe2SAndreas Gohruse Rector\Php71\Rector\ClassConst\PublicConstantVisibilityRector;
24*0603e565SAndreas Gohruse Rector\Php71\Rector\FuncCall\CountOnNullRector;
25077b7fe2SAndreas Gohruse Rector\Set\ValueObject\LevelSetList;
26077b7fe2SAndreas Gohruse Rector\Set\ValueObject\SetList;
27077b7fe2SAndreas Gohruse Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
28077b7fe2SAndreas Gohr
29077b7fe2SAndreas Gohrreturn static function (RectorConfig $rectorConfig): void {
301490c177SAndreas Gohr    define('DOKU_INC', __DIR__ . '/../');
311490c177SAndreas Gohr
32077b7fe2SAndreas Gohr    $rectorConfig->paths([
33077b7fe2SAndreas Gohr        __DIR__ . '/../inc',
34077b7fe2SAndreas Gohr        __DIR__ . '/../lib',
35077b7fe2SAndreas Gohr    ]);
36077b7fe2SAndreas Gohr
371490c177SAndreas Gohr    $rectorConfig->bootstrapFiles([
381490c177SAndreas Gohr        __DIR__ . '/../inc/load.php',
391490c177SAndreas Gohr    ]);
401490c177SAndreas Gohr
41077b7fe2SAndreas Gohr    $rectorConfig->importNames();
42077b7fe2SAndreas Gohr    $rectorConfig->importShortClasses(false);
43077b7fe2SAndreas Gohr    $rectorConfig->cacheClass(FileCacheStorage::class);
44077b7fe2SAndreas Gohr    $rectorConfig->cacheDirectory(__DIR__ . '/.rector-cache');
45077b7fe2SAndreas Gohr
46077b7fe2SAndreas Gohr    // define sets of rules
47077b7fe2SAndreas Gohr    $rectorConfig->sets([
48077b7fe2SAndreas Gohr        LevelSetList::UP_TO_PHP_74,
49077b7fe2SAndreas Gohr        SetList::CODE_QUALITY,
50077b7fe2SAndreas Gohr        SetList::DEAD_CODE,
51077b7fe2SAndreas Gohr        SetList::CODING_STYLE,
52077b7fe2SAndreas Gohr    ]);
53077b7fe2SAndreas Gohr
54077b7fe2SAndreas Gohr    $rectorConfig->skip([
55077b7fe2SAndreas Gohr        // skip paths
56077b7fe2SAndreas Gohr        __DIR__ . '/../inc/lang/*',
57077b7fe2SAndreas Gohr        __DIR__ . '/../lib/plugins/*/_test/*',
58077b7fe2SAndreas Gohr        __DIR__ . '/../lib/tpl/*/_test/*',
59077b7fe2SAndreas Gohr        __DIR__ . '/../lib/plugins/*/lang/*',
60077b7fe2SAndreas Gohr        __DIR__ . '/../lib/tpl/*/lang/*',
61077b7fe2SAndreas Gohr        __DIR__ . '/../lib/plugins/*/vendor/*',
62077b7fe2SAndreas Gohr        __DIR__ . '/../lib/tpl/*/vendor/*',
63077b7fe2SAndreas Gohr        __DIR__ . '/../lib/plugins/*/skel/*', // dev plugin
64077b7fe2SAndreas Gohr
65077b7fe2SAndreas Gohr        // third party libs, not yet moved to composer
66077b7fe2SAndreas Gohr        __DIR__ . '/../inc/DifferenceEngine.php',
67077b7fe2SAndreas Gohr        __DIR__ . '/../inc/JpegMeta.php',
68077b7fe2SAndreas Gohr        __DIR__ . '/../lib/plugins/authad/adLDAP',
69077b7fe2SAndreas Gohr
70077b7fe2SAndreas Gohr        // skip rules
71077b7fe2SAndreas Gohr        SimplifyIfElseToTernaryRector::class,
72077b7fe2SAndreas Gohr        NewlineAfterStatementRector::class,
73077b7fe2SAndreas Gohr        CombineIfRector::class,
74077b7fe2SAndreas Gohr        ExplicitBoolCompareRector::class,
75077b7fe2SAndreas Gohr        IssetOnPropertyObjectToPropertyExistsRector::class, // maybe?
76077b7fe2SAndreas Gohr        SymplifyQuoteEscapeRector::class,
77077b7fe2SAndreas Gohr        CatchExceptionNameMatchingTypeRector::class,
78077b7fe2SAndreas Gohr        PublicConstantVisibilityRector::class, // open for discussion
79077b7fe2SAndreas Gohr        EncapsedStringsToSprintfRector::class,
80077b7fe2SAndreas Gohr        CallableThisArrayToAnonymousFunctionRector::class,
81077b7fe2SAndreas Gohr        StaticClosureRector::class,
82077b7fe2SAndreas Gohr        SimplifyUselessVariableRector::class, // seems to strip constructor property initializations
83077b7fe2SAndreas Gohr        PostIncDecToPreIncDecRector::class,
84077b7fe2SAndreas Gohr        RemoveUselessParamTagRector::class,
85077b7fe2SAndreas Gohr        DisallowedEmptyRuleFixerRector::class,
86*0603e565SAndreas Gohr        CountOnNullRector::class, // adds unwanted is_countable checks?
876723156fSAndreas Gohr        RemoveParentCallWithoutParentRector::class,
886723156fSAndreas Gohr        WrapEncapsedVariableInCurlyBracesRector::class,
891490c177SAndreas Gohr        SimplifyIfReturnBoolRector::class,
90077b7fe2SAndreas Gohr    ]);
91077b7fe2SAndreas Gohr};
92