Skip to content

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

@seregazhuk

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;
    };

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions