Skip to content
Prev Previous commit
Fixing phpdoc, rename getError to getException
  • Loading branch information
joelwurtz committed Nov 4, 2015
commit 55b159fe639e627d0824f13fde536009f4ad440f
19 changes: 10 additions & 9 deletions src/Promise.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ interface Promise
* The callback will be called when the response or exception arrived and never more than once.
*
* @param callable $onFulfilled Called when a response will be available.
* @param callable $onRejected Called when an error happens.
* @param callable $onRejected Called when an error happens.
*
* You must always return the Response in the interface or throw an Exception.
*
Expand All @@ -56,27 +56,28 @@ public function getState();
/**
* Return the value of the promise (fulfilled).
*
* @throws \LogicException When the promise is not fulfilled.
*
* @return ResponseInterface Response Object only when the Promise is fulfilled.
*
* @throws \LogicException When the promise is not fulfilled.
*/
public function getResponse();

/**
* Return the reason of the promise (rejected).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Return the reason why the promise was rejected."?

and we could mention that if this exception is a HttpException, it will contain the Response object with the error status code inside. (in the hope that people will be less confused when trying to figure out how to get to that information)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think about the wording "Get the reason why the promise was rejected." ?

*
* @throws \LogicException When the promise is not rejected.
*
* @return Exception Exception Object only when the Promise is rejected.
*
* If the exception is an instance of Http\Client\Exception\HttpException it will contain
* the response object with the status code and the http reason.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this should go above the @return line

*
* @throws \LogicException When the promise is not rejected.
*/
public function getError();
public function getException();

/**
* Wait for the promise to be fulfilled or rejected.
*
* This function does not return a result, it simply wait for response or error
* of the request to be available, change the state of the promise and call one
* of the then callable.
* When this method returns, the request has been resolved and the appropriate callable has terminated.
*/
public function wait();
}