Skip to content

Commit

Permalink
Strict types
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Smetannikov committed Jul 7, 2020
1 parent 5da3e52 commit 354c7cf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/Driver/Auto.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ class Auto extends AbstractDriver
*/
public function request(Request $request): Response
{
return $this->getClient()->request($request);
return static::getClient()->request($request);
}

/**
* @inheritDoc
*/
public function multiRequest(array $requestList): array
{
return $this->getClient()->multiRequest($requestList);
return static::getClient()->multiRequest($requestList);
}

/**
* @return AbstractDriver
*/
protected function getClient(): AbstractDriver
protected static function getClient(): AbstractDriver
{
if (class_exists(Client::class) && method_exists(Client::class, 'request')) {
return new Guzzle();
Expand Down
10 changes: 5 additions & 5 deletions src/Driver/Guzzle.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function request(Request $request): Response
$httpResult = $client->request(
$request->getMethod(),
$request->getUri(),
$this->getDriverOptions(
self::getDriverOptions(
$request->getOptions(),
$request->getHeaders(),
$request->getMethod(),
Expand Down Expand Up @@ -68,7 +68,7 @@ public function multiRequest(array $requestList): array
$promises[$name] = $client->requestAsync(
$request->getMethod(),
$request->getUri(),
$this->getDriverOptions(
self::getDriverOptions(
$request->getOptions(),
$request->getHeaders(),
$request->getMethod(),
Expand Down Expand Up @@ -98,7 +98,7 @@ public function multiRequest(array $requestList): array
* @param string|array|null $args
* @return array
*/
protected function getDriverOptions(Options $options, array $headers, string $method, $args)
protected static function getDriverOptions(Options $options, array $headers, string $method, $args): array
{
$headers['User-Agent'] = $options->getUserAgent('Guzzle');

Expand All @@ -121,15 +121,15 @@ protected function getDriverOptions(Options $options, array $headers, string $me
'verify' => $options->isVerify(),
'exceptions' => $options->allowException(),
'auth' => $options->getAuth(),
'allow_redirects' => $this->getAllowRedirects($options)
'allow_redirects' => self::getAllowRedirects($options)
];
}

/**
* @param Options $options
* @return array|bool
*/
protected function getAllowRedirects(Options $options)
protected static function getAllowRedirects(Options $options)
{
$allowRedirects = false;

Expand Down
7 changes: 3 additions & 4 deletions src/Driver/Rmccue.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function request(Request $request): Response
/** @phan-suppress-next-line PhanPartialTypeMismatchArgument */
$request->getArgs(),
$request->getMethod(),
$this->getDriverOptions($options)
self::getDriverOptions($options)
);

if ($httpResult->status_code >= self::INVALID_CODE_LINE && $options->allowException()) {
Expand All @@ -73,7 +73,7 @@ public function multiRequest(array $requestList): array
'data' => $request->getArgs(),
'type' => $request->getMethod(),
'headers' => $request->getHeaders(),
'options' => $this->getDriverOptions($request->getOptions()),
'options' => self::getDriverOptions($request->getOptions()),
];
}

Expand All @@ -83,7 +83,6 @@ public function multiRequest(array $requestList): array
foreach ($httpResults as $name => $httpResult) {
$result[$name] = (new Response())
->setCode((int)$httpResult->status_code)
/** @phan-suppress-next-line PhanPossiblyNonClassMethodCall */
->setHeaders($httpResult->headers->getAll())
->setBody($httpResult->body)
->setRequest($requestList[$name]);
Expand All @@ -96,7 +95,7 @@ public function multiRequest(array $requestList): array
* @param Options $options
* @return array
*/
protected function getDriverOptions(Options $options)
protected static function getDriverOptions(Options $options): array
{
return [
'timeout' => $options->getTimeout(),
Expand Down
2 changes: 1 addition & 1 deletion src/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function request(
* @param array $options
* @return Response[]
*/
public function multiRequest(array $requestList, array $options = [])
public function multiRequest(array $requestList, array $options = []): array
{
/** @var Request[] $cleanedRequestList */
$cleanedRequestList = [];
Expand Down

0 comments on commit 354c7cf

Please sign in to comment.