| @@ 207-220 (lines=14) @@ | ||
| 204 | ||
| 205 | foreach ($array as $i=>$promiseOrValue) |
|
| 206 | { |
|
| 207 | $fulfiller = function($val) use($i, &$values, &$toResolve, $toReject, $resolve, $cancellationQueue) { |
|
| 208 | if ($toResolve < 1 || $toReject < 1) |
|
| 209 | { |
|
| 210 | return; |
|
| 211 | } |
|
| 212 | ||
| 213 | $values[$i] = $val; |
|
| 214 | ||
| 215 | if (0 === --$toResolve) |
|
| 216 | { |
|
| 217 | $resolve($values); |
|
| 218 | $cancellationQueue(); |
|
| 219 | } |
|
| 220 | }; |
|
| 221 | ||
| 222 | $rejecter = function($reason) use($i, &$reasons, &$toReject, $toResolve, $reject, $cancellationQueue) { |
|
| 223 | if ($toResolve < 1 || $toReject < 1) |
|
| @@ 222-235 (lines=14) @@ | ||
| 219 | } |
|
| 220 | }; |
|
| 221 | ||
| 222 | $rejecter = function($reason) use($i, &$reasons, &$toReject, $toResolve, $reject, $cancellationQueue) { |
|
| 223 | if ($toResolve < 1 || $toReject < 1) |
|
| 224 | { |
|
| 225 | return; |
|
| 226 | } |
|
| 227 | ||
| 228 | $reasons[$i] = $reason; |
|
| 229 | ||
| 230 | if (0 === --$toReject) |
|
| 231 | { |
|
| 232 | $reject($reasons); |
|
| 233 | $cancellationQueue(); |
|
| 234 | } |
|
| 235 | }; |
|
| 236 | ||
| 237 | $canceller = $cancel; |
|
| 238 | ||