forked from webonyx/graphql-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rector.php
59 lines (57 loc) · 2.93 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
<?php declare(strict_types=1);
use Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector;
use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector;
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
use Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector;
use Rector\CodeQuality\Rector\Switch_\SwitchTrueToIfRector;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector;
use Rector\DeadCode\Rector\If_\RemoveDeadInstanceOfRector;
use Rector\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector;
use Rector\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector;
use Rector\PHPUnit\Rector\MethodCall\AssertEqualsToSameRector;
use Rector\PHPUnit\Rector\MethodCall\AssertIssetToSpecificMethodRector;
use Rector\PHPUnit\Rector\MethodCall\AssertPropertyExistsRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\SetList;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->sets([
SetList::CODE_QUALITY,
SetList::DEAD_CODE,
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([
AddSeeTestAnnotationRector::class, // We do not bundle tests
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
UnusedForeachValueToArrayKeysRector::class, // Less efficient
RemoveAlwaysTrueIfConditionRector::class, // Sometimes necessary to prove runtime behaviour matches defined types
RemoveDeadInstanceOfRector::class, // Sometimes necessary to prove runtime behaviour matches defined types
RemoveNonExistingVarAnnotationRector::class, // Sometimes false-positive
AssertPropertyExistsRector::class, // Uses deprecated PHPUnit methods
AssertIssetToSpecificMethodRector::class => [
__DIR__ . '/tests/Utils/MixedStoreTest.php', // Uses keys that are not string or int
],
AssertEqualsToSameRector::class => [
__DIR__ . '/tests/TestCaseBase.php',
],
SwitchTrueToIfRector::class, // More expressive in some cases
]);
$rectorConfig->paths([
__DIR__ . '/examples',
__DIR__ . '/phpstan',
__DIR__ . '/src',
__DIR__ . '/tests',
__DIR__ . '/.php-cs-fixer.php',
__DIR__ . '/generate-class-reference.php',
__DIR__ . '/rector.php',
]);
$rectorConfig->phpstanConfig(__DIR__ . '/phpstan.neon');
};