Skip to content

all() function fails when a specified event doesn't pass any data #10

Description

@seregazhuk

Hi!
For all() function the docs say:

The promise will resolve with an array of whatever all events emitted or null if the events do not pass any data.

Here is a simple example. I create a writable stream and then try to collect data from all drain events. These events don't provide any data. As a result the promise should resolve with null:

$writable = new \React\Stream\WritableResourceStream(fopen('php://stdout', 'w'), $loop, 1);
$writable->write('Hello world');
React\Promise\Stream\all($writable, 'drain')->then(function() {
    echo 'drained' . PHP_EOL;
});

But I receive

Notice: Undefined variable: data in vendor/react/promise-stream/src/functions.php on line 129

Looks like in source code for all() function we should add default null value for variable $data?

$bufferer = function ($data = null) use (&$buffer) {
        $buffer []= $data;
    };

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions