forked from nuwave/lighthouse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rector.php
74 lines (72 loc) · 3.72 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
<?php declare(strict_types=1);
use Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector;
use Rector\CodeQuality\Rector\Concat\JoinStringConcatRector;
use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector;
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
use Rector\CodeQuality\Rector\Identical\GetClassToInstanceOfRector;
use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
use Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector;
use Rector\CodingStyle\Rector\Class_\AddArrayDefaultToArrayPropertyRector;
use Rector\CodingStyle\Rector\ClassConst\VarConstantCommentRector;
use Rector\CodingStyle\Rector\ClassMethod\UnSpreadOperatorRector;
use Rector\CodingStyle\Rector\Closure\StaticClosureRector;
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
use Rector\Config\RectorConfig;
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\SetList;
use Rector\TypeDeclaration\Rector\ClassMethod\ArrayShapeFromConstantArrayReturnRector;
use Rector\TypeDeclaration\Rector\FunctionLike\AddReturnTypeDeclarationFromYieldsRector;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->sets([
SetList::CODE_QUALITY,
SetList::CODING_STYLE,
SetList::TYPE_DECLARATION,
SetList::PHP_72,
SetList::PHP_73,
SetList::PHP_74,
SetList::PHP_80,
PHPUnitSetList::PHPUNIT_80,
PHPUnitSetList::PHPUNIT_90,
PHPUnitSetList::PHPUNIT_91,
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
PHPUnitSetList::PHPUNIT_EXCEPTION,
PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD,
PHPUnitSetList::PHPUNIT_YIELD_DATA_PROVIDER,
PHPUnitSetList::REMOVE_MOCKS,
]);
$rectorConfig->skip([
__DIR__ . '/tests/database/migrations', // Does not fit autoloading standards
CallableThisArrayToAnonymousFunctionRector::class, // Callable in array form is shorter and more efficient
IssetOnPropertyObjectToPropertyExistsRector::class, // isset() is nice when moving towards typed properties
FlipTypeControlToUseExclusiveTypeRector::class, // Unnecessarily complex with PHPStan
JoinStringConcatRector::class => [
__DIR__ . '/tests/Integration/OrderBy/OrderByDirectiveTest.php', // Improves clarity
],
RemoveExtraParametersRector::class => [
__DIR__ . '/src/Testing/TestResponseMixin.php', // mixins are weird
],
StaticClosureRector::class => [
__DIR__ . '/src/Testing/TestResponseMixin.php', // Cannot bind an instance to a static closure
],
GetClassToInstanceOfRector::class => [
__DIR__ . '/src/Schema/Types/Scalars/DateScalar.php', // We need to compare exact classes, not subclasses
],
ExplicitBoolCompareRector::class, // if($truthy) is fine and very readable
EncapsedStringsToSprintfRector::class, // unreadable, slow, error prone
VarConstantCommentRector::class, // Noisy
UnSpreadOperatorRector::class, // Breaks some public APIs
AddArrayDefaultToArrayPropertyRector::class, // Break lazy initialization
AddReturnTypeDeclarationFromYieldsRector::class, // iterable is fine
ArrayShapeFromConstantArrayReturnRector::class, // Sometimes too specific in methods that can be overridden
UnusedForeachValueToArrayKeysRector::class, // inefficient
]);
$rectorConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests',
__DIR__ . '/.php-cs-fixer.php',
__DIR__ . '/_ide_helper.php',
__DIR__ . '/rector.php',
]);
$rectorConfig->phpstanConfig(__DIR__ . '/phpstan.neon');
};