From fd74833a083d8a0b185f51e30f0434fcdcbc96ff Mon Sep 17 00:00:00 2001 From: Eric Sizemore Date: Sun, 24 Dec 2023 01:31:17 -0500 Subject: [PATCH] PHPStan cleanup pass --- README.md | 2 +- src/AbstractBase.php | 7 ++++--- src/Platform.php | 3 +++ src/Project.php | 3 ++- src/Repository.php | 5 +++-- src/User.php | 5 +++-- 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 368fe78..a15f75b 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ As an example, let's say you want to get a list of the available platforms. To d ```php makeRequest(); diff --git a/src/AbstractBase.php b/src/AbstractBase.php index 7620cd7..736666a 100644 --- a/src/AbstractBase.php +++ b/src/AbstractBase.php @@ -190,7 +190,7 @@ public abstract function makeRequest(string $endpoint, array $options): Response * Processes the available parameters for a given endpoint. * * @param string $endpoint - * @return array|string> + * @return array|string> */ public abstract function endpointParameters(string $endpoint): array; @@ -212,6 +212,7 @@ public function processEndpointFormat(string $format, array $options): string if ($key === 'page' || $key === 'per_page') { continue; } + /** @var string $val **/ $format = str_replace(":$key", $val, $format); } return $format; @@ -221,8 +222,8 @@ public function processEndpointFormat(string $format, array $options): string * Helper function to make sure that the $options passed to the child class' makeRequest() * contains the required options listed in the endpoints options. * - * @param array|string> $endpointOptions - * @param array $options + * @param array $endpointOptions + * @param array $options * @return bool */ public function verifyEndpointOptions(array $endpointOptions, array $options): bool diff --git a/src/Platform.php b/src/Platform.php index 852a33e..2a6031a 100644 --- a/src/Platform.php +++ b/src/Platform.php @@ -14,6 +14,8 @@ */ namespace Esi\LibrariesIO; +use InvalidArgumentException; + use Esi\LibrariesIO\{ Exception\RateLimitExceededException, AbstractBase @@ -73,6 +75,7 @@ public function makeRequest(string $endpoint = 'platforms', ?array $options = nu // Attempt the request try { + /** @phpstan-ignore-next-line **/ return $this->client->get($endpointParameters['format']); } catch (ClientException $e) { if ($e->getResponse()->getStatusCode() === 429) { diff --git a/src/Project.php b/src/Project.php index 8e022e1..1184d99 100644 --- a/src/Project.php +++ b/src/Project.php @@ -72,6 +72,7 @@ public function makeRequest(string $endpoint, array $options): ResponseInterface ); } + /** @var array $endpointOptions **/ $endpointOptions = $endpointParameters['options']; if (!parent::verifyEndpointOptions($endpointOptions, $options)) { @@ -105,7 +106,7 @@ public function makeRequest(string $endpoint, array $options): ResponseInterface parent::makeClient($query); // Attempt the request - $endpointParameters['format'] = parent::processEndpointFormat($endpointParameters['format'], $options); + $endpointParameters['format'] = parent::processEndpointFormat(/** @phpstan-ignore-line **/$endpointParameters['format'], $options); try { return $this->client->get($endpointParameters['format']); diff --git a/src/Repository.php b/src/Repository.php index 82df200..032c44a 100644 --- a/src/Repository.php +++ b/src/Repository.php @@ -62,7 +62,7 @@ final class Repository extends AbstractBase /** * {@inheritdoc} */ - public function makeRequest(string $endpoint, ?array $options = null): ResponseInterface + public function makeRequest(string $endpoint, array $options): ResponseInterface { // Make sure we have the format and options for $endpoint $endpointParameters = $this->endpointParameters($endpoint); @@ -73,6 +73,7 @@ public function makeRequest(string $endpoint, ?array $options = null): ResponseI ); } + /** @var array $endpointOptions **/ $endpointOptions = $endpointParameters['options']; if (!parent::verifyEndpointOptions($endpointOptions, $options)) { @@ -89,7 +90,7 @@ public function makeRequest(string $endpoint, ?array $options = null): ResponseI ]); // Attempt the request - $endpointParameters['format'] = parent::processEndpointFormat($endpointParameters['format'], $options); + $endpointParameters['format'] = parent::processEndpointFormat(/** @phpstan-ignore-line **/$endpointParameters['format'], $options); try { return $this->client->get($endpointParameters['format']); diff --git a/src/User.php b/src/User.php index a0abce1..da2a885 100644 --- a/src/User.php +++ b/src/User.php @@ -64,7 +64,7 @@ final class User extends AbstractBase /** * {@inheritdoc} */ - public function makeRequest(string $endpoint, ?array $options = null): ResponseInterface + public function makeRequest(string $endpoint, array $options): ResponseInterface { // Make sure we have the format and options for $endpoint $endpointParameters = $this->endpointParameters($endpoint); @@ -75,6 +75,7 @@ public function makeRequest(string $endpoint, ?array $options = null): ResponseI ); } + /** @var array $endpointOptions **/ $endpointOptions = $endpointParameters['options']; if (!parent::verifyEndpointOptions($endpointOptions, $options)) { @@ -91,7 +92,7 @@ public function makeRequest(string $endpoint, ?array $options = null): ResponseI ]); // Attempt the request - $endpointParameters['format'] = parent::processEndpointFormat($endpointParameters['format'], $options); + $endpointParameters['format'] = parent::processEndpointFormat(/** @phpstan-ignore-line **/$endpointParameters['format'], $options); // Attempt the request try {