Skip to content

Commit f261a32

Browse files
committed
Update rector config
1 parent ae0a21d commit f261a32

File tree

2 files changed

+28
-51
lines changed

2 files changed

+28
-51
lines changed

benchmarks/Utils/QueryGenerator.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class QueryGenerator
2121

2222
private int $maxLeafFields;
2323

24-
private int $currentLeafFields;
24+
private int $currentLeafFields = 0;
2525

2626
public function __construct(Schema $schema, float $percentOfLeafFields)
2727
{
@@ -32,12 +32,11 @@ public function __construct(Schema $schema, float $percentOfLeafFields)
3232
$totalFields = 0;
3333
foreach ($schema->getTypeMap() as $type) {
3434
if ($type instanceof ObjectType) {
35-
$totalFields += \count($type->getFieldNames());
35+
$totalFields += count($type->getFieldNames());
3636
}
3737
}
3838

39-
$this->maxLeafFields = \max(1, (int) \round($totalFields * $percentOfLeafFields));
40-
$this->currentLeafFields = 0;
39+
$this->maxLeafFields = max(1, (int) round($totalFields * $percentOfLeafFields));
4140
}
4241

4342
public function buildQuery(): string

rector.php

Lines changed: 25 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,40 @@
11
<?php declare(strict_types=1);
22

3-
use Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector;
4-
use Rector\CodeQuality\Rector\ClassMethod\LocallyCalledStaticMethodToNonStaticRector;
5-
use Rector\CodeQuality\Rector\Concat\JoinStringConcatRector;
6-
use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector;
7-
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
8-
use Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector;
9-
use Rector\CodeQuality\Rector\Switch_\SwitchTrueToIfRector;
10-
use Rector\Config\RectorConfig;
11-
use Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector;
12-
use Rector\DeadCode\Rector\If_\RemoveDeadInstanceOfRector;
13-
use Rector\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector;
14-
use Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector;
15-
use Rector\PHPUnit\CodeQuality\Rector\Class_\AddSeeTestAnnotationRector;
16-
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector;
17-
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertEqualsToSameRector;
18-
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertIssetToSpecificMethodRector;
19-
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertPropertyExistsRector;
20-
use Rector\PHPUnit\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector;
21-
use Rector\PHPUnit\Set\PHPUnitSetList;
22-
use Rector\Set\ValueObject\SetList;
23-
24-
return static function (RectorConfig $rectorConfig): void {
3+
return static function (Rector\Config\RectorConfig $rectorConfig): void {
254
$rectorConfig->sets([
26-
SetList::CODE_QUALITY,
27-
SetList::DEAD_CODE,
28-
PHPUnitSetList::PHPUNIT_60,
29-
PHPUnitSetList::PHPUNIT_70,
30-
PHPUnitSetList::PHPUNIT_80,
31-
PHPUnitSetList::PHPUNIT_90,
32-
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
5+
Rector\Set\ValueObject\SetList::CODE_QUALITY,
6+
Rector\Set\ValueObject\SetList::DEAD_CODE,
7+
Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_60,
8+
Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_70,
9+
Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_80,
10+
Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_90,
11+
Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_CODE_QUALITY,
3312
]);
3413
$rectorConfig->skip([
35-
AddSeeTestAnnotationRector::class, // We do not bundle tests, so referring to them is confusing for library users
36-
PreferPHPUnitThisCallRector::class, // Prefer self::
37-
AddDoesNotPerformAssertionToNonAssertingTestRector::class, // False-positive
38-
CallableThisArrayToAnonymousFunctionRector::class, // Callable in array form is shorter and more efficient
39-
IssetOnPropertyObjectToPropertyExistsRector::class, // isset() is nice when moving towards typed properties
40-
FlipTypeControlToUseExclusiveTypeRector::class, // Unnecessarily complex with PHPStan
41-
JoinStringConcatRector::class => [
42-
__DIR__ . '/tests',
14+
Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector::class, // Prefer self::
15+
Rector\PHPUnit\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector::class, // False-positive
16+
Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector::class, // isset() is nice when moving towards typed properties
17+
Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector::class, // Unnecessarily complex with PHPStan
18+
Rector\CodeQuality\Rector\Concat\JoinStringConcatRector::class => [
19+
__DIR__ . '/tests', // Sometimes more readable for long strings
4320
],
44-
LocallyCalledStaticMethodToNonStaticRector::class, // static methods are fine
45-
UnusedForeachValueToArrayKeysRector::class, // Less efficient
46-
RemoveAlwaysTrueIfConditionRector::class, // Sometimes necessary to prove runtime behaviour matches defined types
47-
RemoveDeadInstanceOfRector::class, // Sometimes necessary to prove runtime behaviour matches defined types
48-
RemoveNonExistingVarAnnotationRector::class, // Sometimes false-positive
49-
RemoveUnusedPrivatePropertyRector::class, // TODO reintroduce when https://github.com/rectorphp/rector-src/pull/4491 is released
50-
AssertPropertyExistsRector::class, // Uses deprecated PHPUnit methods
51-
AssertIssetToSpecificMethodRector::class => [
21+
Rector\CodeQuality\Rector\ClassMethod\LocallyCalledStaticMethodToNonStaticRector::class, // static methods are fine
22+
Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector::class, // Less efficient
23+
Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector::class, // Sometimes necessary to prove runtime behaviour matches defined types
24+
Rector\DeadCode\Rector\If_\RemoveDeadInstanceOfRector::class, // Sometimes necessary to prove runtime behaviour matches defined types
25+
Rector\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector::class, // Sometimes false-positive
26+
Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector::class, // TODO reintroduce when https://github.com/rectorphp/rector-src/pull/4491 is released
27+
Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertPropertyExistsRector::class, // Uses deprecated PHPUnit methods
28+
Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertIssetToSpecificMethodRector::class => [
5229
__DIR__ . '/tests/Utils/MixedStoreTest.php', // Uses keys that are not string or int
5330
],
54-
AssertEqualsToSameRector::class => [
31+
Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertEqualsToSameRector::class => [
5532
__DIR__ . '/tests/TestCaseBase.php', // Array output may differ between tested PHP versions, assertEquals smooths over this
5633
],
57-
SwitchTrueToIfRector::class, // More expressive in some cases
34+
Rector\CodeQuality\Rector\Switch_\SwitchTrueToIfRector::class, // More expressive in some cases
5835
]);
5936
$rectorConfig->paths([
37+
__DIR__ . '/benchmarks',
6038
__DIR__ . '/examples',
6139
__DIR__ . '/phpstan',
6240
__DIR__ . '/src',

0 commit comments

Comments
 (0)