2828 * resolved to.
2929 *
3030 * Once the promise is rejected, this will throw whatever the promise rejected
31- * with. If the promise did not reject with an `Exception` or `Throwable` (PHP 7+),
32- * then this function will throw an `UnexpectedValueException` instead.
31+ * with. If the promise did not reject with an `Exception` or `Throwable`, then
32+ * this function will throw an `UnexpectedValueException` instead.
3333 *
3434 * ```php
3535 * try {
4545 * @param PromiseInterface $promise
4646 * @return mixed returns whatever the promise resolves to
4747 * @throws \Exception when the promise is rejected with an `Exception`
48- * @throws \Throwable when the promise is rejected with a `Throwable` (PHP 7+)
48+ * @throws \Throwable when the promise is rejected with a `Throwable`
4949 * @throws \UnexpectedValueException when the promise is rejected with an unexpected value (Promise API v1 or v2 only)
5050 */
5151function await (PromiseInterface $ promise )
@@ -79,7 +79,7 @@ function ($error) use (&$exception, &$rejected, &$wait) {
7979
8080 if ($ rejected ) {
8181 // promise is rejected with an unexpected value (Promise API v1 or v2 only)
82- if (!$ exception instanceof \Exception && ! $ exception instanceof \ Throwable) {
82+ if (!$ exception instanceof \Throwable) {
8383 $ exception = new \UnexpectedValueException (
8484 'Promise rejected with unexpected value of type ' . (is_object ($ exception ) ? get_class ($ exception ) : gettype ($ exception ))
8585 );
@@ -95,18 +95,18 @@ function ($error) use (&$exception, &$rejected, &$wait) {
9595 * @param array<callable():PromiseInterface<mixed,Exception>> $tasks
9696 * @return PromiseInterface<array<mixed>,Exception>
9797 */
98- function parallel (array $ tasks )
98+ function parallel (array $ tasks ): PromiseInterface
9999{
100- $ pending = array () ;
100+ $ pending = [] ;
101101 $ deferred = new Deferred (function () use (&$ pending ) {
102102 foreach ($ pending as $ promise ) {
103103 if ($ promise instanceof CancellablePromiseInterface) {
104104 $ promise ->cancel ();
105105 }
106106 }
107- $ pending = array () ;
107+ $ pending = [] ;
108108 });
109- $ results = array () ;
109+ $ results = [] ;
110110 $ errored = false ;
111111
112112 $ numTasks = count ($ tasks );
@@ -123,7 +123,7 @@ function parallel(array $tasks)
123123 $ promise ->cancel ();
124124 }
125125 }
126- $ pending = array () ;
126+ $ pending = [] ;
127127 };
128128
129129 foreach ($ tasks as $ i => $ task ) {
@@ -153,7 +153,7 @@ function parallel(array $tasks)
153153 * @param array<callable():PromiseInterface<mixed,Exception>> $tasks
154154 * @return PromiseInterface<array<mixed>,Exception>
155155 */
156- function series (array $ tasks )
156+ function series (array $ tasks ): PromiseInterface
157157{
158158 $ pending = null ;
159159 $ deferred = new Deferred (function () use (&$ pending ) {
@@ -162,7 +162,7 @@ function series(array $tasks)
162162 }
163163 $ pending = null ;
164164 });
165- $ results = array () ;
165+ $ results = [] ;
166166
167167 /** @var callable():void $next */
168168 $ taskCallback = function ($ result ) use (&$ results , &$ next ) {
@@ -193,7 +193,7 @@ function series(array $tasks)
193193 * @param array<callable(mixed=):PromiseInterface<mixed,Exception>> $tasks
194194 * @return PromiseInterface<mixed,Exception>
195195 */
196- function waterfall (array $ tasks )
196+ function waterfall (array $ tasks ): PromiseInterface
197197{
198198 $ pending = null ;
199199 $ deferred = new Deferred (function () use (&$ pending ) {
0 commit comments