diff --git a/composer.json b/composer.json index df4dcfc..f25b1b3 100644 --- a/composer.json +++ b/composer.json @@ -17,8 +17,8 @@ "require-dev": { "phpunit/phpunit": "^9.1", "http-interop/http-factory-guzzle": "^1.0", - "infection/infection": "^0.18|^0.19|^0.20|^0.23|^0.25", - "phpstan/phpstan": "^0.12.88", + "infection/infection": "^0.25", + "phpstan/phpstan": "^1.0.0", "php-http/guzzle7-adapter": "^1.0" } } diff --git a/src/HtaccessClient.php b/src/HtaccessClient.php index a7a394d..f2271b1 100644 --- a/src/HtaccessClient.php +++ b/src/HtaccessClient.php @@ -5,6 +5,22 @@ use Psr\Http\Client\ClientInterface; use Psr\Http\Message\ServerRequestFactoryInterface; +/** + * @phpstan-type HtaccessResponseData array{ + * 'output_url': string, + * 'lines': array, + * 'output_status_code': int, + * 'url':string, + * 'errors'?: array + * } + */ final class HtaccessClient { public function __construct( @@ -22,6 +38,7 @@ public function test( ?ServerVariables $serverVariables = null ): HtaccessResult { $serverVariables = $serverVariables ?? ServerVariables::default(); + /** @var HtaccessResponseData */ $responseData = $this->request( 'POST', '', @@ -35,7 +52,7 @@ public function test( return new HtaccessResult( $responseData['output_url'], array_map( - function (array $line) { + function (array $line): ResultLine { return new ResultLine( $line['value'], $line['message'], @@ -60,6 +77,7 @@ public function share( ?ServerVariables $serverVariables = null ): ShareResult { $serverVariables = $serverVariables ?? ServerVariables::default(); + /** @var HtaccessResponseData */ $responseData = $this->request( 'POST', '/share', @@ -78,6 +96,7 @@ public function share( */ public function getShared(string $shareUuid): HtaccessResult { + /** @var HtaccessResponseData */ $responseData = $this->request( 'GET', '/share?share=' . $shareUuid @@ -125,6 +144,7 @@ private function request(string $method, string $endpoint = '', array $requestDa $response = $this->httpClient->sendRequest($request); + /** @var HtaccessResponseData */ $responseData = json_decode($response->getBody()->getContents(), true); if (isset($responseData['errors'])) {