Skip to content

Commit

Permalink
Update rector config and apply rector
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia committed Dec 19, 2024
1 parent fa01712 commit 5f1eda3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
7 changes: 4 additions & 3 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,28 @@
Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_CODE_QUALITY,
]);
$rectorConfig->skip([
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
],
Rector\CodeQuality\Rector\ClassMethod\LocallyCalledStaticMethodToNonStaticRector::class, // static methods are fine
Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector::class, // Less efficient
Rector\CodeQuality\Rector\Switch_\SwitchTrueToIfRector::class, // More expressive in some cases
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\Class_\NarrowUnusedSetUpDefinedPropertyRector::class, // Sometimes nicer for symmetry
Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector::class, // Prefer self::
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
],
Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertEqualsToSameRector::class => [
__DIR__ . '/tests/TestCaseBase.php', // Array output may differ between tested PHP versions, assertEquals smooths over this
],
Rector\CodeQuality\Rector\Switch_\SwitchTrueToIfRector::class, // More expressive in some cases
Rector\PHPUnit\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector::class, // False-positive
]);
$rectorConfig->paths([
__DIR__ . '/benchmarks',
Expand Down
18 changes: 9 additions & 9 deletions tests/Executor/Promise/SyncPromiseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,23 +389,23 @@ public function testPendingPromiseThen(): void
$nextPromise3 = $promise->then($onFulfilled, $onRejected);
$nextPromise4 = $promise->then($onFulfilled, $onRejected);

self::assertSame(SyncPromise::getQueue()->count(), 0);
self::assertSame($onFulfilledCount, 0);
self::assertSame($onRejectedCount, 0);
self::assertCount(0, SyncPromise::getQueue());
self::assertSame(0, $onFulfilledCount);
self::assertSame(0, $onRejectedCount);
$promise->resolve(1);

self::assertSame(SyncPromise::getQueue()->count(), 4);
self::assertSame($onFulfilledCount, 0); // @phpstan-ignore-line side-effects
self::assertSame($onRejectedCount, 0); // @phpstan-ignore-line side-effects
self::assertCount(4, SyncPromise::getQueue());
self::assertSame(0, $onFulfilledCount); // @phpstan-ignore-line side-effects
self::assertSame(0, $onRejectedCount); // @phpstan-ignore-line side-effects
self::assertSame(SyncPromise::PENDING, $nextPromise->state);
self::assertSame(SyncPromise::PENDING, $nextPromise2->state);
self::assertSame(SyncPromise::PENDING, $nextPromise3->state);
self::assertSame(SyncPromise::PENDING, $nextPromise4->state);

SyncPromise::runQueue();
self::assertSame(SyncPromise::getQueue()->count(), 0);
self::assertSame($onFulfilledCount, 3); // @phpstan-ignore-line side-effects
self::assertSame($onRejectedCount, 0); // @phpstan-ignore-line side-effects
self::assertCount(0, SyncPromise::getQueue());
self::assertSame(3, $onFulfilledCount); // @phpstan-ignore-line side-effects
self::assertSame(0, $onRejectedCount); // @phpstan-ignore-line side-effects
self::assertValidPromise($nextPromise, 1, null, SyncPromise::FULFILLED);
self::assertValidPromise($nextPromise2, 1, null, SyncPromise::FULFILLED);
self::assertValidPromise($nextPromise3, 2, null, SyncPromise::FULFILLED);
Expand Down
4 changes: 2 additions & 2 deletions tests/Language/PrinterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ public function testExperimentalCorrectlyPrintsFragmentDefinedVariables(): void
);

self::assertSame(
Printer::doPrint($fragmentWithVariable),
<<<'GRAPHQL'
fragment Foo($a: ComplexType, $b: Boolean = false) on TestType {
id
}

GRAPHQL
GRAPHQL,
Printer::doPrint($fragmentWithVariable)
);
}

Expand Down
8 changes: 4 additions & 4 deletions tests/Type/DefinitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ public function testDefinesAQueryOnlySchema(): void
self::assertSame($blogSchema->getQueryType(), $this->blogQuery);

$articleField = $this->blogQuery->getField('article');
self::assertSame($articleField->name, 'article');
self::assertSame('article', $articleField->name);

$articleFieldType = $articleField->getType();
self::assertInstanceOf(ObjectType::class, $articleFieldType);
self::assertSame($articleFieldType, $this->blogArticle);
self::assertSame($articleFieldType->name, 'Article');
self::assertSame('Article', $articleFieldType->name);

$titleField = $articleFieldType->getField('title');
self::assertSame('title', $titleField->name);
Expand Down Expand Up @@ -213,8 +213,8 @@ public function testDefinesSubscriptionSchema(): void
$subType = $sub->getType();
self::assertInstanceOf(ObjectType::class, $subType);
self::assertEquals($subType, $this->blogArticle);
self::assertSame($subType->name, 'Article');
self::assertSame($sub->name, 'articleSubscribe');
self::assertSame('Article', $subType->name);
self::assertSame('articleSubscribe', $sub->name);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Type/LazyDefinitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ public function testReturningFieldsUsingYield(): void
self::assertSame($blogSchema->getQueryType(), $type);

$field = $type->getField('url');
self::assertSame($field->name, 'url');
self::assertSame('url', $field->name);
self::assertInstanceOf(StringType::class, $field->getType());

$field = $type->getField('width');
self::assertSame($field->name, 'width');
self::assertSame('width', $field->name);
self::assertInstanceOf(IntType::class, $field->getType());
}

Expand Down

0 comments on commit 5f1eda3

Please sign in to comment.