forked from topwire/topwire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrector.php
More file actions
84 lines (69 loc) · 3.52 KB
/
rector.php
File metadata and controls
84 lines (69 loc) · 3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
declare(strict_types=1);
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector;
use Ssch\TYPO3Rector\FileProcessor\TypoScript\Rector\v9\v0\FileIncludeToImportStatementTypoScriptRector;
use Ssch\TYPO3Rector\Rector\General\ConvertImplicitVariablesToExplicitGlobalsRector;
use Ssch\TYPO3Rector\Rector\General\ExtEmConfRector;
use Ssch\TYPO3Rector\Set\Typo3LevelSetList;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->sets([
Typo3LevelSetList::UP_TO_TYPO3_12,
LevelSetList::UP_TO_PHP_81,
SetList::CODE_QUALITY,
SetList::TYPE_DECLARATION,
SetList::DEAD_CODE,
SetList::EARLY_RETURN,
]);
// Ensure file system caching is used instead of in-memory.
$rectorConfig->cacheClass(FileCacheStorage::class);
// Specify a path that works locally as well as on CI job runners.
$rectorConfig->cacheDirectory('var/rector');
// In order to have a better analysis from phpstan we teach it here some more things
$rectorConfig->phpstanConfig(__DIR__ . '/phpstan.neon');
// FQN classes are not imported by default. If you don't do it manually after every Rector run, enable it by:
$rectorConfig->importNames();
$rectorConfig->parallel();
// this will not import root namespace classes, like \DateTime or \Exception
$rectorConfig->importShortClasses(\false);
// Define your target version which you want to support
$rectorConfig->phpVersion(PhpVersion::PHP_74);
$rectorConfig->paths([
__DIR__ . '/rector.php',
__DIR__ . '/Classes/',
]);
// If you use the option --config change __DIR__ to getcwd()
$rectorConfig->skip([
// We skip those directories on purpose as there might be node_modules or similar
// that include typescript which would result in false positive processing
__DIR__ . '/**/node_modules/*',
__DIR__ . '/**/Resources/**/build/*',
__DIR__ . '/**/vendor/*',
__DIR__ . '/.build',
__DIR__ . '/vendor',
__DIR__ . '/node_modules',
AddLiteralSeparatorToNumberRector::class,
ChangeAndIfToEarlyReturnRector::class,
AddMethodCallBasedStrictParamTypeRector::class,
]);
/**
* Useful rule from RectorPHP itself to transform i.e. GeneralUtility::makeInstance('TYPO3\CMS\Core\Log\LogManager')
* to GeneralUtility::makeInstance(\TYPO3\CMS\Core\Log\LogManager::class) calls.
* But be warned, sometimes it produces false positives (edge cases), so watch out
*/
$rectorConfig->rule(StringClassNameToClassConstantRector::class);
// Optional non-php file functionalities:
// @see https://github.com/sabbelasichon/typo3-rector/blob/main/docs/beyond_php_file_processors.md
// Add some general TYPO3 rules
$rectorConfig->rule(ConvertImplicitVariablesToExplicitGlobalsRector::class);
$rectorConfig->rule(ExtEmConfRector::class);
// Do you want to modernize your TypoScript include statements for files and move from <INCLUDE /> to @import use the FileIncludeToImportStatementVisitor
$rectorConfig->rule(FileIncludeToImportStatementTypoScriptRector::class);
};