diff --git a/benchmarks/Utils/QueryGenerator.php b/benchmarks/Utils/QueryGenerator.php index 44c67ed8b..b7b00d0d8 100644 --- a/benchmarks/Utils/QueryGenerator.php +++ b/benchmarks/Utils/QueryGenerator.php @@ -21,7 +21,7 @@ class QueryGenerator private int $maxLeafFields; - private int $currentLeafFields; + private int $currentLeafFields = 0; public function __construct(Schema $schema, float $percentOfLeafFields) { @@ -32,12 +32,11 @@ public function __construct(Schema $schema, float $percentOfLeafFields) $totalFields = 0; foreach ($schema->getTypeMap() as $type) { if ($type instanceof ObjectType) { - $totalFields += \count($type->getFieldNames()); + $totalFields += count($type->getFieldNames()); } } - $this->maxLeafFields = \max(1, (int) \round($totalFields * $percentOfLeafFields)); - $this->currentLeafFields = 0; + $this->maxLeafFields = max(1, (int) round($totalFields * $percentOfLeafFields)); } public function buildQuery(): string diff --git a/rector.php b/rector.php index 230f3474e..bc3abe7bd 100644 --- a/rector.php +++ b/rector.php @@ -1,62 +1,40 @@ sets([ - SetList::CODE_QUALITY, - SetList::DEAD_CODE, - PHPUnitSetList::PHPUNIT_60, - PHPUnitSetList::PHPUNIT_70, - PHPUnitSetList::PHPUNIT_80, - PHPUnitSetList::PHPUNIT_90, - PHPUnitSetList::PHPUNIT_CODE_QUALITY, + Rector\Set\ValueObject\SetList::CODE_QUALITY, + Rector\Set\ValueObject\SetList::DEAD_CODE, + Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_60, + Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_70, + Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_80, + Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_90, + Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_CODE_QUALITY, ]); $rectorConfig->skip([ - AddSeeTestAnnotationRector::class, // We do not bundle tests, so referring to them is confusing for library users - PreferPHPUnitThisCallRector::class, // Prefer self:: - AddDoesNotPerformAssertionToNonAssertingTestRector::class, // False-positive - 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', + Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector::class, // Prefer self:: + Rector\PHPUnit\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector::class, // False-positive + Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector::class, // isset() is nice when moving towards typed properties + Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector::class, // Unnecessarily complex with PHPStan + Rector\CodeQuality\Rector\Concat\JoinStringConcatRector::class => [ + __DIR__ . '/tests', // Sometimes more readable for long strings ], - LocallyCalledStaticMethodToNonStaticRector::class, // static methods are fine - 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 - RemoveUnusedPrivatePropertyRector::class, // TODO reintroduce when https://github.com/rectorphp/rector-src/pull/4491 is released - AssertPropertyExistsRector::class, // Uses deprecated PHPUnit methods - AssertIssetToSpecificMethodRector::class => [ + Rector\CodeQuality\Rector\ClassMethod\LocallyCalledStaticMethodToNonStaticRector::class, // static methods are fine + Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector::class, // Less efficient + Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector::class, // Sometimes necessary to prove runtime behaviour matches defined types + Rector\DeadCode\Rector\If_\RemoveDeadInstanceOfRector::class, // Sometimes necessary to prove runtime behaviour matches defined types + Rector\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector::class, // Sometimes false-positive + Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector::class, // TODO reintroduce when https://github.com/rectorphp/rector-src/pull/4491 is released + Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertPropertyExistsRector::class, // Uses deprecated PHPUnit methods + Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertIssetToSpecificMethodRector::class => [ __DIR__ . '/tests/Utils/MixedStoreTest.php', // Uses keys that are not string or int ], - AssertEqualsToSameRector::class => [ + Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertEqualsToSameRector::class => [ __DIR__ . '/tests/TestCaseBase.php', // Array output may differ between tested PHP versions, assertEquals smooths over this ], - SwitchTrueToIfRector::class, // More expressive in some cases + Rector\CodeQuality\Rector\Switch_\SwitchTrueToIfRector::class, // More expressive in some cases ]); $rectorConfig->paths([ + __DIR__ . '/benchmarks', __DIR__ . '/examples', __DIR__ . '/phpstan', __DIR__ . '/src',