MAJ Librarys

This commit is contained in:
EoleDev 2016-03-09 16:03:46 +01:00
parent 1d3ed3af6d
commit 03ef74d0cf
17 changed files with 347 additions and 194 deletions

View file

@ -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();
}
}
}