-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrector.php
More file actions
55 lines (46 loc) · 2.11 KB
/
rector.php
File metadata and controls
55 lines (46 loc) · 2.11 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
<?php
declare(strict_types=1);
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
use Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use Rector\Symfony\Set\SymfonyLevelSetList;
use Rector\Symfony\Set\SymfonySetList;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
return static function (RectorConfig $rectorConfig): void {
// Chemins à analyser
$rectorConfig->paths([
__DIR__ . '/src',
]);
// Cache de l'analyse
$rectorConfig->cacheClass(FileCacheStorage::class);
$rectorConfig->cacheDirectory('./var/cache/rector');
// Utilisation de toutes les règles jusqu'à PHP 8.2 ainsi que les règles de Symfony
$rectorConfig->sets([
SetList::DEAD_CODE,
SymfonyLevelSetList::UP_TO_SYMFONY_62,
SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES,
SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION,
LevelSetList::UP_TO_PHP_82,
SymfonySetList::SYMFONY_CODE_QUALITY,
]);
// Mise en place des imports "use Ma\Class\Fqcn;"
$rectorConfig->importNames();
$rectorConfig->ruleWithConfiguration(TypedPropertyFromAssignsRector::class, [
TypedPropertyFromAssignsRector::INLINE_PUBLIC => true,
]);
// Pas d'import des classes de PHP (\DateTime par exemple)
$rectorConfig->importShortClasses(false);
// Move property default from constructor to property default: https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#inlineconstructordefaulttopropertyrector
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
// Règles à ignorer
$rectorConfig->skip([
// Ne pas throw d'exception sur des "json_decode" -> Nécessite des vérifications manuelles
JsonThrowOnErrorRector::class,
// Ne pas utiliser les numeric_literal_separator
AddLiteralSeparatorToNumberRector::class,
]);
};