-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathrector.php
More file actions
145 lines (123 loc) · 5.52 KB
/
rector.php
File metadata and controls
145 lines (123 loc) · 5.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\ValueObject\PhpVersion;
use Rector\PostRector\Rector\NameImportingPostRector;
use Rector\Set\ValueObject\DowngradeLevelSetList;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use Rector\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector;
use Ssch\TYPO3Rector\Configuration\Typo3Option;
use Ssch\TYPO3Rector\FileProcessor\Composer\Rector\ExtensionComposerRector;
use Ssch\TYPO3Rector\FileProcessor\Composer\Rector\RemoveCmsPackageDirFromExtraComposerRector;
// not found with latest version of ssch/typo3-rector
//use Ssch\TYPO3Rector\FileProcessor\TypoScript\Rector\v10\v0\ExtbasePersistenceTypoScriptRector;
use Ssch\TYPO3Rector\FileProcessor\TypoScript\Rector\v9\v0\FileIncludeToImportStatementTypoScriptRector;
use Ssch\TYPO3Rector\CodeQuality\General\ExtEmConfRector;
use Ssch\TYPO3Rector\Set\Typo3LevelSetList;
/**
* TYPO3 >= v12
* PHP >= 8.1
*
* Use rector:
* composer require ssch/typo3-rector:^2.6 rector/rector:^1.2 --dev
*
*
*/
return static function (RectorConfig $rectorConfig): void {
// If you want to override the number of spaces for your typoscript files you can define it here, the default value is 4
// $parameters = $rectorConfig->parameters();
// $parameters->set(Typo3Option::TYPOSCRIPT_INDENT_SIZE, 2);
$rectorConfig->sets([
SetList::CODE_QUALITY,
SetList::CODING_STYLE,
LevelSetList::UP_TO_PHP_82,
DowngradeLevelSetList::DOWN_TO_PHP_82,
SetList::TYPE_DECLARATION,
Typo3LevelSetList::UP_TO_TYPO3_13,
]);
$rectorConfig->parallel(120, 5);
// Register a single rule. Single rules don't load the main config file, therefore the config file needs to be loaded manually.
// $rectorConfig->import(__DIR__ . '/vendor/ssch/typo3-rector/config/config.php');
// $rectorConfig->rule(\Ssch\TYPO3Rector\Rector\v9\v0\InjectAnnotationRector::class);
// To have a better analysis from phpstan, we teach it here some more things
$rectorConfig->phpstanConfig(Typo3Option::PHPSTAN_FOR_RECTOR_PATH);
// FQN classes are not imported by default. If you don't do it manually after every Rector run, enable it by:
$rectorConfig->importNames();
// Disable parallel otherwise non php file processing is not working i.e. typoscript or flexform
$rectorConfig->disableParallel();
// 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_82);
// If you only want to process one/some TYPO3 extension(s), you can specify its path(s) here.
// If you use the option --config change __DIR__ to getcwd()
$rectorConfig->paths([
getcwd() . '/',
]);
// If you use the option --config change __DIR__ to getcwd()
$rectorConfig->skip([
getcwd() . '/**/Resources/',
// @see https://github.com/sabbelasichon/typo3-rector/issues/2536
getcwd() . '/**/Configuration/ExtensionBuilder/*',
// We skip those directories on purpose as there might be node_modules or similar
// that include typescript which would result in false positive processing
getcwd() . '/**/Resources/**/node_modules/*',
getcwd() . '/**/Resources/**/NodeModules/*',
getcwd() . '/**/Resources/**/BowerComponents/*',
getcwd() . '/**/Resources/**/bower_components/*',
getcwd() . '/**/Resources/**/build/*',
getcwd() . '/vendor/*',
getcwd() . '/Build/*',
getcwd() . '/public/*',
getcwd() . '/.github/*',
getcwd() . '/.Build/*',
NameImportingPostRector::class => [
'ext_localconf.php',
'ext_emconf.php',
'ext_tables.php',
getcwd() . '/**/Configuration/*',
getcwd() . '/**/Configuration/**/*.php',
],
]);
// Optional non-php file functionalities:
// @see https://github.com/sabbelasichon/typo3-rector/blob/main/docs/beyond_php_file_processors.md
// Rewrite your extbase persistence class mapping from typoscript into php according to official docs.
// This processor will create a summarized file with all of the typoscript rewrites combined into a single file.
// The filename can be passed as argument, "Configuration_Extbase_Persistence_Classes.php" is default.
// not found with latest version of ssch/typo3-rector
/*
$rectorConfig->ruleWithConfiguration(
ExtbasePersistenceTypoScriptRector::class,
[
ExtbasePersistenceTypoScriptRector::FILENAME => 'Configuration_Extbase_Persistence_Classes.php',
]
);
*/
// Add some general TYPO3 rules
# $rectorConfig->rule(ConvertImplicitVariablesToExplicitGlobalsRector::class);
$rectorConfig->ruleWithConfiguration(
ExtEmConfRector::class,
[
ExtEmConfRector::TYPO3_VERSION_CONSTRAINT => '13.4.0-13.4.99',
ExtEmConfRector::ADDITIONAL_VALUES_TO_BE_REMOVED => [
'dependencies',
'conflicts',
'suggests',
'private',
'download_password',
'TYPO3_version',
'PHP_version',
'internal',
'module',
'loadOrder',
'lockType',
'shy',
'priority',
'modify_tables',
'CGLcompliance',
'CGLcompliance_note',
],
]
);
};