forked from PGSSoft/HashId
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrector-php81.php
More file actions
71 lines (60 loc) · 2.5 KB
/
rector-php81.php
File metadata and controls
71 lines (60 loc) · 2.5 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
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector;
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector;
use Rector\CodeQuality\Rector\Assign\CombinedAssignRector;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);
$rectorConfig->skip([
// Skip test fixtures and generated files
__DIR__ . '/tests/Fixtures',
__DIR__ . '/tests/Rector/Fixtures',
__DIR__ . '/var',
__DIR__ . '/vendor',
__DIR__ . '/tests/App/cache',
// Skip specific patterns that might need manual attention
ChangeSwitchToMatchRector::class => [
// Skip complex switch statements that might need manual review
__DIR__ . '/src/Service/RouterDecorator.php',
],
ReadOnlyPropertyRector::class => [
// Skip entities that might have Doctrine implications
__DIR__ . '/tests/App/Entity',
],
]);
// PHP 8.0 Features
$rectorConfig->rule(ClassPropertyAssignToConstructorPromotionRector::class);
$rectorConfig->rule(ChangeSwitchToMatchRector::class);
// PHP 8.1 Features
$rectorConfig->rule(ReadOnlyPropertyRector::class);
$rectorConfig->rule(FirstClassCallableRector::class);
// Type Declaration Improvements
$rectorConfig->rule(TypedPropertyFromAssignsRector::class);
$rectorConfig->rule(ReturnTypeFromReturnNewRector::class);
// Code Quality
$rectorConfig->rule(CombinedAssignRector::class);
// Custom HashId-specific rules
$customRulesDir = __DIR__ . '/rector-rules';
if (is_dir($customRulesDir)) {
// Hash annotation to attribute conversion
$hashRuleClass = 'Pgs\\HashIdBundle\\Rector\\HashAnnotationToAttributeRule';
if (class_exists($hashRuleClass)) {
$rectorConfig->rule($hashRuleClass);
}
}
// Performance optimizations
$rectorConfig->parallel();
$rectorConfig->cacheDirectory(__DIR__ . '/var/cache/rector');
$rectorConfig->importNames();
$rectorConfig->removeUnusedImports();
};