From f573434f6d0f0336beba77241552bf104dffe9e7 Mon Sep 17 00:00:00 2001 From: SonataCI Date: Wed, 27 Sep 2023 16:12:45 +0000 Subject: [PATCH 1/5] DevKit updates --- .php-cs-fixer.dist.php | 2 ++ rector.php | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 72c25056..1afe2e23 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -56,6 +56,8 @@ ]], 'php_unit_strict' => true, 'php_unit_test_case_static_method_calls' => true, + 'php_unit_data_provider_name' => true, + 'php_unit_data_provider_return_type' => true, 'phpdoc_to_comment' => ['ignored_tags' => ['psalm-suppress', 'phpstan-var']], 'single_line_throw' => false, 'static_lambda' => true, diff --git a/rector.php b/rector.php index 6454e91a..74c4dcde 100644 --- a/rector.php +++ b/rector.php @@ -20,6 +20,9 @@ use Rector\Config\RectorConfig; use Rector\Php70\Rector\FunctionLike\ExceptionHandlerTypehintRector; use Rector\Php71\Rector\FuncCall\CountOnNullRector; +use Rector\PHPUnit\CodeQuality\Rector\Class_\AddSeeTestAnnotationRector; +use Rector\PHPUnit\Set\PHPUnitLevelSetList; +use Rector\PHPUnit\Set\PHPUnitSetList; use Rector\Set\ValueObject\LevelSetList; return static function (RectorConfig $rectorConfig): void { @@ -30,6 +33,8 @@ $rectorConfig->sets([ LevelSetList::UP_TO_PHP_80, + PHPUnitLevelSetList::UP_TO_PHPUNIT_90, + PHPUnitSetList::PHPUNIT_CODE_QUALITY, ]); $rectorConfig->importNames(); @@ -37,5 +42,6 @@ $rectorConfig->skip([ CountOnNullRector::class, ExceptionHandlerTypehintRector::class, + AddSeeTestAnnotationRector::class, ]); }; From 3ecaf713c154f02e58e731cfe4d56812ae3947a8 Mon Sep 17 00:00:00 2001 From: SonataCI Date: Thu, 28 Sep 2023 12:12:25 +0000 Subject: [PATCH 2/5] DevKit updates --- rector.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rector.php b/rector.php index 74c4dcde..dd4380e3 100644 --- a/rector.php +++ b/rector.php @@ -21,6 +21,7 @@ use Rector\Php70\Rector\FunctionLike\ExceptionHandlerTypehintRector; use Rector\Php71\Rector\FuncCall\CountOnNullRector; use Rector\PHPUnit\CodeQuality\Rector\Class_\AddSeeTestAnnotationRector; +use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector; use Rector\PHPUnit\Set\PHPUnitLevelSetList; use Rector\PHPUnit\Set\PHPUnitSetList; use Rector\Set\ValueObject\LevelSetList; @@ -43,5 +44,6 @@ CountOnNullRector::class, ExceptionHandlerTypehintRector::class, AddSeeTestAnnotationRector::class, + PreferPHPUnitThisCallRector::class, ]); }; From ae1bd662b65078dfe716092422fabae1febecdaf Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Sat, 14 Oct 2023 11:12:18 +0200 Subject: [PATCH 3/5] Fix --- composer.json | 2 +- tests/Functional/SmokeTest.php | 4 ++-- tests/RelationTest.php | 6 +++--- tests/Utils/SimpleDiffTest.php | 16 +++++++--------- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/composer.json b/composer.json index 1acd1b7b..8e3075b1 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "phpunit/phpunit": "^9.5.13", "psalm/plugin-phpunit": "^0.18", "psalm/plugin-symfony": "^5.0", - "rector/rector": "^0.17", + "rector/rector": "^0.18", "symfony/browser-kit": "^5.4 || ^6.2", "symfony/cache": "^5.4 || ^6.2", "symfony/filesystem": "^5.4 || ^6.2", diff --git a/tests/Functional/SmokeTest.php b/tests/Functional/SmokeTest.php index bb60cfc9..17eee4a8 100644 --- a/tests/Functional/SmokeTest.php +++ b/tests/Functional/SmokeTest.php @@ -21,7 +21,7 @@ final class SmokeTest extends WebTestCase { /** - * @dataProvider provideUrls + * @dataProvider provideSuccessfulResponsesCases */ public function testSuccessfulResponses(string $url): void { @@ -34,7 +34,7 @@ public function testSuccessfulResponses(string $url): void /** * @return iterable */ - public function provideUrls(): iterable + public function provideSuccessfulResponsesCases(): iterable { yield 'index' => ['/audit']; yield 'view revision' => ['/audit/viewrev/1']; diff --git a/tests/RelationTest.php b/tests/RelationTest.php index dfd4082b..cfcf3aa4 100644 --- a/tests/RelationTest.php +++ b/tests/RelationTest.php @@ -928,9 +928,9 @@ public function testOneToManyCollectionDeletedElements(): void $ids[] = $ownedElement->getId(); } - static::assertTrue(\in_array($ownedOne->getId(), $ids, true)); - static::assertTrue(\in_array($ownedThree->getId(), $ids, true)); - static::assertTrue(\in_array($ownedFour->getId(), $ids, true)); + static::assertContains($ownedOne->getId(), $ids); + static::assertContains($ownedThree->getId(), $ids); + static::assertContains($ownedFour->getId(), $ids); } public function testOneToOneEdgeCase(): void diff --git a/tests/Utils/SimpleDiffTest.php b/tests/Utils/SimpleDiffTest.php index 8ca62699..f5be462b 100644 --- a/tests/Utils/SimpleDiffTest.php +++ b/tests/Utils/SimpleDiffTest.php @@ -19,7 +19,7 @@ final class SimpleDiffTest extends TestCase { /** - * @dataProvider dataDiff + * @dataProvider provideDiffCases */ public function testDiff(string $old, string $new, string $output): void { @@ -32,14 +32,12 @@ public function testDiff(string $old, string $new, string $output): void /** * @return iterable */ - public static function dataDiff(): iterable + public static function provideDiffCases(): iterable { - return [ - ['Foo', 'foo', 'Foo foo '], - ['Foo Foo', 'Foo', 'Foo Foo '], - ['Foo', 'Foo Foo', 'Foo Foo '], - ['Foo Bar Baz', 'Foo Foo Foo', 'Foo Bar Baz Foo Foo '], - ['Foo Bar Baz', 'Foo Baz', 'Foo Bar Baz '], - ]; + yield ['Foo', 'foo', 'Foo foo ']; + yield ['Foo Foo', 'Foo', 'Foo Foo ']; + yield ['Foo', 'Foo Foo', 'Foo Foo ']; + yield ['Foo Bar Baz', 'Foo Foo Foo', 'Foo Bar Baz Foo Foo ']; + yield ['Foo Bar Baz', 'Foo Baz', 'Foo Bar Baz ']; } } From babdfb357864e3e032608ea2d9f2fd210fe77e81 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Sat, 14 Oct 2023 11:41:29 +0200 Subject: [PATCH 4/5] fix --- src/Collection/AuditedCollection.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Collection/AuditedCollection.php b/src/Collection/AuditedCollection.php index 539514c2..c0da6ea6 100644 --- a/src/Collection/AuditedCollection.php +++ b/src/Collection/AuditedCollection.php @@ -295,7 +295,6 @@ public function exists(\Closure $p) * * @phpstan-param \Closure(T, int|string):bool $p * @psalm-param \Closure(T=):bool $p - * @phpstan-return ReadableCollection * @psalm-return Collection */ #[\ReturnTypeWillChange] @@ -324,8 +323,9 @@ public function forAll(\Closure $p) * * @phpstan-template U * @phpstan-param \Closure(T):U $func - * @phpstan-return ReadableCollection * @psalm-return Collection + * + * @psalm-suppress ImplementedParamTypeMismatch,InvalidArgument */ #[\ReturnTypeWillChange] public function map(\Closure $func) @@ -339,7 +339,6 @@ public function map(\Closure $func) * @return array> * * @phpstan-param \Closure(TKey, T):bool $p - * @phpstan-return array{0: ReadableCollection, 1: ReadableCollection} * @psalm-return array{0: Collection, 1: Collection} */ #[\ReturnTypeWillChange] From 3961b615f691b1cbe9285400922cdeabed203f97 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Sat, 14 Oct 2023 11:44:41 +0200 Subject: [PATCH 5/5] Fix --- src/Collection/AuditedCollection.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Collection/AuditedCollection.php b/src/Collection/AuditedCollection.php index c0da6ea6..2e483124 100644 --- a/src/Collection/AuditedCollection.php +++ b/src/Collection/AuditedCollection.php @@ -15,7 +15,6 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; -use Doctrine\Common\Collections\ReadableCollection; use Doctrine\ORM\Mapping\ClassMetadataInfo; use SimpleThings\EntityAudit\AuditConfiguration; use SimpleThings\EntityAudit\AuditReader;