aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/event/lib/Promise/functions.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/event/lib/Promise/functions.php')
-rw-r--r--vendor/sabre/event/lib/Promise/functions.php26
1 files changed, 13 insertions, 13 deletions
diff --git a/vendor/sabre/event/lib/Promise/functions.php b/vendor/sabre/event/lib/Promise/functions.php
index 3604b8aaa..275492cbc 100644
--- a/vendor/sabre/event/lib/Promise/functions.php
+++ b/vendor/sabre/event/lib/Promise/functions.php
@@ -1,14 +1,15 @@
-<?php
+<?php declare (strict_types=1);
namespace Sabre\Event\Promise;
use Sabre\Event\Promise;
+use Throwable;
/**
* This file contains a set of functions that are useful for dealing with the
* Promise object.
*
- * @copyright Copyright (C) 2013-2015 fruux GmbH (https://fruux.com/).
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
@@ -27,12 +28,16 @@ use Sabre\Event\Promise;
* fail with the first Promise that fails, and its reason.
*
* @param Promise[] $promises
- * @return Promise
*/
-function all(array $promises) {
+function all(array $promises) : Promise {
return new Promise(function($success, $fail) use ($promises) {
+ if (empty($promises)) {
+ $success([]);
+ return;
+ }
+
$successCount = 0;
$completeResult = [];
@@ -47,7 +52,7 @@ function all(array $promises) {
}
return $result;
}
- )->error(
+ )->otherwise(
function($reason) use ($fail) {
$fail($reason);
}
@@ -66,9 +71,8 @@ function all(array $promises) {
* that first promise.
*
* @param Promise[] $promises
- * @return Promise
*/
-function race(array $promises) {
+function race(array $promises) : Promise {
return new Promise(function($success, $fail) use ($promises) {
@@ -106,9 +110,8 @@ function race(array $promises) {
* promise and eventually get the same state as the followed promise.
*
* @param mixed $value
- * @return Promise
*/
-function resolve($value) {
+function resolve($value) : Promise {
if ($value instanceof Promise) {
return $value->then();
@@ -122,11 +125,8 @@ function resolve($value) {
/**
* Returns a Promise that will reject with the given reason.
- *
- * @param mixed $reason
- * @return Promise
*/
-function reject($reason) {
+function reject(Throwable $reason) : Promise {
$promise = new Promise();
$promise->reject($reason);