-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrector.php
More file actions
84 lines (66 loc) · 3.13 KB
/
Copy pathrector.php
File metadata and controls
84 lines (66 loc) · 3.13 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
<?php
declare(strict_types=1);
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\SetList;
// Rector rules we intentionally skip (CakePHP-friendly)
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
use Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector;
use Rector\CodingStyle\Rector\Assign\SplitDoubleAssignRector;
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
use Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictFluentReturnRector;
use Rector\TypeDeclaration\Rector\Class_\TypedPropertyFromCreateMockAssignRector;
use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
$cacheDir = getenv('RECTOR_CACHE_DIR') ?: sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'rector';
return RectorConfig::configure()
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
__DIR__ . '/plugins/*/src',
__DIR__ . '/plugins/*/tests',
])
// Use file-based cache for faster runs
->withCache(
cacheClass: FileCacheStorage::class,
cacheDirectory: $cacheDir,
)
// Enable modern PHP syntax and attribute-related improvements
->withPhpSets()
->withAttributesSets()
// Safe and useful Rector sets for CRM/NMS projects
->withSets([
SetList::CODE_QUALITY, // Improve readability and simplify logic
SetList::CODING_STYLE, // Consistent coding style
SetList::DEAD_CODE, // Remove unused code
SetList::EARLY_RETURN, // Replace nested conditions with early returns
SetList::INSTANCEOF, // Modern instanceof usage
SetList::TYPE_DECLARATION, // Add missing type declarations
SetList::PRIVATIZATION, // Safely tighten visibility where possible
])
// Skip rules that are unsafe or undesirable for CakePHP-style projects
->withSkip([
__DIR__ . '/tests/comparisons',
// Do not convert properties to constructor promotion
ClassPropertyAssignToConstructorPromotionRector::class,
// Do not convert closures to arrow functions
ClosureToArrowFunctionRector::class,
// Do not enforce catch variable naming rules
CatchExceptionNameMatchingTypeRector::class,
// Do not split chained assignments
SplitDoubleAssignRector::class,
// Do not enforce blank lines after statements
NewlineAfterStatementRector::class,
// Do not rewrite compact() calls
CompactToVariablesRector::class,
// Do not remove return tags from docblocks
RemoveUselessReturnTagRector::class,
// Do not add strict return types to fluent APIs
ReturnTypeFromStrictFluentReturnRector::class,
// Do not rewrite boolean comparisons
ExplicitBoolCompareRector::class,
// Do not add typed properties for mocks in tests
TypedPropertyFromCreateMockAssignRector::class,
]);