Skip to content

Commit

Permalink
Bump guzzle to 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
denpamusic committed Aug 23, 2020
1 parent aaaa048 commit 578dab8
Show file tree
Hide file tree
Showing 28 changed files with 204 additions and 197 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ php:
- 7.1
- 7.2
- 7.3
- 7.4
- hhvm
- nightly

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
],
"require": {
"php": ">=7.1",
"guzzlehttp/guzzle": "^6.3"
"guzzlehttp/guzzle": "^6.5 | ^7.0"
},
"require-dev": {
"phpunit/phpunit": "^7.0 | ^8.0"
Expand Down
23 changes: 12 additions & 11 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function __destruct()
*
* @return \Denpa\Bitcoin\Config
*/
public function getConfig() : Config
public function getConfig(): Config
{
return $this->config;
}
Expand All @@ -106,7 +106,7 @@ public function getConfig() : Config
*
* @return \GuzzleHttp\ClientInterface
*/
public function getClient() : ClientInterface
public function getClient(): ClientInterface
{
return $this->client;
}
Expand All @@ -118,7 +118,7 @@ public function getClient() : ClientInterface
*
* @return self
*/
public function setClient(ClientInterface $client) : self
public function setClient(ClientInterface $client): self
{
$this->client = $client;

Expand All @@ -132,7 +132,7 @@ public function setClient(ClientInterface $client) : self
*
* @return self
*/
public function wallet(string $name) : self
public function wallet(string $name): self
{
$this->path = "/wallet/$name";

Expand All @@ -147,7 +147,7 @@ public function wallet(string $name) : self
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function request(string $method, ...$params) : ResponseInterface
public function request(string $method, ...$params): ResponseInterface
{
try {
$response = $this->client
Expand Down Expand Up @@ -178,7 +178,8 @@ public function requestAsync(
string $method,
$params = [],
?callable $fulfilled = null,
?callable $rejected = null) : Promise\Promise
?callable $rejected = null
): Promise\Promise
{
$promise = $this->client
->postAsync($this->path, $this->makeJson($method, $params));
Expand All @@ -205,7 +206,7 @@ public function requestAsync(
*
* @return void
*/
public function wait() : void
public function wait(): void
{
if (!empty($this->promises)) {
Promise\settle($this->promises)->wait();
Expand Down Expand Up @@ -234,7 +235,7 @@ public function __call(string $method, array $params = [])
*
* @return string
*/
protected function getConfigProvider() : string
protected function getConfigProvider(): string
{
return 'Denpa\\Bitcoin\\Config';
}
Expand All @@ -244,7 +245,7 @@ protected function getConfigProvider() : string
*
* @return string
*/
protected function getResponseHandler() : string
protected function getResponseHandler(): string
{
return 'Denpa\\Bitcoin\\Responses\\BitcoindResponse';
}
Expand All @@ -254,7 +255,7 @@ protected function getResponseHandler() : string
*
* @return \GuzzleHttp\HandlerStack
*/
protected function getHandler() : HandlerStack
protected function getHandler(): HandlerStack
{
$stack = HandlerStack::create();

Expand All @@ -278,7 +279,7 @@ protected function getHandler() : HandlerStack
*
* @return array
*/
protected function makeJson(string $method, $params = []) : array
protected function makeJson(string $method, $params = []): array
{
return [
'json' => [
Expand Down
13 changes: 7 additions & 6 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

class Config implements \ArrayAccess, \Countable
{
use Collection, ImmutableArray;
use Collection;
use ImmutableArray;

/**
* Default configuration.
Expand Down Expand Up @@ -44,7 +45,7 @@ public function __construct(array $config = [])
*
* @return string|null
*/
public function getCa() : ?string
public function getCa(): ?string
{
if (isset($this->config['ca']) && is_file($this->config['ca'])) {
return $this->config['ca'];
Expand All @@ -58,7 +59,7 @@ public function getCa() : ?string
*
* @return array
*/
public function getAuth() : array
public function getAuth(): array
{
return [
$this->config['user'],
Expand All @@ -71,7 +72,7 @@ public function getAuth() : array
*
* @return string
*/
public function getDsn() : string
public function getDsn(): string
{
$scheme = $this->config['scheme'] ?? 'http';

Expand All @@ -87,7 +88,7 @@ public function getDsn() : string
*
* @return self
*/
public function set(array $config = []) : self
public function set(array $config = []): self
{
// use same var name as laravel-bitcoinrpc
$config['password'] = $config['password'] ?? $config['pass'] ?? null;
Expand All @@ -107,7 +108,7 @@ public function set(array $config = []) : self
*
* @return array
*/
protected function toArray() : array
protected function toArray(): array
{
return $this->config;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Exceptions/BadConfigurationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(array $config, ...$args)
*
* @return array
*/
public function getConfig() : array
public function getConfig(): array
{
return $this->config;
}
Expand All @@ -43,7 +43,7 @@ public function getConfig() : array
*
* @return array
*/
protected function getConstructorParameters() : array
protected function getConstructorParameters(): array
{
return [
$this->getConfig(),
Expand Down
4 changes: 2 additions & 2 deletions src/Exceptions/BadRemoteCallException.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(Response $response)
*
* @return \Denpa\Bitcoin\Responses\Response
*/
public function getResponse() : Response
public function getResponse(): Response
{
return $this->response;
}
Expand All @@ -45,7 +45,7 @@ public function getResponse() : Response
*
* @return array
*/
protected function getConstructorParameters() : array
protected function getConstructorParameters(): array
{
return [
$this->getResponse(),
Expand Down
4 changes: 2 additions & 2 deletions src/Exceptions/ClientException.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ abstract class ClientException extends Exception
*
* @return \Exception
*/
public function withNamespace($namespace) : Exception
public function withNamespace($namespace): Exception
{
$classname = $this->getClassName();

Expand All @@ -33,7 +33,7 @@ public function withNamespace($namespace) : Exception
*
* @return string
*/
protected function getClassName() : string
protected function getClassName(): string
{
$pos = ($pos = strrpos(static::class, '\\')) !== false ? $pos + 1 : 0;

Expand Down
4 changes: 2 additions & 2 deletions src/Exceptions/ConnectionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(Request $request, ...$args)
*
* @return \GuzzleHttp\Psr7\Request
*/
public function getRequest() : Request
public function getRequest(): Request
{
return $this->request;
}
Expand All @@ -45,7 +45,7 @@ public function getRequest() : Request
*
* @return array
*/
protected function getConstructorParameters() : array
protected function getConstructorParameters(): array
{
return [
$this->getRequest(),
Expand Down
10 changes: 5 additions & 5 deletions src/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected function __construct()
*
* @return \Throwable|null
*/
protected function namespaceHandler(Throwable $exception) : ?Throwable
protected function namespaceHandler(Throwable $exception): ?Throwable
{
if ($this->namespace && $exception instanceof ClientException) {
return $exception->withNamespace($this->namespace);
Expand All @@ -60,7 +60,7 @@ protected function namespaceHandler(Throwable $exception) : ?Throwable
*
* @return \Throwable|null
*/
protected function requestExceptionHandler(Throwable $exception) : ?Throwable
protected function requestExceptionHandler(Throwable $exception): ?Throwable
{
if ($exception instanceof RequestException) {
if (
Expand All @@ -87,7 +87,7 @@ protected function requestExceptionHandler(Throwable $exception) : ?Throwable
*
* @return self
*/
public function registerHandler(callable $handler) : self
public function registerHandler(callable $handler): self
{
$this->handlers[] = $handler;

Expand All @@ -101,7 +101,7 @@ public function registerHandler(callable $handler) : self
*
* @return void
*/
public function handle(Throwable $exception) : void
public function handle(Throwable $exception): void
{
foreach ($this->handlers as $handler) {
$result = $handler($exception);
Expand All @@ -121,7 +121,7 @@ public function handle(Throwable $exception) : void
*
* @return self
*/
public function setNamespace($namespace) : self
public function setNamespace($namespace): self
{
$this->namespace = $namespace;

Expand Down
8 changes: 5 additions & 3 deletions src/Responses/BitcoindResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ class BitcoindResponse extends Response implements
\Serializable,
\JsonSerializable
{
use Collection, ImmutableArray, SerializableContainer;
use Collection;
use ImmutableArray;
use SerializableContainer;

/**
* Gets array representation of response object.
*
* @return array
*/
public function toArray() : array
public function toArray(): array
{
return (array) $this->result();
}
Expand All @@ -31,7 +33,7 @@ public function toArray() : array
*
* @return array
*/
public function toContainer() : array
public function toContainer(): array
{
return $this->container;
}
Expand Down
16 changes: 8 additions & 8 deletions src/Responses/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(ResponseInterface $response)
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function response() : ResponseInterface
public function response(): ResponseInterface
{
return $this->response;
}
Expand All @@ -55,7 +55,7 @@ public function response() : ResponseInterface
*
* @return self
*/
public function setResponse(ResponseInterface $response) : self
public function setResponse(ResponseInterface $response): self
{
$this->response = $response;

Expand All @@ -67,7 +67,7 @@ public function setResponse(ResponseInterface $response) : self
*
* @return bool
*/
public function hasError() : bool
public function hasError(): bool
{
return isset($this->container['error']);
}
Expand All @@ -77,7 +77,7 @@ public function hasError() : bool
*
* @return array|null
*/
public function error() : ?array
public function error(): ?array
{
return $this->container['error'] ?? null;
}
Expand All @@ -87,7 +87,7 @@ public function error() : ?array
*
* @return bool
*/
public function hasResult() : bool
public function hasResult(): bool
{
return isset($this->container['result']);
}
Expand All @@ -107,7 +107,7 @@ public function result()
*
* @return int
*/
public function getStatusCode() : int
public function getStatusCode(): int
{
return $this->response->getStatusCode();
}
Expand All @@ -120,7 +120,7 @@ public function getStatusCode() : int
*
* @return self
*/
public function withStatus($code, $reasonPhrase = '') : self
public function withStatus($code, $reasonPhrase = ''): self
{
$new = clone $this;

Expand All @@ -134,7 +134,7 @@ public function withStatus($code, $reasonPhrase = '') : self
*
* @return string
*/
public function getReasonPhrase() : string
public function getReasonPhrase(): string
{
return $this->response->getReasonPhrase();
}
Expand Down
Loading

0 comments on commit 578dab8

Please sign in to comment.