From a95911b6c60bda57cac5ec3eaa46e494d73e53c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Mon, 17 Jul 2023 08:42:16 +0200 Subject: [PATCH] Update to require Promise v3 --- composer.json | 2 +- phpstan.neon.dist | 3 --- tests/TestCase.php | 9 ++++----- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 242b91f..335b526 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "clue/redis-protocol": "0.3.*", "evenement/evenement": "^3.0 || ^2.0 || ^1.0", "react/event-loop": "^1.2", - "react/promise": "^3 || ^2.0 || ^1.1", + "react/promise": "^3", "react/promise-timer": "^1.10", "react/socket": "^1.15" }, diff --git a/phpstan.neon.dist b/phpstan.neon.dist index fb725aa..be4a66a 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -6,10 +6,7 @@ parameters: - src/ - tests/ - reportUnmatchedIgnoredErrors: false ignoreErrors: - # ignore generic usage like `PromiseInterface` for Promise v2/v1 - - '/^PHPDoc tag @return contains generic type React\\Promise\\PromiseInterface<.+> but interface React\\Promise\\PromiseInterface is not generic\.$/' # ignore undefined methods due to magic `__call()` method - '/^Call to an undefined method Clue\\React\\Redis\\RedisClient::.+\(\)\.$/' - '/^Call to an undefined method Clue\\React\\Redis\\Io\\StreamingClient::.+\(\)\.$/' diff --git a/tests/TestCase.php b/tests/TestCase.php index 483864d..722c8b6 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,7 +2,6 @@ namespace Clue\Tests\React\Redis; -use PHPUnit\Framework\MockObject\MockBuilder; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase as BaseTestCase; use React\Promise\PromiseInterface; @@ -39,12 +38,12 @@ protected function expectCallableNever(): callable protected function createCallableMock(): MockObject { - if (method_exists(MockBuilder::class, 'addMethods')) { - // @phpstan-ignore-next-line requires PHPUnit 9+ - return $this->getMockBuilder(\stdClass::class)->addMethods(['__invoke'])->getMock(); + $builder = $this->getMockBuilder(\stdClass::class); + if (method_exists($builder, 'addMethods')) { + return $builder->addMethods(['__invoke'])->getMock(); } else { // legacy PHPUnit < 9 - return $this->getMockBuilder(\stdClass::class)->setMethods(['__invoke'])->getMock(); + return $builder->setMethods(['__invoke'])->getMock(); } }