-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrector.php
More file actions
105 lines (101 loc) · 4.87 KB
/
rector.php
File metadata and controls
105 lines (101 loc) · 4.87 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
declare(strict_types=1);
/**
* This file is part of PHPDevsr/Minifyku.
*
* (c) 2025 Denny Septian Panggabean <xamidimura@gmail.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
use Rector\CodeQuality\Rector\Ternary\TernaryEmptyArrayArrayDimFetchToCoalesceRector;
use Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector;
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
use Rector\Config\RectorConfig;
use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector;
use Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector;
use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector;
use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector;
use Rector\Renaming\Rector\ConstFetch\RenameConstantRector;
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
use Rector\TypeDeclaration\Rector\ArrowFunction\AddArrowFunctionReturnTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector;
use Rector\TypeDeclaration\Rector\Closure\AddClosureVoidReturnTypeWhereNoReturnRector;
use Rector\TypeDeclaration\Rector\Closure\ClosureReturnTypeRector;
use Rector\TypeDeclaration\Rector\Empty_\EmptyOnNullableObjectToInstanceOfRector;
use Rector\TypeDeclaration\Rector\Function_\AddFunctionVoidReturnTypeWhereNoReturnRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector;
return RectorConfig::configure()
->withPhpSets(php83: true)
->withPreparedSets(deadCode: true, codeQuality: true, codingStyle: true, instanceOf: true, phpunitCodeQuality: true, typeDeclarations: true, earlyReturn: true)
->withAutoloadPaths([
__DIR__ . '/vendor/autoload.php',
])
->withComposerBased(phpunit: true)
->withParallel(200, 16, 16)
->withCache(
// Github action cache or local
is_dir('/tmp') ? '/tmp/rector' : null,
FileCacheStorage::class,
)
// paths to refactor; solid alternative to CLI arguments
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
])
// do you need to include constants, class aliases or custom autoloader? files listed will be executed
->withBootstrapFiles([
realpath(getcwd()) . '/vendor/codeigniter4/framework/system/Test/bootstrap.php',
])
->withPHPStanConfigs([
__DIR__ . '/phpstan.neon.dist',
__DIR__ . '/vendor/codeigniter/phpstan-codeigniter/extension.neon',
__DIR__ . '/vendor/phpstan/phpstan-strict-rules/rules.neon',
])
// is there a file you need to skip?
->withSkip([
// No need
DeclareStrictTypesRector::class,
EncapsedStringsToSprintfRector::class,
NewlineAfterStatementRector::class,
NewlineBeforeNewAssignSetRector::class,
ChangeOrIfContinueToMultiContinueRector::class,
])
// auto import fully qualified class names
->withImportNames(removeUnusedImports: true)
->withRules([
DeclareStrictTypesRector::class,
SimplifyUselessVariableRector::class,
RemoveAlwaysElseRector::class,
ChangeNestedForeachIfsToEarlyContinueRector::class,
ChangeIfElseValueAssignToEarlyReturnRector::class,
PreparedValueToEarlyReturnRector::class,
SimplifyEmptyCheckOnEmptyArrayRector::class,
TernaryEmptyArrayArrayDimFetchToCoalesceRector::class,
EmptyOnNullableObjectToInstanceOfRector::class,
DisallowedEmptyRuleFixerRector::class,
PrivatizeFinalClassPropertyRector::class,
AddClosureVoidReturnTypeWhereNoReturnRector::class,
AddFunctionVoidReturnTypeWhereNoReturnRector::class,
AddMethodCallBasedStrictParamTypeRector::class,
TypedPropertyFromAssignsRector::class,
ClosureReturnTypeRector::class,
FlipTypeControlToUseExclusiveTypeRector::class,
AddArrowFunctionReturnTypeRector::class,
])
->withConfiguredRule(RenameConstantRector::class, [
'FILTER_DEFAULT' => 'FILTER_UNSAFE_RAW',
])
->withConfiguredRule(StringClassNameToClassConstantRector::class, [
// keep '\\' prefix string on string '\Foo\Bar'
StringClassNameToClassConstantRector::SHOULD_KEEP_PRE_SLASH => true,
]);