diff options
| author | EoleDev <root@serverpc.home> | 2016-03-09 16:03:46 +0100 |
|---|---|---|
| committer | EoleDev <root@serverpc.home> | 2016-03-09 16:03:46 +0100 |
| commit | 03ef74d0cfe675a6e18a91f039182ca1b248d8f5 (patch) | |
| tree | b1668c59fdbf9cb0b0a3da52bfc79e393a953573 /server/vendor/guzzlehttp/promises/src/Promise.php | |
| parent | 1d3ed3af6d57316640c143002ddf80d61e6c098a (diff) | |
MAJ Librarys
Diffstat (limited to 'server/vendor/guzzlehttp/promises/src/Promise.php')
| -rw-r--r-- | server/vendor/guzzlehttp/promises/src/Promise.php | 27 |
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(); } } } |
