Skip to content

Commit

Permalink
Remove getResult()
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Aug 9, 2015
1 parent 325d27e commit 6e79a45
Show file tree
Hide file tree
Showing 12 changed files with 466 additions and 271 deletions.
14 changes: 1 addition & 13 deletions src/Promise/Promise.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,19 +360,7 @@ public function isCancelled()
{
return null !== $this->result ? $this->unwrap()->isCancelled() : false;
}

/**
* {@inheritdoc}
*/
public function getResult()
{
if (null === $this->result) {
throw new UnresolvedError('The promise is still pending.');
}

return $this->unwrap()->getResult();
}


/**
* {@inheritdoc}
*/
Expand Down
39 changes: 15 additions & 24 deletions src/Promise/PromiseInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,21 @@ public function cleanup(callable $onResolved);
* @return \Icicle\Promise\PromiseInterface
*/
public function splat(callable $onFulfilled);


/**
* This function may be used to synchronously wait for a promise to be resolved. This function should generally
* not be used within a running event loop, but rather to set up a task (or set of tasks, then use join() or another
* function to group them) and synchronously wait for the task to complete. Using this function in a running event
* loop will not block the loop, but it will prevent control from moving past the call to this function and disrupt
* program flow.
*
* @return mixed Promise fulfillment value.
*
* @throws \Icicle\Promise\Exception\UnresolvedError If the event loop empties without fulfilling the promise.
* @throws \Exception If the promise is rejected, the rejection reason is thrown from this function.
*/
public function wait();

/**
* Returns true if the promise has not been resolved.
*
Expand Down Expand Up @@ -134,30 +148,7 @@ public function isRejected();
* @return bool
*/
public function isCancelled();

/**
* Returns the value of the fulfilled or rejected promise if it has been resolved.
*
* @return mixed
*
* @throws \Icicle\Promise\Exception\UnresolvedError If the promise has not been resolved.
*/
public function getResult();

/**
* This function may be used to synchronously wait for a promise to be resolved. This function should generally
* not be used within a running event loop, but rather to set up a task (or set of tasks, then use join() or another
* function to group them) and synchronously wait for the task to complete. Using this function in a running event
* loop will not block the loop, but it will prevent control from moving past the call to this function and disrupt
* program flow.
*
* @return mixed Promise fulfillment value.
*
* @throws \Icicle\Promise\Exception\UnresolvedError If the event loop empties without fulfilling the promise.
* @throws \Exception If the promise is rejected, the rejection reason is thrown from this function.
*/
public function wait();

/**
* Iteratively finds the last promise in the pending chain and returns it.
*
Expand Down
8 changes: 0 additions & 8 deletions src/Promise/Structures/CancelledPromise.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,6 @@ public function isCancelled()
return !$this->result->isPending();
}

/**
* {@inheritdoc}
*/
public function getResult()
{
return $this->result->getResult();
}

/**
* {@inheritdoc}
*/
Expand Down
8 changes: 0 additions & 8 deletions src/Promise/Structures/FulfilledPromise.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,6 @@ public function isRejected()
return false;
}

/**
* {@inheritdoc}
*/
public function getResult()
{
return $this->value;
}

/**
* {@inheritdoc}
*/
Expand Down
8 changes: 0 additions & 8 deletions src/Promise/Structures/LazyPromise.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,6 @@ public function isCancelled()
{
return $this->getPromise()->isCancelled();
}

/**
* {@inheritdoc}
*/
public function getResult()
{
return $this->getPromise()->getResult();
}

/**
* {@inheritdoc}
Expand Down
8 changes: 0 additions & 8 deletions src/Promise/Structures/RejectedPromise.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,6 @@ public function isRejected()
return true;
}

/**
* {@inheritdoc}
*/
public function getResult()
{
return $this->exception;
}

/**
* {@inheritdoc}
*/
Expand Down
Loading

0 comments on commit 6e79a45

Please sign in to comment.