-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrector.php
More file actions
69 lines (67 loc) · 2.38 KB
/
rector.php
File metadata and controls
69 lines (67 loc) · 2.38 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
<?php
use Rector\Config\RectorConfig;
use Rector\Naming\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector;
use Rector\Naming\Rector\Class_\RenamePropertyToMatchTypeRector;
use Rector\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector;
use Rector\Naming\Rector\ClassMethod\RenameVariableToMatchNewTypeRector;
use Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector;
return RectorConfig::configure()
->withPreparedSets(
deadCode: true,
codingStyle: true,
typeDeclarations: true,
typeDeclarationDocblocks: true,
privatization: true,
naming: true,
instanceOf: true,
earlyReturn: true,
carbon: false, // No services use Carbon
rectorPreset: true,
phpunitCodeQuality: true,
doctrineCodeQuality: false, // No service use Doctrine
symfonyCodeQuality: true,
symfonyConfigs: true
)
->withComposerBased(
twig: true,
doctrine: false, // No service use Doctrine
phpunit: true,
symfony: true,
netteUtils: false, // No service use Nette
laravel: false // No service use Laravel
)
->withImportNames(
importNames: true,
importDocBlockNames: true,
importShortClasses: true,
removeUnusedImports: true,
)
->withPhpSets()
->withAttributesSets()
->withTreatClassesAsFinal()
->withRules([
/**
* Make sure all overridden methods have the `#[Override]` attribute.
*/
AddOverrideAttributeToOverriddenMethodsRector::class,
])
->withSkip([
/**
* Ignore as, although this is a good pattern in most cases, theres genuine use cases for
* a variable name which _doesn't_ match the type being instantiated.
*
* For example, creating instances of DateTimeImmutables loses a lot of context when
* the variable is renamed to `$dateTimeImmutable`:
* ```php
* $dateTimeImmutable = new DateTimeImmutable();
* ```
* or:
* ```php
* function method(DateTimeImmutable $dateTimeImmutable): void
* ```
*/
RenameVariableToMatchNewTypeRector::class,
RenameParamToMatchTypeRector::class,
RenameVariableToMatchMethodCallReturnTypeRector::class,
RenamePropertyToMatchTypeRector::class
]);