aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/event/lib/Promise
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2019-11-10 12:49:51 +0000
committerMario <mario@mariovavti.com>2019-11-10 14:10:03 +0100
commit580c3f4ffe9608d2beb56d418c68b3b112420e76 (patch)
tree82335d01179ac361d3f547a4b8e8c598d302e9f3 /vendor/sabre/event/lib/Promise
parentd22766f458a8539a40a57f3946459a9be1f21cd6 (diff)
downloadvolse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.gz
volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.bz2
volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.zip
another bulk of composer updates
(cherry picked from commit 6685381fd8db507493c3d7c1793f8c05c681bbce)
Diffstat (limited to 'vendor/sabre/event/lib/Promise')
-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);