forked from nuwave/lighthouse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrector.php
67 lines (65 loc) · 3.29 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
<?php declare(strict_types=1);
use Rector\CodeQuality\Rector\Concat\JoinStringConcatRector;
use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector;
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
use Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector;
use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector;
use Rector\CodingStyle\Rector\Closure\StaticClosureRector;
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
use Rector\Config\RectorConfig;
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
use Rector\Php80\Rector\FunctionLike\MixedTypeRector;
use Rector\PHPUnit\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\SetList;
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_60,
PHPUnitSetList::PHPUNIT_80,
PHPUnitSetList::PHPUNIT_90,
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
]);
$rectorConfig->rule(StaticClosureRector::class);
$rectorConfig->skip([
__DIR__ . '/src/Tracing/FederatedTracing/Proto', // Generated code
__DIR__ . '/tests/database/migrations', // Does not fit autoloader standards
__DIR__ . '/tests/LaravelPhpdocAlignmentFixer.php', // Copied from Laravel
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
],
MakeInheritedMethodVisibilitySameAsParentRector::class => [
__DIR__ . '/tests/Unit/Execution/ResolveInfoTest.php', // Makes method public on purpose
],
ExplicitBoolCompareRector::class, // if($truthy) is fine and very readable
EncapsedStringsToSprintfRector::class, // unreadable, slow, error prone
AddReturnTypeDeclarationFromYieldsRector::class, // iterable is fine
UnusedForeachValueToArrayKeysRector::class, // inefficient
AddDoesNotPerformAssertionToNonAssertingTestRector::class, // does not recognize mockResolver
MixedTypeRector::class, // removes useful comments
]);
$rectorConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests',
__DIR__ . '/.php-cs-fixer.php',
__DIR__ . '/_ide_helper.php',
__DIR__ . '/rector.php',
]);
$rectorConfig->phpstanConfig(__DIR__ . '/phpstan.neon');
};