xref: /dokuwiki/_test/rector.php (revision e2d055f5c6617b7cc57c19fa727b968f3689e13c)
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;
7*e2d055f5SAndreas 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;
25104a3b7cSAndreas Gohruse Rector\DeadCode\Rector\Property\RemoveUselessVarTagRector;
266723156fSAndreas Gohruse Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector;
27077b7fe2SAndreas Gohruse Rector\Php71\Rector\ClassConst\PublicConstantVisibilityRector;
280603e565SAndreas Gohruse Rector\Php71\Rector\FuncCall\CountOnNullRector;
29077b7fe2SAndreas Gohruse Rector\Set\ValueObject\LevelSetList;
30077b7fe2SAndreas Gohruse Rector\Set\ValueObject\SetList;
31077b7fe2SAndreas Gohruse Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
32104a3b7cSAndreas Gohruse Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
33077b7fe2SAndreas Gohr
34077b7fe2SAndreas Gohrreturn static function (RectorConfig $rectorConfig): void {
351490c177SAndreas Gohr    define('DOKU_INC', __DIR__ . '/../');
361490c177SAndreas Gohr
37077b7fe2SAndreas Gohr    $rectorConfig->paths([
38077b7fe2SAndreas Gohr        __DIR__ . '/../inc',
39077b7fe2SAndreas Gohr        __DIR__ . '/../lib',
40077b7fe2SAndreas Gohr    ]);
41077b7fe2SAndreas Gohr
421490c177SAndreas Gohr    $rectorConfig->bootstrapFiles([
431490c177SAndreas Gohr        __DIR__ . '/../inc/load.php',
441490c177SAndreas Gohr    ]);
451490c177SAndreas Gohr
46077b7fe2SAndreas Gohr    $rectorConfig->importNames();
47077b7fe2SAndreas Gohr    $rectorConfig->importShortClasses(false);
48077b7fe2SAndreas Gohr    $rectorConfig->cacheClass(FileCacheStorage::class);
49077b7fe2SAndreas Gohr    $rectorConfig->cacheDirectory(__DIR__ . '/.rector-cache');
50077b7fe2SAndreas Gohr
51077b7fe2SAndreas Gohr    // define sets of rules
52077b7fe2SAndreas Gohr    $rectorConfig->sets([
53077b7fe2SAndreas Gohr        LevelSetList::UP_TO_PHP_74,
54077b7fe2SAndreas Gohr        SetList::CODE_QUALITY,
55077b7fe2SAndreas Gohr        SetList::DEAD_CODE,
56077b7fe2SAndreas Gohr        SetList::CODING_STYLE,
57077b7fe2SAndreas Gohr    ]);
58077b7fe2SAndreas Gohr
59077b7fe2SAndreas Gohr    $rectorConfig->skip([
60077b7fe2SAndreas Gohr        // skip paths
61077b7fe2SAndreas Gohr        __DIR__ . '/../inc/lang/*',
62077b7fe2SAndreas Gohr        __DIR__ . '/../lib/plugins/*/_test/*',
63077b7fe2SAndreas Gohr        __DIR__ . '/../lib/tpl/*/_test/*',
64077b7fe2SAndreas Gohr        __DIR__ . '/../lib/plugins/*/lang/*',
65077b7fe2SAndreas Gohr        __DIR__ . '/../lib/tpl/*/lang/*',
66077b7fe2SAndreas Gohr        __DIR__ . '/../lib/plugins/*/vendor/*',
67077b7fe2SAndreas Gohr        __DIR__ . '/../lib/tpl/*/vendor/*',
68077b7fe2SAndreas Gohr        __DIR__ . '/../lib/plugins/*/skel/*', // dev plugin
69077b7fe2SAndreas Gohr
70077b7fe2SAndreas Gohr        // third party libs, not yet moved to composer
71077b7fe2SAndreas Gohr        __DIR__ . '/../inc/DifferenceEngine.php',
72077b7fe2SAndreas Gohr        __DIR__ . '/../inc/JpegMeta.php',
73077b7fe2SAndreas Gohr        __DIR__ . '/../lib/plugins/authad/adLDAP',
74077b7fe2SAndreas Gohr
75077b7fe2SAndreas Gohr        // skip rules
76077b7fe2SAndreas Gohr        SimplifyIfElseToTernaryRector::class,
77077b7fe2SAndreas Gohr        NewlineAfterStatementRector::class,
78077b7fe2SAndreas Gohr        CombineIfRector::class,
79077b7fe2SAndreas Gohr        ExplicitBoolCompareRector::class,
80077b7fe2SAndreas Gohr        IssetOnPropertyObjectToPropertyExistsRector::class, // maybe?
81077b7fe2SAndreas Gohr        SymplifyQuoteEscapeRector::class,
82077b7fe2SAndreas Gohr        CatchExceptionNameMatchingTypeRector::class,
83077b7fe2SAndreas Gohr        PublicConstantVisibilityRector::class, // open for discussion
84077b7fe2SAndreas Gohr        EncapsedStringsToSprintfRector::class,
85077b7fe2SAndreas Gohr        CallableThisArrayToAnonymousFunctionRector::class,
86077b7fe2SAndreas Gohr        StaticClosureRector::class,
87077b7fe2SAndreas Gohr        SimplifyUselessVariableRector::class, // seems to strip constructor property initializations
88077b7fe2SAndreas Gohr        PostIncDecToPreIncDecRector::class,
89077b7fe2SAndreas Gohr        RemoveUselessParamTagRector::class,
90077b7fe2SAndreas Gohr        DisallowedEmptyRuleFixerRector::class,
910603e565SAndreas Gohr        CountOnNullRector::class, // adds unwanted is_countable checks?
926723156fSAndreas Gohr        RemoveParentCallWithoutParentRector::class,
936723156fSAndreas Gohr        WrapEncapsedVariableInCurlyBracesRector::class,
941490c177SAndreas Gohr        SimplifyIfReturnBoolRector::class,
95a469bafbSAndreas Gohr        StrictArraySearchRector::class, // we cannot assume strict search is always wanted
96104a3b7cSAndreas Gohr        AddArrayDefaultToArrayPropertyRector::class, // may break code differentiating between null and empty array
97104a3b7cSAndreas Gohr        RemoveUselessVarTagRector::class,
98104a3b7cSAndreas Gohr        TypedPropertyFromAssignsRector::class, // maybe?
99*e2d055f5SAndreas Gohr        JoinStringConcatRector::class, // this does not count variables, so it creates overlong lines
100077b7fe2SAndreas Gohr    ]);
101077b7fe2SAndreas Gohr};
102