forked from chamilo/chamilo-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rector.php
105 lines (89 loc) · 5.42 KB
/
rector.php
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);
use Rector\Core\Configuration\Option;
use Rector\Doctrine\Set\DoctrineSetList;
use Rector\Php74\Rector\Property\TypedPropertyRector;
use Rector\Set\ValueObject\SetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
// get parameters
$parameters = $containerConfigurator->parameters();
// paths to refactor; solid alternative to CLI arguments
$parameters->set(Option::PATHS, [
__DIR__.'/src',
]);
// Define what rule sets will be applied
$parameters->set(Option::SETS, [
//SetList::DEAD_CODE,
SetList::CODING_STYLE,
SetList::CODE_QUALITY,
SetList::PHP_74,
DoctrineSetList::DOCTRINE_CODE_QUALITY,
]);
// register single rule
$services = $containerConfigurator->services();
$services->set(TypedPropertyRector::class);
$services->set(\Rector\TypeDeclaration\Rector\Property\PropertyTypeDeclarationRector::class);
$services->set(\Rector\TypeDeclaration\Rector\FunctionLike\ParamTypeDeclarationRector::class);
$services->set(\Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector::class);
//$services->set(\Rector\CakePHP\Rector\FileWithoutNamespace\ImplicitShortClassNameUseStatementRector::class);
$services->set(\PhpCsFixer\Fixer\Import\GlobalNamespaceImportFixer::class);
$services->set(\PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer::class);
$services->set(Rector\CodeQuality\Rector\LogicalAnd\LogicalToBooleanRector::class);
$services->set(\Rector\Php52\Rector\Property\VarToPublicPropertyRector::class);
//$services->set(\Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector::class);
//$services->set(Rector\DoctrineCodeQuality\Rector\ClassMethod\MakeEntitySetterNullabilityInSyncWithPropertyRector::class);
//$services->set(\Rector\DoctrineCodeQuality\Rector\Property\CorrectDefaultTypesOnEntityPropertyRector::class);
//$services->set(\Rector\DoctrineCodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector::class);
//$services->set(\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedParameterRector::class, false);
$services->set(\PhpCsFixer\Fixer\Import\OrderedImportsFixer::class);
/*$parameters->set(
Option::SYMFONY_CONTAINER_XML_PATH_PARAMETER,
__DIR__ . '/var/cache/dev/Chamilo_KernelDevDebugContainer.xml'
);*/
$parameters->set(
Option::SKIP,
[
__DIR__.'/public/*',
__DIR__.'/src/CoreBundle/Component/Editor/*',
__DIR__.'/src/CourseBundle/Component/CourseCopy/*',
__DIR__.'/src/CoreBundle/Component/HTMLPurifier/*',
__DIR__.'/src/LtiBundle/*',
__DIR__.'/src/CoreBundle/Hook/*',
__DIR__.'/src/CoreBundle/Migrations/*',
__DIR__.'/src/CoreBundle/Twig/SettingsHelper.php',
__DIR__.'/src/CoreBundle/Settings/*',
//__DIR__.'/src/CoreBundle/Controller/ResourceApiController.php',
//__DIR__.'/src/CoreBundle/Controller/EditorController.php',
__DIR__.'/src/CoreBundle/Component/Editor/*',
//\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedParameterRector::class,
\PhpCsFixer\Fixer\FunctionNotation\UseArrowFunctionsFixer::class,
\Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector::class,
\Rector\CodeQuality\Rector\ClassMethod\DateTimeToDateTimeInterfaceRector::class,
\Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector::class,
\Rector\Doctrine\Rector\Property\CorrectDefaultTypesOnEntityPropertyRector::class,
Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector::class,
\Rector\Doctrine\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector::class,
\Rector\Doctrine\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector::class,
\Rector\Doctrine\Rector\Class_\MoveCurrentDateTimeDefaultInEntityToConstructorRector::class,
Rector\CodingStyle\Rector\Switch_\BinarySwitchToIfElseRector::class,
Rector\CodingStyle\Rector\ClassConst\VarConstantCommentRector::class,
Rector\CodingStyle\Rector\String_\SplitStringClassConstantToClassConstFetchRector::class,
Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector::class,
Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector::class,
Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector::class,
Rector\CodingStyle\Rector\Assign\SplitDoubleAssignRector::class,
Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector::class,
Rector\CodingStyle\Rector\Use_\RemoveUnusedAliasRector::class,
\Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector::class,
Rector\Php74\Rector\Property\TypedPropertyRector::class,
Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class,
]
);
$parameters->set(Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_74);
//$parameters->set(Option::AUTO_IMPORT_NAMES, true);
// get services (needed for register a single rule)
// $services = $containerConfigurator->services();
// register a single rule
// $services->set(TypedPropertyRector::class);
};