Skip to content

Commit

Permalink
Update to require Promise v3
Browse files Browse the repository at this point in the history
  • Loading branch information
clue committed Dec 21, 2023
1 parent cfd3e05 commit 434a4bf
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 15 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
3 changes: 0 additions & 3 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ parameters:
- src/
- tests/

reportUnmatchedIgnoredErrors: false
ignoreErrors:
# ignore generic usage like `PromiseInterface<T>` 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::.+\(\)\.$/'
2 changes: 0 additions & 2 deletions src/Io/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public function createClient(string $uri): PromiseInterface
unset($parts['path']);
}

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

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

Expand Down
1 change: 0 additions & 1 deletion src/RedisClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ public function close(): void
// ignore to avoid reporting unhandled rejection
});
if ($this->promise !== null) {
assert(\method_exists($this->promise, 'cancel'));
$this->promise->cancel();
$this->promise = null;
}
Expand Down
3 changes: 0 additions & 3 deletions tests/Io/FactoryStreamingClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,6 @@ public function testCancelWillRejectPromise(): void

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

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

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

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

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

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

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

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

$promise->then(null, $this->expectCallableOnceWith(
Expand Down
9 changes: 4 additions & 5 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}

Expand Down

0 comments on commit 434a4bf

Please sign in to comment.