mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 14:35:35 +00:00
Merge branch 'minor-next' into feat/async-events
This commit is contained in:
commit
b82d47dd32
@ -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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user