diff --git a/rector.php b/rector.php index bc3abe7bd..dc7d989e9 100644 --- a/rector.php +++ b/rector.php @@ -11,8 +11,6 @@ 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 => [ @@ -20,10 +18,13 @@ ], 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 @@ -31,7 +32,7 @@ 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', diff --git a/tests/Executor/Promise/SyncPromiseTest.php b/tests/Executor/Promise/SyncPromiseTest.php index 9a35c0fd0..4fd830466 100644 --- a/tests/Executor/Promise/SyncPromiseTest.php +++ b/tests/Executor/Promise/SyncPromiseTest.php @@ -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); diff --git a/tests/Language/PrinterTest.php b/tests/Language/PrinterTest.php index af9d9ff59..480e24322 100644 --- a/tests/Language/PrinterTest.php +++ b/tests/Language/PrinterTest.php @@ -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) ); } diff --git a/tests/Type/DefinitionTest.php b/tests/Type/DefinitionTest.php index c68265afb..eac861927 100644 --- a/tests/Type/DefinitionTest.php +++ b/tests/Type/DefinitionTest.php @@ -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); @@ -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); } /** diff --git a/tests/Type/LazyDefinitionTest.php b/tests/Type/LazyDefinitionTest.php index f2efa1367..0150085ca 100644 --- a/tests/Type/LazyDefinitionTest.php +++ b/tests/Type/LazyDefinitionTest.php @@ -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()); }