Skip to content

Commit 2cd2759

Browse files
authored
Merge pull request #517 from cakephp/3.x-rector
add rector
2 parents c9b267d + 61331dd commit 2cd2759

44 files changed

Lines changed: 1098 additions & 1108 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
"stan": "@phpstan",
6363
"stan-baseline": "tools/phpstan --generate-baseline",
6464
"stan-setup": "phive install",
65+
"rector-setup": "cp composer.json composer.backup && composer require --dev rector/rector:\"~2.3.1\" && mv composer.backup composer.json",
66+
"rector-check": "vendor/bin/rector process --dry-run",
67+
"rector-fix": "vendor/bin/rector process",
6568
"test": "phpunit"
6669
}
6770
}

rector.php

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
5+
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
6+
use Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector;
7+
use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
8+
use Rector\CodingStyle\Rector\Assign\SplitDoubleAssignRector;
9+
use Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector;
10+
use Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector;
11+
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
12+
use Rector\Config\RectorConfig;
13+
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector;
14+
use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector;
15+
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
16+
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
17+
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
18+
use Rector\Php80\Rector\Class_\StringableForToStringRector;
19+
use Rector\Set\ValueObject\SetList;
20+
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
21+
use Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByMethodCallTypeRector;
22+
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictFluentReturnRector;
23+
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector;
24+
use Rector\TypeDeclaration\Rector\Function_\AddFunctionVoidReturnTypeWhereNoReturnRector;
25+
26+
$cacheDir = getenv('RECTOR_CACHE_DIR') ?: sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'rector';
27+
28+
return RectorConfig::configure()
29+
->withPaths([
30+
__DIR__ . '/src',
31+
__DIR__ . '/tests',
32+
])
33+
34+
->withCache(
35+
cacheClass: FileCacheStorage::class,
36+
cacheDirectory: $cacheDir,
37+
)
38+
39+
->withPhpSets()
40+
->withAttributesSets()
41+
42+
->withSets([
43+
SetList::CODE_QUALITY,
44+
SetList::CODING_STYLE,
45+
SetList::DEAD_CODE,
46+
SetList::EARLY_RETURN,
47+
SetList::INSTANCEOF,
48+
SetList::TYPE_DECLARATION,
49+
])
50+
51+
->withSkip([
52+
ClassPropertyAssignToConstructorPromotionRector::class,
53+
CatchExceptionNameMatchingTypeRector::class,
54+
ClosureToArrowFunctionRector::class,
55+
RemoveUselessReturnTagRector::class,
56+
ReturnTypeFromStrictFluentReturnRector::class,
57+
NewlineAfterStatementRector::class,
58+
StringClassNameToClassConstantRector::class,
59+
ReturnTypeFromStrictTypedCallRector::class,
60+
ParamTypeByMethodCallTypeRector::class,
61+
AddFunctionVoidReturnTypeWhereNoReturnRector::class,
62+
// StringableForToStringRector::class,
63+
// CompactToVariablesRector::class,
64+
// SplitDoubleAssignRector::class,
65+
// ChangeOrIfContinueToMultiContinueRector::class,
66+
// ExplicitBoolCompareRector::class,
67+
// NewlineBeforeNewAssignSetRector::class,
68+
// SimplifyEmptyCheckOnEmptyArrayRector::class,
69+
// DisallowedEmptyRuleFixerRector::class,
70+
]);

0 commit comments

Comments
 (0)