-
-
Notifications
You must be signed in to change notification settings - Fork 150
Closed
Labels
Milestone
Description
Hi I ran into an strange issue and am wondering is this intended behavior?
Basically I'm expecting that for the included code the output would be:
.Array
(
[0] => 1
[1] => 2
[2] => 3
)
But instead I'm getting the array keys unordered:
.Array
(
[0] => 1
[2] => 3
[1] => 2
)
Which causes problems for example when json_encoding (PHP thinks it should be encoded as an object not an array).
Code to reproduce:
$loop = Factory::create();
$testData = [
new Promise(
function ($resolve) use ($loop) {
$loop->nextTick(
function () use ($resolve) {
$resolve(1);
}
);
}
),
new Promise(
function ($resolve) use ($loop) {
$loop->nextTick(
function () use ($resolve, $loop) {
\React\Promise\resolve()->then( function() use ($resolve, $loop) {
$loop->nextTick(function () use ($resolve) {
$resolve(2);
});
});
}
);
}
),
new Promise(
function ($resolve) use ($loop) {
$loop->nextTick(
function () use ($resolve) {
$resolve(3);
}
);
}
)
];
\React\Promise\all($testData)->then(function ($result) {
print_r($result);
});
$loop->run();Thanks!