1
0
mirror of https://github.com/danog/amp.git synced 2024-11-30 04:29:08 +01:00

Fix combinator function derps (again)

This commit is contained in:
Daniel Lowrey 2014-12-04 18:08:13 -05:00
parent b93238eb1b
commit b11e7a0fd1

View File

@ -237,9 +237,7 @@ function all(array $promises) {
foreach ($promises as $key => $resolvable) {
if (!$resolvable instanceof Promise) {
$results[$key] = $resolvable;
$remaining--;
continue;
$resolvable = new Success($resolvable);
}
$resolvable->when(function($error, $result) use (&$remaining, &$results, $key, $promisor) {
@ -261,10 +259,6 @@ function all(array $promises) {
});
}
if (empty($remaining)) {
$promisor->succeed($results);
}
// We can return $promisor directly because the Future Promisor implementation
// also implements Promise for convenience
return $promisor;
@ -300,9 +294,7 @@ function some(array $promises) {
foreach ($promises as $key => $resolvable) {
if (!$resolvable instanceof Promise) {
$results[$key] = $resolvable;
$remaining--;
continue;
$resolvable = new Success($resolvable);
}
$resolvable->when(function($error, $result) use (&$remaining, &$results, &$errors, $key, $promisor) {
@ -324,10 +316,6 @@ function some(array $promises) {
});
}
if (empty($remaining)) {
$promisor->succeed([$errors, $results]);
}
// We can return $promisor directly because the Future Promisor implementation
// also implements Promise for convenience
return $promisor;
@ -354,9 +342,7 @@ function any(array $promises) {
foreach ($promises as $key => $resolvable) {
if (!$resolvable instanceof Promise) {
$results[$key] = $resolvable;
$remaining--;
continue;
$resolvable = new Success($resolvable);
}
$resolvable->when(function($error, $result) use (&$remaining, &$results, &$errors, $key, $promisor) {
@ -372,10 +358,6 @@ function any(array $promises) {
});
}
if (empty($remaining)) {
$promisor->succeed([$errors, $results]);
}
// We can return $promisor directly because the Future Promisor implementation
// also implements Promise for convenience
return $promisor;