Skip to content

Commit def15d7

Browse files
committed
Update to require Promise v3
1 parent cfd3e05 commit def15d7

File tree

6 files changed

+6
-15
lines changed

6 files changed

+6
-15
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"clue/redis-protocol": "0.3.*",
1616
"evenement/evenement": "^3.0 || ^2.0 || ^1.0",
1717
"react/event-loop": "^1.2",
18-
"react/promise": "^3 || ^2.0 || ^1.1",
18+
"react/promise": "^3",
1919
"react/promise-timer": "^1.10",
2020
"react/socket": "^1.15"
2121
},

phpstan.neon.dist

-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ parameters:
66
- src/
77
- tests/
88

9-
reportUnmatchedIgnoredErrors: false
109
ignoreErrors:
11-
# ignore generic usage like `PromiseInterface<T>` for Promise v2/v1
12-
- '/^PHPDoc tag @return contains generic type React\\Promise\\PromiseInterface<.+> but interface React\\Promise\\PromiseInterface is not generic\.$/'
1310
# ignore undefined methods due to magic `__call()` method
1411
- '/^Call to an undefined method Clue\\React\\Redis\\RedisClient::.+\(\)\.$/'
1512
- '/^Call to an undefined method Clue\\React\\Redis\\Io\\StreamingClient::.+\(\)\.$/'

src/Io/Factory.php

-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ public function createClient(string $uri): PromiseInterface
8080
unset($parts['path']);
8181
}
8282

83-
/** @var PromiseInterface<ConnectionInterface> $connecting */
8483
$connecting = $this->connector->connect($authority);
8584

8685
$deferred = new Deferred(function ($_, $reject) use ($connecting, $uri) {
@@ -96,7 +95,6 @@ public function createClient(string $uri): PromiseInterface
9695
}, function () {
9796
// ignore to avoid reporting unhandled rejection
9897
});
99-
assert(\method_exists($connecting, 'cancel'));
10098
$connecting->cancel();
10199
});
102100

src/RedisClient.php

-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ public function close(): void
229229
// ignore to avoid reporting unhandled rejection
230230
});
231231
if ($this->promise !== null) {
232-
assert(\method_exists($this->promise, 'cancel'));
233232
$this->promise->cancel();
234233
$this->promise = null;
235234
}

tests/Io/FactoryStreamingClientTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,6 @@ public function testCancelWillRejectPromise(): void
459459

460460
$promise = $this->factory->createClient('redis://127.0.0.1:2');
461461

462-
assert(method_exists($promise, 'cancel'));
463462
$promise->cancel();
464463

465464
$promise->then(null, $this->expectCallableOnceWith($this->isInstanceOf(\RuntimeException::class)));
@@ -542,7 +541,6 @@ public function testCancelWillRejectWithUriInMessageAndCancelConnectorWhenConnec
542541

543542
$promise = $this->factory->createClient($uri);
544543

545-
assert(method_exists($promise, 'cancel'));
546544
$promise->cancel();
547545

548546
$promise->then(null, $this->expectCallableOnceWith(
@@ -568,7 +566,6 @@ public function testCancelWillCloseConnectionWhenConnectionWaitsForSelect(): voi
568566

569567
$promise = $this->factory->createClient('redis://127.0.0.1:2/123');
570568

571-
assert(method_exists($promise, 'cancel'));
572569
$promise->cancel();
573570

574571
$promise->then(null, $this->expectCallableOnceWith(

tests/TestCase.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Clue\Tests\React\Redis;
44

5-
use PHPUnit\Framework\MockObject\MockBuilder;
65
use PHPUnit\Framework\MockObject\MockObject;
76
use PHPUnit\Framework\TestCase as BaseTestCase;
87
use React\Promise\PromiseInterface;
@@ -39,12 +38,13 @@ protected function expectCallableNever(): callable
3938

4039
protected function createCallableMock(): MockObject
4140
{
42-
if (method_exists(MockBuilder::class, 'addMethods')) {
43-
// @phpstan-ignore-next-line requires PHPUnit 9+
44-
return $this->getMockBuilder(\stdClass::class)->addMethods(['__invoke'])->getMock();
41+
$builder = $this->getMockBuilder(\stdClass::class);
42+
if (method_exists($builder, 'addMethods')) {
43+
// PHPUnit 9+
44+
return $builder->addMethods(['__invoke'])->getMock();
4545
} else {
4646
// legacy PHPUnit < 9
47-
return $this->getMockBuilder(\stdClass::class)->setMethods(['__invoke'])->getMock();
47+
return $builder->setMethods(['__invoke'])->getMock();
4848
}
4949
}
5050

0 commit comments

Comments
 (0)