Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
},
"require": {
"php": ">=5.3",
"react/stream": "^0.4 || ^0.3",
"react/stream": "^1.0 || ^0.7 || ^0.6 || ^0.5 || ^0.4 || ^0.3",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't include 1.0 here, as 1.0 isn't released yet. Changes could happen that are not planned yet.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything between 0.7 and 1.0 will be bug fixes. Nothing major will change

"react/promise": "^2.1 || ^1.2"
},
"require-dev": {
"react/event-loop": "^0.4 || ^0.3",
"react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3",
"react/promise-timer": "^1.0",
"clue/block-react": "^1.0",
"phpunit/phpunit": "^4.8"
Expand Down
8 changes: 4 additions & 4 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Creates a `Promise` which resolves with the stream data buffer
*
* @param ReadableStreamInterface $stream
* @return CancellablePromiseInterface Promise<string, Exception>
* @return Promise\CancellablePromiseInterface Promise<string, Exception>
*/
function buffer(ReadableStreamInterface $stream)
{
Expand Down Expand Up @@ -53,7 +53,7 @@ function buffer(ReadableStreamInterface $stream)
*
* @param ReadableStreamInterface|WritableStreamInterface $stream
* @param string $event
* @return CancellablePromiseInterface Promise<mixed, Exception>
* @return Promise\CancellablePromiseInterface Promise<mixed, Exception>
*/
function first(EventEmitterInterface $stream, $event = 'data')
{
Expand All @@ -71,7 +71,7 @@ function first(EventEmitterInterface $stream, $event = 'data')
}

return new Promise\Promise(function ($resolve, $reject) use ($stream, $event, &$listener) {
$listener = function ($data) use ($stream, $event, &$listener, $resolve) {
$listener = function ($data = null) use ($stream, $event, &$listener, $resolve) {
$stream->removeListener($event, $listener);
$resolve($data);
};
Expand All @@ -92,7 +92,7 @@ function first(EventEmitterInterface $stream, $event = 'data')
*
* @param ReadableStreamInterface|WritableStreamInterface $stream
* @param string $event
* @return CancellablePromiseInterface Promise<string, Exception>
* @return Promise\CancellablePromiseInterface Promise<string, Exception>
*/
function all(EventEmitterInterface $stream, $event = 'data')
{
Expand Down
21 changes: 10 additions & 11 deletions tests/AllTest.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?php

use React\Promise\Stream;
use React\Stream\ReadableStream;
use React\Stream\WritableStream;
use React\Stream\ThroughStream;

class AllTest extends TestCase
{
public function testClosedStreamResolvesWithEmptyBuffer()
{
$stream = new ReadableStream();
$stream = new ThroughStream();
$stream->close();

$promise = Stream\all($stream);
Expand All @@ -18,7 +17,7 @@ public function testClosedStreamResolvesWithEmptyBuffer()

public function testClosedWritableStreamResolvesWithEmptyBuffer()
{
$stream = new WritableStream();
$stream = new ThroughStream();
$stream->close();

$promise = Stream\all($stream);
Expand All @@ -28,7 +27,7 @@ public function testClosedWritableStreamResolvesWithEmptyBuffer()

public function testPendingStreamWillNotResolve()
{
$stream = new ReadableStream();
$stream = new ThroughStream();

$promise = Stream\all($stream);

Expand All @@ -37,7 +36,7 @@ public function testPendingStreamWillNotResolve()

public function testClosingStreamResolvesWithEmptyBuffer()
{
$stream = new ReadableStream();
$stream = new ThroughStream();
$promise = Stream\all($stream);

$stream->close();
Expand All @@ -47,7 +46,7 @@ public function testClosingStreamResolvesWithEmptyBuffer()

public function testClosingWritableStreamResolvesWithEmptyBuffer()
{
$stream = new WritableStream();
$stream = new ThroughStream();
$promise = Stream\all($stream);

$stream->close();
Expand All @@ -57,7 +56,7 @@ public function testClosingWritableStreamResolvesWithEmptyBuffer()

public function testEmittingDataOnStreamResolvesWithArrayOfData()
{
$stream = new ReadableStream();
$stream = new ThroughStream();
$promise = Stream\all($stream);

$stream->emit('data', array('hello', $stream));
Expand All @@ -69,7 +68,7 @@ public function testEmittingDataOnStreamResolvesWithArrayOfData()

public function testEmittingErrorOnStreamRejects()
{
$stream = new ReadableStream();
$stream = new ThroughStream();
$promise = Stream\all($stream);

$stream->emit('error', array(new \RuntimeException('test')));
Expand All @@ -79,7 +78,7 @@ public function testEmittingErrorOnStreamRejects()

public function testEmittingErrorAfterEmittingDataOnStreamRejects()
{
$stream = new ReadableStream();
$stream = new ThroughStream();
$promise = Stream\all($stream);

$stream->emit('data', array('hello', $stream));
Expand All @@ -90,7 +89,7 @@ public function testEmittingErrorAfterEmittingDataOnStreamRejects()

public function testCancelPendingStreamWillReject()
{
$stream = new ReadableStream();
$stream = new ThroughStream();

$promise = Stream\all($stream);

Expand Down
16 changes: 8 additions & 8 deletions tests/BufferTest.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

use React\Promise\Stream;
use React\Stream\ReadableStream;
use React\Stream\ThroughStream;

class BufferTest extends TestCase
{
public function testClosedStreamResolvesWithEmptyBuffer()
{
$stream = new ReadableStream();
$stream = new ThroughStream();
$stream->close();

$promise = Stream\buffer($stream);
Expand All @@ -17,7 +17,7 @@ public function testClosedStreamResolvesWithEmptyBuffer()

public function testPendingStreamWillNotResolve()
{
$stream = new ReadableStream();
$stream = new ThroughStream();

$promise = Stream\buffer($stream);

Expand All @@ -26,7 +26,7 @@ public function testPendingStreamWillNotResolve()

public function testClosingStreamResolvesWithEmptyBuffer()
{
$stream = new ReadableStream();
$stream = new ThroughStream();
$promise = Stream\buffer($stream);

$stream->close();
Expand All @@ -36,7 +36,7 @@ public function testClosingStreamResolvesWithEmptyBuffer()

public function testEmittingDataOnStreamResolvesWithConcatenatedData()
{
$stream = new ReadableStream();
$stream = new ThroughStream();
$promise = Stream\buffer($stream);

$stream->emit('data', array('hello', $stream));
Expand All @@ -48,7 +48,7 @@ public function testEmittingDataOnStreamResolvesWithConcatenatedData()

public function testEmittingErrorOnStreamRejects()
{
$stream = new ReadableStream();
$stream = new ThroughStream();
$promise = Stream\buffer($stream);

$stream->emit('error', array(new \RuntimeException('test')));
Expand All @@ -58,7 +58,7 @@ public function testEmittingErrorOnStreamRejects()

public function testEmittingErrorAfterEmittingDataOnStreamRejects()
{
$stream = new ReadableStream();
$stream = new ThroughStream();
$promise = Stream\buffer($stream);

$stream->emit('data', array('hello', $stream));
Expand All @@ -69,7 +69,7 @@ public function testEmittingErrorAfterEmittingDataOnStreamRejects()

public function testCancelPendingStreamWillReject()
{
$stream = new ReadableStream();
$stream = new ThroughStream();

$promise = Stream\buffer($stream);

Expand Down
23 changes: 11 additions & 12 deletions tests/FirstTest.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?php

use React\Promise\Stream;
use React\Stream\ReadableStream;
use React\Stream\WritableStream;
use React\Stream\ThroughStream;

class FirstTest extends TestCase
{
public function testClosedReadableStreamRejects()
{
$stream = new ReadableStream();
$stream = new ThroughStream();
$stream->close();

$promise = Stream\first($stream);
Expand All @@ -18,7 +17,7 @@ public function testClosedReadableStreamRejects()

public function testClosedWritableStreamRejects()
{
$stream = new WritableStream();
$stream = new ThroughStream();
$stream->close();

$promise = Stream\first($stream);
Expand All @@ -28,7 +27,7 @@ public function testClosedWritableStreamRejects()

public function testPendingStreamWillNotResolve()
{
$stream = new ReadableStream();
$stream = new ThroughStream();

$promise = Stream\first($stream);

Expand All @@ -37,7 +36,7 @@ public function testPendingStreamWillNotResolve()

public function testClosingStreamRejects()
{
$stream = new ReadableStream();
$stream = new ThroughStream();
$promise = Stream\first($stream);

$stream->close();
Expand All @@ -47,7 +46,7 @@ public function testClosingStreamRejects()

public function testClosingWritableStreamRejects()
{
$stream = new WritableStream();
$stream = new ThroughStream();
$promise = Stream\first($stream);

$stream->close();
Expand All @@ -57,7 +56,7 @@ public function testClosingWritableStreamRejects()

public function testClosingStreamResolvesWhenWaitingForCloseEvent()
{
$stream = new ReadableStream();
$stream = new ThroughStream();
$promise = Stream\first($stream, 'close');

$stream->close();
Expand All @@ -67,7 +66,7 @@ public function testClosingStreamResolvesWhenWaitingForCloseEvent()

public function testEmittingDataOnStreamResolvesWithFirstEvent()
{
$stream = new ReadableStream();
$stream = new ThroughStream();
$promise = Stream\first($stream);

$stream->emit('data', array('hello', $stream));
Expand All @@ -79,7 +78,7 @@ public function testEmittingDataOnStreamResolvesWithFirstEvent()

public function testEmittingErrorOnStreamDoesNothing()
{
$stream = new ReadableStream();
$stream = new ThroughStream();
$promise = Stream\first($stream);

$stream->emit('error', array(new \RuntimeException('test')));
Expand All @@ -89,7 +88,7 @@ public function testEmittingErrorOnStreamDoesNothing()

public function testEmittingErrorResolvesWhenWaitingForErrorEvent()
{
$stream = new ReadableStream();
$stream = new ThroughStream();
$promise = Stream\first($stream, 'error');

$stream->emit('error', array(new \RuntimeException('test')));
Expand All @@ -99,7 +98,7 @@ public function testEmittingErrorResolvesWhenWaitingForErrorEvent()

public function testCancelPendingStreamWillReject()
{
$stream = new ReadableStream();
$stream = new ThroughStream();

$promise = Stream\first($stream);

Expand Down
Loading