Repository navigation
Expand file tree
/
Copy pathrector.php
More file actions
89 lines (86 loc) · 3.67 KB
/
Copy pathrector.php
File metadata and controls
89 lines (86 loc) · 3.67 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
85
86
87
88
89
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use RectorPest\Set\PestSetList;
use RectorLaravel\Set\LaravelSetList;
use RectorPest\Rules\UseToMatchRector;
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
use Rector\Carbon\Rector\FuncCall\DateFuncCallToCarbonRector;
use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector;
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
use Rector\CodeQuality\Rector\BooleanOr\RepeatedOrEqualToInArrayRector;
use Rector\CodeQuality\Rector\ClassMethod\InlineArrayReturnAssignRector;
use Rector\Privatization\Rector\ClassMethod\PrivatizeFinalClassMethodRector;
use Rector\TypeDeclaration\Rector\ArrowFunction\AddArrowFunctionReturnTypeRector;
return RectorConfig::configure()
->withCache(
cacheDirectory: './.cache/rector',
cacheClass: FileCacheStorage::class,
containerCacheDirectory: './.cache/rectorContainer',
)
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->withSkipPath(__DIR__ . '/tests/Fixtures/MacroableFootgun')
->withPreparedSets(
deadCode: true,
codeQuality: true,
codingStyle: true,
typeDeclarations: true,
typeDeclarationDocblocks: true,
privatization: true,
instanceOf: true,
earlyReturn: true,
carbon: true,
rectorPreset: true,
phpunitCodeQuality: true,
)
->withAttributesSets()
->withImportNames()
->withIndent()
->withFluentCallNewLine()
->withParallel(300, 15, 15)
->withMemoryLimit('3G')
->withPhpSets(php84: true)
->withSets([
LaravelSetList::LARAVEL_110,
LaravelSetList::LARAVEL_CODE_QUALITY,
LaravelSetList::LARAVEL_ARRAYACCESS_TO_METHOD_CALL,
LaravelSetList::LARAVEL_CONTAINER_STRING_TO_FULLY_QUALIFIED_NAME,
LaravelSetList::LARAVEL_FACADE_ALIASES_TO_FULL_NAMES,
PestSetList::PEST_CODE_QUALITY,
PestSetList::PEST_CHAIN,
PestSetList::PEST_LARAVEL,
])
->withSkip([
// Pint owns formatting, and it disagrees: Rector rewrites $i++ to ++$i,
// Pint's laravel preset rewrites it straight back. Verified by running
// them in sequence - Rector changed 21 files, Pint reverted every one,
// so the two gates could never both pass. Formatting goes to Pint.
PostIncDecToPreIncDecRector::class,
DateFuncCallToCarbonRector::class,
NullToStrictStringFuncCallArgRector::class,
AddArrowFunctionReturnTypeRector::class,
EncapsedStringsToSprintfRector::class,
ExplicitBoolCompareRector::class,
InlineArrayReturnAssignRector::class,
PrivatizeFinalClassMethodRector::class,
RemoveUselessParamTagRector::class,
RemoveUselessReturnTagRector::class,
// Rewrites expect(preg_match($p, 'x'))->toBe(1) into expect('x')
// ->toMatch($p), but on chained expectations it swaps the head
// subject while leaving ->toBe(1) behind and converts ->and()
// links without changing their subject — both produce failing
// (or nonsensical) assertions. mrpunyapal/rector-pest 0.2.17.
UseToMatchRector::class,
// Hot-path closure allocates a literal array on every invocation
// when in_array() is used. Explicit === comparisons avoid that.
RepeatedOrEqualToInArrayRector::class => [
__DIR__ . '/src/FastCheckCompiler.php',
],
]);