From 1a97277ec4b3f4396217b20c8bc72af5870563df Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Wed, 28 Jun 2023 14:03:15 -0400 Subject: [PATCH] Tweak a Stringy method to have a more sensible return type --- src/AnimeClient/API/APIRequestBuilder.php | 32 +++++++++++------------ src/Ion/Type/Stringy.php | 4 ++- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/AnimeClient/API/APIRequestBuilder.php b/src/AnimeClient/API/APIRequestBuilder.php index f41e67c1..3e194206 100644 --- a/src/AnimeClient/API/APIRequestBuilder.php +++ b/src/AnimeClient/API/APIRequestBuilder.php @@ -14,8 +14,10 @@ namespace Aviat\AnimeClient\API; +// use Amp\Http\Client\Form; use Amp\Http\Client\Body\FormBody; - +use Amp\Http\Client\HttpClientBuilder; +use Amp\Http\Client\HttpException; use Amp\Http\Client\Request; use Aviat\Ion\Json; @@ -203,18 +205,15 @@ abstract class APIRequestBuilder { $this->buildUri(); - if ($this->logger !== NULL) - { - $this->logger->debug('API Request', [ - 'request_url' => $this->request->getUri(), - 'request_headers' => $this->request->getHeaders(), - 'request_body' => wait( - $this->request->getBody() - ->createBodyStream() - ->read() - ), - ]); - } + $this->logger?->debug('API Request', [ + 'request_url' => $this->request->getUri(), + 'request_headers' => $this->request->getHeaders(), + 'request_body' => wait( + $this->request->getBody() + ->createBodyStream() + ->read() + ), + ]); return $this->request; } @@ -222,12 +221,11 @@ abstract class APIRequestBuilder /** * Get the data from the response of the passed request * - * @throws Error - * @throws Throwable - * @throws TypeError + * @param Request $request * @return mixed + * @throws Throwable */ - public function getResponseData(Request $request) + public function getResponseData(Request $request): mixed { $response = getResponse($request); diff --git a/src/Ion/Type/Stringy.php b/src/Ion/Type/Stringy.php index 147f6435..8e4c40a6 100644 --- a/src/Ion/Type/Stringy.php +++ b/src/Ion/Type/Stringy.php @@ -2122,7 +2122,7 @@ abstract class Stringy implements Countable, IteratorAggregate, ArrayAccess * Alias for mb_regex_encoding which default to a noop if the mbstring * module is not installed. */ - protected function regexEncoding(): mixed + protected function regexEncoding(): string|bool|null { static $functionExists; @@ -2137,6 +2137,8 @@ abstract class Stringy implements Countable, IteratorAggregate, ArrayAccess return mb_regex_encoding(...$args); } + + return null; } protected function supportsEncoding(): bool|null