Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve type definition for combinators (any, first, some) #334

Merged
merged 1 commit into from
Jan 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,11 @@ function adapt($promise): Promise
* This function is the same as some() with the notable exception that it will never fail even
* if all promises in the array resolve unsuccessfully.
*
* @param Promise[]|ReactPromise[] $promises
* @template TValue
*
* @return Promise
* @param Promise<TValue>[]|ReactPromise[] $promises
*
* @return Promise<array{0: \Throwable[], 1: TValue[]}>
*
* @throws \Error If a non-Promise is in the array.
*/
Expand Down Expand Up @@ -423,9 +425,11 @@ function all(array $promises): Promise
/**
* Returns a promise that succeeds when the first promise succeeds, and fails only if all promises fail.
*
* @param Promise[]|ReactPromise[] $promises Array of only promises.
* @template TValue
*
* @return Promise
* @param Promise<TValue>[]|ReactPromise[] $promises Array of only promises.
*
* @return Promise<TValue>
*
* @throws \Error If the array is empty or a non-Promise is in the array.
*/
Expand Down Expand Up @@ -475,12 +479,14 @@ function first(array $promises): Promise
* Resolves with a two-item array delineating successful and failed Promise results.
*
* The returned promise will only fail if the given number of required promises fail.
*
* @template TValue
*
* @param Promise[]|ReactPromise[] $promises Array of only promises.
* @param int $required Number of promises that must succeed for the
* @param Promise<TValue>[]|ReactPromise[] $promises Array of only promises.
* @param int $required Number of promises that must succeed for the
* returned promise to succeed.
*
* @return Promise
* @return Promise<array{0: \Throwable[], 1: TValue[]}>
*
* @throws \Error If a non-Promise is in the array.
*/
Expand Down