-
Notifications
You must be signed in to change notification settings - Fork 53
Fix pending PHPStan errors in PR #233 #234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -10,6 +10,8 @@ | |||
|
||||
/** | ||||
* A deferred allow to return a promise which has not been resolved yet. | ||||
* | ||||
* @implements Promise<ResponseInterface> | ||||
*/ | ||||
final class Deferred implements Promise | ||||
{ | ||||
|
@@ -52,7 +54,9 @@ public function __construct(callable $waitCallback) | |||
} | ||||
|
||||
/** | ||||
* {@inheritdoc} | ||||
* @param callable(ResponseInterface): ResponseInterface|null $onFulfilled | ||||
* @param callable(\Throwable): ResponseInterface|null $onRejected | ||||
* @return Promise<ResponseInterface> | ||||
*/ | ||||
public function then(callable $onFulfilled = null, callable $onRejected = null): Promise | ||||
{ | ||||
|
@@ -86,16 +90,14 @@ public function then(callable $onFulfilled = null, callable $onRejected = null): | |||
return $deferred; | ||||
} | ||||
|
||||
/** | ||||
* {@inheritdoc} | ||||
*/ | ||||
public function getState(): string | ||||
{ | ||||
return $this->state; | ||||
} | ||||
|
||||
/** | ||||
* Resolve this deferred with a Response. | ||||
* @param ResponseInterface $response | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't add phpdoc when it does not add information
Suggested change
|
||||
*/ | ||||
public function resolve(ResponseInterface $response): void | ||||
{ | ||||
|
@@ -129,8 +131,8 @@ public function reject(ClientExceptionInterface $exception): void | |||
} | ||||
|
||||
/** | ||||
* {@inheritdoc} | ||||
*/ | ||||
* {@inheritDoc} | ||||
*/ | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't do inheritdoc when there is nothing else. if there is no docblock, most tools take the docblock of the parent/interface |
||||
public function wait($unwrap = true) | ||||
{ | ||||
if (Promise::PENDING === $this->state) { | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
namespace Http\Client\Common; | ||
|
||
use Http\Client\HttpAsyncClient; | ||
use Http\Promise\Promise; | ||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\RequestInterface; | ||
|
||
/** | ||
|
@@ -20,9 +22,8 @@ trait HttpAsyncClientDecorator | |
protected $httpAsyncClient; | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @see HttpAsyncClient::sendAsyncRequest | ||
* @return Promise<ResponseInterface> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need to fix this in the HttpAsyncClient instead. then it will be inferred for all the various implementations here: |
||
*/ | ||
public function sendAsyncRequest(RequestInterface $request) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,16 +17,13 @@ | |
trait HttpAsyncClientEmulator | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
* | ||
* @see HttpClient::sendRequest | ||
*/ | ||
abstract public function sendRequest(RequestInterface $request): ResponseInterface; | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @see HttpAsyncClient::sendAsyncRequest | ||
* @return \Http\Promise\Promise<ResponseInterface|\Throwable> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add in interface instead |
||
*/ | ||
public function sendAsyncRequest(RequestInterface $request) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
use Http\Client\Common\Exception\HttpClientNotFoundException; | ||
use Http\Client\Common\HttpClientPool as HttpClientPoolInterface; | ||
use Http\Client\HttpAsyncClient; | ||
use Http\Promise\Promise; | ||
use Psr\Http\Client\ClientInterface; | ||
use Psr\Http\Message\RequestInterface; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
@@ -53,16 +54,13 @@ public function addHttpClient($client): void | |
abstract protected function chooseHttpClient(): HttpClientPoolItem; | ||
|
||
/** | ||
* {@inheritdoc} | ||
* @return Promise<ResponseInterface> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not needed when HttpAsyncClient defines the return type |
||
*/ | ||
public function sendAsyncRequest(RequestInterface $request) | ||
{ | ||
return $this->chooseHttpClient()->sendAsyncRequest($request); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function sendRequest(RequestInterface $request): ResponseInterface | ||
{ | ||
return $this->chooseHttpClient()->sendRequest($request); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
use Http\Client\Exception; | ||
use Http\Client\HttpAsyncClient; | ||
use Http\Client\HttpClient; | ||
use Http\Promise\Promise; | ||
use Psr\Http\Client\ClientInterface; | ||
use Psr\Http\Message\RequestInterface; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
@@ -69,9 +70,6 @@ public function __construct($client, int $reenableAfter = null) | |
$this->reenableAfter = $reenableAfter; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function sendRequest(RequestInterface $request): ResponseInterface | ||
{ | ||
if ($this->isDisabled()) { | ||
|
@@ -93,7 +91,7 @@ public function sendRequest(RequestInterface $request): ResponseInterface | |
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* @return Promise<ResponseInterface> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not needed when HttpAsyncClient defines the return type |
||
*/ | ||
public function sendAsyncRequest(RequestInterface $request) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,13 +7,12 @@ | |
use Http\Client\Common\Exception\HttpClientNoMatchException; | ||
use Http\Client\HttpAsyncClient; | ||
use Http\Message\RequestMatcher; | ||
use Http\Promise\Promise; | ||
use Psr\Http\Client\ClientInterface; | ||
use Psr\Http\Message\RequestInterface; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @author Joel Wurtz <[email protected]> | ||
*/ | ||
final class HttpClientRouter implements HttpClientRouterInterface | ||
|
@@ -23,16 +22,13 @@ final class HttpClientRouter implements HttpClientRouterInterface | |
*/ | ||
private $clients = []; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function sendRequest(RequestInterface $request): ResponseInterface | ||
{ | ||
return $this->chooseHttpClient($request)->sendRequest($request); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* @return Promise<ResponseInterface> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not needed when HttpAsyncClient defines the return type |
||
*/ | ||
public function sendAsyncRequest(RequestInterface $request) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should not be necessary with the
@implements
in the class docblock, it should come automatically from the covariant in the interface.