summaryrefslogtreecommitdiff
path: root/server/vendor/guzzlehttp/promises/src/Promise.php
diff options
context:
space:
mode:
authormanzerbredes <loic.guegan_secondary@yahoo.fr>2016-03-15 16:17:39 +0100
committermanzerbredes <loic.guegan_secondary@yahoo.fr>2016-03-15 16:17:39 +0100
commit26d10bc0fa4befbac54453228ae1ce89021bdec2 (patch)
tree029d7240ecf7416205e5f76cf9107a6b5bdf8ca3 /server/vendor/guzzlehttp/promises/src/Promise.php
parent8ad216dedf017f3d6de047a25d08db3b98e16361 (diff)
parent03ef74d0cfe675a6e18a91f039182ca1b248d8f5 (diff)
Merge branch 'develop' into loic
Diffstat (limited to 'server/vendor/guzzlehttp/promises/src/Promise.php')
-rw-r--r--server/vendor/guzzlehttp/promises/src/Promise.php27
1 files changed, 14 insertions, 13 deletions
diff --git a/server/vendor/guzzlehttp/promises/src/Promise.php b/server/vendor/guzzlehttp/promises/src/Promise.php
index c2cf969..86820b2 100644
--- a/server/vendor/guzzlehttp/promises/src/Promise.php
+++ b/server/vendor/guzzlehttp/promises/src/Promise.php
@@ -61,17 +61,19 @@ class Promise implements PromiseInterface
{
$this->waitIfPending();
- if (!$unwrap) {
- return null;
- }
+ $inner = $this->result instanceof PromiseInterface
+ ? $this->result->wait($unwrap)
+ : $this->result;
- if ($this->result instanceof PromiseInterface) {
- return $this->result->wait($unwrap);
- } elseif ($this->state === self::FULFILLED) {
- return $this->result;
- } else {
- // It's rejected so "unwrap" and throw an exception.
- throw exception_for($this->result);
+ if ($unwrap) {
+ if ($this->result instanceof PromiseInterface
+ || $this->state === self::FULFILLED
+ ) {
+ return $inner;
+ } else {
+ // It's rejected so "unwrap" and throw an exception.
+ throw exception_for($inner);
+ }
}
}
@@ -257,11 +259,10 @@ class Promise implements PromiseInterface
$this->waitList = null;
foreach ($waitList as $result) {
- descend:
$result->waitIfPending();
- if ($result->result instanceof Promise) {
+ while ($result->result instanceof Promise) {
$result = $result->result;
- goto descend;
+ $result->waitIfPending();
}
}
}