Skip to content

Commit

Permalink
Merge pull request #34 from madewithlove/dependabot/composer/phpstan/…
Browse files Browse the repository at this point in the history
…phpstan-tw-0.12.88or-tw-1.0.0

Update phpstan/phpstan requirement from ^0.12.88 to ^0.12.88 || ^1.0.0
  • Loading branch information
madewithlove-machine-user authored Nov 2, 2021
2 parents 068bf1a + 70553a3 commit f52aab0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
22 changes: 21 additions & 1 deletion src/HtaccessClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\ServerRequestFactoryInterface;

/**
* @phpstan-type HtaccessResponseData array{
* 'output_url': string,
* 'lines': array<int,array{
* 'value': string,
* 'message': string,
* 'isMet': bool,
* 'isValid': bool,
* 'wasReached': bool,
* 'isSupported': bool,
* }>,
* 'output_status_code': int,
* 'url':string,
* 'errors'?: array<int,array{'field': string, 'message': string}>
* }
*/
final class HtaccessClient
{
public function __construct(
Expand All @@ -22,6 +38,7 @@ public function test(
?ServerVariables $serverVariables = null
): HtaccessResult {
$serverVariables = $serverVariables ?? ServerVariables::default();
/** @var HtaccessResponseData */
$responseData = $this->request(
'POST',
'',
Expand All @@ -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'],
Expand All @@ -60,6 +77,7 @@ public function share(
?ServerVariables $serverVariables = null
): ShareResult {
$serverVariables = $serverVariables ?? ServerVariables::default();
/** @var HtaccessResponseData */
$responseData = $this->request(
'POST',
'/share',
Expand All @@ -78,6 +96,7 @@ public function share(
*/
public function getShared(string $shareUuid): HtaccessResult
{
/** @var HtaccessResponseData */
$responseData = $this->request(
'GET',
'/share?share=' . $shareUuid
Expand Down Expand Up @@ -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'])) {
Expand Down

0 comments on commit f52aab0

Please sign in to comment.