Merge branch 'minor-next' into feat/async-events

This commit is contained in:
Dylan K. Taylor 2024-11-13 14:57:03 +00:00
commit b82d47dd32
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -69,16 +69,17 @@ final class Promise{
* *
* @phpstan-template TPromiseValue * @phpstan-template TPromiseValue
* @phpstan-template TKey of array-key * @phpstan-template TKey of array-key
* @phpstan-param non-empty-array<TKey, Promise<TPromiseValue>> $promises * @phpstan-param array<TKey, Promise<TPromiseValue>> $promises
* *
* @phpstan-return Promise<array<TKey, TPromiseValue>> * @phpstan-return Promise<array<TKey, TPromiseValue>>
*/ */
public static function all(array $promises) : Promise{ public static function all(array $promises) : Promise{
if(count($promises) === 0){
throw new \InvalidArgumentException("At least one promise must be provided");
}
/** @phpstan-var PromiseResolver<array<TKey, TPromiseValue>> $resolver */ /** @phpstan-var PromiseResolver<array<TKey, TPromiseValue>> $resolver */
$resolver = new PromiseResolver(); $resolver = new PromiseResolver();
if(count($promises) === 0){
$resolver->resolve([]);
return $resolver->getPromise();
}
$values = []; $values = [];
$toResolve = count($promises); $toResolve = count($promises);
$continue = true; $continue = true;