-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrector.php
More file actions
76 lines (67 loc) · 2.72 KB
/
rector.php
File metadata and controls
76 lines (67 loc) · 2.72 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
<?php
declare(strict_types=1);
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
use Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector;
use Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector;
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
use Rector\CodingStyle\Rector\Stmt\RemoveUselessAliasInUseStatementRector;
use Rector\CodingStyle\Rector\Use_\SeparateMultiUseImportsRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNewArrayRector;
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector;
use Rector\ValueObject\PhpVersion;
use RectorLaravel\Rector\ClassMethod\ScopeNamedClassMethodToScopeAttributedClassMethodRector;
use RectorLaravel\Rector\MethodCall\ValidationRuleArrayStringValueToArrayRector;
use RectorLaravel\Set\LaravelLevelSetList;
use RectorLaravel\Set\LaravelSetList;
return static function (RectorConfig $rectorConfig): void {
// Paths to analyze
$rectorConfig->paths([
__DIR__.'/app',
__DIR__.'/config',
__DIR__.'/database',
__DIR__.'/resources',
__DIR__.'/routes',
__DIR__.'/tests',
]);
// Skip rules for specific paths to prevent breaking Laravel's magic
$rectorConfig->skip([
//
]);
// Enable caching for Rector
$rectorConfig->cacheDirectory(__DIR__.'/storage/rector');
$rectorConfig->cacheClass(FileCacheStorage::class);
// Import Rector sets for Laravel and general code quality
$rectorConfig->importNames();
// Define the Rector rules to apply
$rectorConfig->rules([
DeclareStrictTypesRector::class,
CompactToVariablesRector::class,
ValidationRuleArrayStringValueToArrayRector::class,
ScopeNamedClassMethodToScopeAttributedClassMethodRector::class,
SeparateMultiUseImportsRector::class,
RemoveUselessAliasInUseStatementRector::class,
NewlineAfterStatementRector::class,
CatchExceptionNameMatchingTypeRector::class,
ReturnTypeFromStrictNewArrayRector::class,
]);
// Apply sets for Laravel and general code quality
$rectorConfig->sets([
LaravelLevelSetList::UP_TO_LARAVEL_120,
LaravelSetList::LARAVEL_COLLECTION,
LaravelSetList::LARAVEL_CODE_QUALITY,
LevelSetList::UP_TO_PHP_83,
SetList::DEAD_CODE,
SetList::TYPE_DECLARATION,
SetList::PRIVATIZATION,
SetList::EARLY_RETURN,
SetList::PHP_83,
SetList::INSTANCEOF,
SetList::CODING_STYLE,
SetList::CODE_QUALITY,
]);
// Define PHP version for Rector
$rectorConfig->phpVersion(PhpVersion::PHP_83);
};