-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrector.php
More file actions
64 lines (54 loc) · 2 KB
/
rector.php
File metadata and controls
64 lines (54 loc) · 2 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
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use Rector\ValueObject\PhpVersion;
// Optional: add Laravel set if driftingly/rector-laravel is installed
use RectorLaravel\Set\LaravelSetList;
return static function (RectorConfig $rectorConfig): void {
// Paths to refactor
$rectorConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);
// Target PHP version (helps Rector choose appropriate rules)
if (class_exists(\Rector\ValueObject\PhpVersion::class)) {
$rectorConfig->phpVersion(PhpVersion::PHP_84);
}
// Core sets to enable - a broad, safe set of automated fixes:
$sets = [
LevelSetList::UP_TO_PHP_84, // use rules for PHP 8.4 features & migrations
SetList::CODE_QUALITY,
SetList::CODING_STYLE,
SetList::DEAD_CODE,
SetList::TYPE_DECLARATION,
SetList::EARLY_RETURN,
SetList::NAMING,
SetList::PRIVATIZATION,
];
// If the Laravel set package is installed, add Laravel-specific sets
if (class_exists(LaravelSetList::class)) {
// Add whichever Laravel sets the package exposes; LARAVEL_110 is commonly provided
if (defined(LaravelSetList::class . '::LARAVEL_110')) {
$sets[] = LaravelSetList::LARAVEL_110;
}
// some driftingly versions also expose LARAVEL_CODE_QUALITY etc; add if present:
if (defined(LaravelSetList::class . '::LARAVEL_CODE_QUALITY')) {
$sets[] = LaravelSetList::LARAVEL_CODE_QUALITY;
}
}
$rectorConfig->sets($sets);
// Autoload vendor (helps Rector find Laravel classes, etc.)
$rectorConfig->autoloadPaths([
__DIR__ . '/vendor/autoload.php',
]);
// Skip vendor & other noisy dirs
$rectorConfig->skip([
__DIR__ . '/vendor',
__DIR__ . '/storage',
__DIR__ . '/node_modules',
]);
// Cache dir
$rectorConfig->cacheDirectory(__DIR__ . '/.rector/cache');
};