From 3439e4594db29f3fcc53d6c06eea677c3e623b45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 19 Feb 2024 10:10:10 +0100 Subject: [PATCH 1/2] Upgrade to PHPUnit 10 (#393) --- composer.json | 2 +- phpunit.xml.dist | 6 ++---- tests/AbstractLazyArrayCollectionTest.php | 2 +- tests/AbstractLazyCollectionTest.php | 2 +- tests/ArrayCollectionTest.php | 2 +- ...yCollectionTest.php => ArrayCollectionTestCase.php} | 6 +++--- tests/CollectionTest.php | 2 +- .../{BaseCollectionTest.php => CollectionTestCase.php} | 2 +- tests/Expr/CompositeExpressionTest.php | 10 ++++++++-- 9 files changed, 19 insertions(+), 15 deletions(-) rename tests/{BaseArrayCollectionTest.php => ArrayCollectionTestCase.php} (98%) rename tests/{BaseCollectionTest.php => CollectionTestCase.php} (99%) diff --git a/composer.json b/composer.json index b9ef287a..4c36229a 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ "doctrine/coding-standard": "^12", "phpstan/phpstan": "^1.8", "phpstan/phpstan-phpunit": "^1.0", - "phpunit/phpunit": "^9.5", + "phpunit/phpunit": "^10.5", "vimeo/psalm": "^5.11" }, "autoload": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8dacf950..e75d8aeb 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,9 +1,7 @@ - @@ -13,9 +11,9 @@ - + ./src/ - + diff --git a/tests/AbstractLazyArrayCollectionTest.php b/tests/AbstractLazyArrayCollectionTest.php index 28e62cef..d0c0d1c0 100644 --- a/tests/AbstractLazyArrayCollectionTest.php +++ b/tests/AbstractLazyArrayCollectionTest.php @@ -14,7 +14,7 @@ * * @covers \Doctrine\Common\Collections\AbstractLazyCollection */ -class AbstractLazyArrayCollectionTest extends BaseArrayCollectionTest +class AbstractLazyArrayCollectionTest extends ArrayCollectionTestCase { /** * @param mixed[] $elements diff --git a/tests/AbstractLazyCollectionTest.php b/tests/AbstractLazyCollectionTest.php index e30b6969..8f38e238 100644 --- a/tests/AbstractLazyCollectionTest.php +++ b/tests/AbstractLazyCollectionTest.php @@ -16,7 +16,7 @@ * * @covers \Doctrine\Common\Collections\AbstractLazyCollection */ -class AbstractLazyCollectionTest extends BaseCollectionTest +class AbstractLazyCollectionTest extends CollectionTestCase { protected function setUp(): void { diff --git a/tests/ArrayCollectionTest.php b/tests/ArrayCollectionTest.php index bde74f88..f2f7cb88 100644 --- a/tests/ArrayCollectionTest.php +++ b/tests/ArrayCollectionTest.php @@ -20,7 +20,7 @@ * * @covers \Doctrine\Common\Collections\ArrayCollection */ -class ArrayCollectionTest extends BaseArrayCollectionTest +class ArrayCollectionTest extends ArrayCollectionTestCase { /** * @param mixed[] $elements diff --git a/tests/BaseArrayCollectionTest.php b/tests/ArrayCollectionTestCase.php similarity index 98% rename from tests/BaseArrayCollectionTest.php rename to tests/ArrayCollectionTestCase.php index 53fe2252..77732609 100644 --- a/tests/BaseArrayCollectionTest.php +++ b/tests/ArrayCollectionTestCase.php @@ -20,7 +20,7 @@ use function next; use function reset; -abstract class BaseArrayCollectionTest extends TestCase +abstract class ArrayCollectionTestCase extends TestCase { /** * @param mixed[] $elements @@ -183,7 +183,7 @@ public function testIterator(array $elements): void } /** @psalm-return array */ - public function provideDifferentElements(): array + public static function provideDifferentElements(): array { return [ 'indexed' => [[1, 2, 3, 4, 5]], @@ -359,7 +359,7 @@ public function testMatchingWithSlicingPreserveKeys(array $array, array $slicedA } /** @return mixed[][] */ - public function provideSlices(): array + public static function provideSlices(): array { return [ 'preserve numeric keys' => [ diff --git a/tests/CollectionTest.php b/tests/CollectionTest.php index a3115cc6..07e920f3 100644 --- a/tests/CollectionTest.php +++ b/tests/CollectionTest.php @@ -15,7 +15,7 @@ use function count; use function is_string; -class CollectionTest extends BaseCollectionTest +class CollectionTest extends CollectionTestCase { protected function setUp(): void { diff --git a/tests/BaseCollectionTest.php b/tests/CollectionTestCase.php similarity index 99% rename from tests/BaseCollectionTest.php rename to tests/CollectionTestCase.php index 61616359..4dc136b0 100644 --- a/tests/BaseCollectionTest.php +++ b/tests/CollectionTestCase.php @@ -16,7 +16,7 @@ use function is_string; use function sprintf; -abstract class BaseCollectionTest extends TestCase +abstract class CollectionTestCase extends TestCase { /** @var Collection */ protected Collection $collection; diff --git a/tests/Expr/CompositeExpressionTest.php b/tests/Expr/CompositeExpressionTest.php index a5a3d6f9..31b85562 100644 --- a/tests/Expr/CompositeExpressionTest.php +++ b/tests/Expr/CompositeExpressionTest.php @@ -15,12 +15,18 @@ class CompositeExpressionTest extends TestCase { /** @return list}> */ - public function invalidDataProvider(): array + public static function invalidDataProvider(): array { return [ ['type' => CompositeExpression::TYPE_AND, 'expressions' => [new Value('value')]], ['type' => CompositeExpression::TYPE_AND, 'expressions' => ['wrong-type']], - ['type' => CompositeExpression::TYPE_NOT, 'expressions' => [$this->createMock(Expression::class), $this->createMock(Expression::class)]], + [ + 'type' => CompositeExpression::TYPE_NOT, + 'expressions' => [ + self::createStub(Expression::class), + self::createStub(Expression::class), + ], + ], ]; } From 2270a54cdb4fe74f29783e90f43ca92c258ca7a1 Mon Sep 17 00:00:00 2001 From: Gregor Harlan Date: Wed, 21 Feb 2024 17:01:20 +0100 Subject: [PATCH 2/2] reduce method: more accurate types --- src/ReadableCollection.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ReadableCollection.php b/src/ReadableCollection.php index 53d0bf37..a8dbd43f 100644 --- a/src/ReadableCollection.php +++ b/src/ReadableCollection.php @@ -229,11 +229,11 @@ public function findFirst(Closure $p); * Applies iteratively the given function to each element in the collection, * so as to reduce the collection to a single value. * - * @psalm-param Closure(TReturn|TInitial|null, T):(TInitial|TReturn) $func - * @psalm-param TInitial|null $initial + * @psalm-param Closure(TReturn|TInitial, T):TReturn $func + * @psalm-param TInitial $initial * * @return mixed - * @psalm-return TReturn|TInitial|null + * @psalm-return TReturn|TInitial * * @psalm-template TReturn * @psalm-template TInitial