Skip to content

Commit 3941aa8

Browse files
committed
Typehint against Stream (fixes #5)
Fixes compatibility with react/stream:0.4 which removed the StreamInterface.
1 parent aabc226 commit 3941aa8

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

src/Client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Clue\React\Ami\Protocol\Event;
66
use Clue\React\Ami\Protocol\Action;
77
use Evenement\EventEmitter;
8-
use React\Stream\StreamInterface;
8+
use React\Stream\Stream;
99
use Clue\React\Ami\Protocol\Parser;
1010
use React\Promise\Deferred;
1111
use Exception;
@@ -20,7 +20,7 @@ class Client extends EventEmitter
2020
private $pending = array();
2121
private $ending = false;
2222

23-
public function __construct(StreamInterface $stream, Parser $parser = null)
23+
public function __construct(Stream $stream, Parser $parser = null)
2424
{
2525
if ($parser === null) {
2626
$parser = new Parser();

tests/ClientTest.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
use React\Stream\Stream;
44
use Clue\React\Ami\Protocol\Parser;
55
use Clue\React\Ami\Client;
6-
use React\Stream\ThroughStream;
6+
use React\EventLoop\Factory;
77

88
class ClientTest extends TestCase
99
{
1010
public function testClosingStreamClosesClient()
1111
{
12-
$stream = new ThroughStream();
12+
$stream = $this->createStreamMock();
1313

1414
$client = new Client($stream);
1515

@@ -21,7 +21,7 @@ public function testClosingStreamClosesClient()
2121

2222
public function testParserExceptionForwardsErrorAndClosesClient()
2323
{
24-
$stream = new ThroughStream();
24+
$stream = $this->createStreamMock();
2525
$parser = new Parser();
2626

2727
$client = new Client($stream, $parser);
@@ -31,4 +31,9 @@ public function testParserExceptionForwardsErrorAndClosesClient()
3131

3232
$stream->emit('data', array("invalid chunk\r\n\r\ninvalid chunk\r\n\r\n"));
3333
}
34+
35+
private function createStreamMock()
36+
{
37+
return new Stream(fopen('php://memory', 'r+'), $this->getMock('React\EventLoop\LoopInterface'));
38+
}
3439
}

0 commit comments

Comments
 (0)