Skip to content

Commit

Permalink
Update flix-tech/avro-php dependency (#36)
Browse files Browse the repository at this point in the history
Co-authored-by: @nick-zh
Co-authored-by: @tPl0ch
  • Loading branch information
nick-zh authored Aug 26, 2020
1 parent ec106af commit 4b5b788
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ composer-update:
PHP_VERSION=$(PHP_VERSION) $(PHP) $(COMPOSER) update --no-interaction --no-progress --no-suggest --no-scripts

phpstan:
PHP_VERSION=$(PHP_VERSION) $(PHP) vendor/bin/phpstan.phar analyse -l 7 src
PHP_VERSION=$(PHP_VERSION) $(PHP) vendor/bin/phpstan.phar analyse

cs-fixer:
PHP_VERSION=$(PHP_VERSION) $(PHP) bin/php-cs-fixer.phar fix --config=.php_cs.dist -v --dry-run \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ compliant requests that can be used as well as high level abstractions to ease d
| **`php`** | ~7.2 | Anything lower has reached EOL |
| **`guzzlephp/guzzle`** | ~6.3 | Using `Request` to build PSR-7 `RequestInterface` |
| **`beberlei/assert`** | ~2.7\|~3.0 | The de-facto standard assertions library for PHP |
| **`flix-tech/avro-php`** | ^3.0 | Maintained fork of the only Avro PHP implementation: `rg/avro-php` |
| **`flix-tech/avro-php`** | ^4.0 | Maintained fork of the only Avro PHP implementation: `rg/avro-php` |

### Optional dependencies

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"ext-json": "*",
"guzzlehttp/guzzle": "~6.3",
"beberlei/assert": "~2.7|~3.0",
"flix-tech/avro-php": "^3.0"
"flix-tech/avro-php": "^3.0|^4.0"
},
"require-dev": {
"phpunit/phpunit": "~7.0",
"phpstan/phpstan-shim": "~0.8",
"phpstan/phpstan": "^0.12",
"raphhh/trex-reflection": "~1.0",
"doctrine/cache": "~1.3"
},
Expand Down
3 changes: 3 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
parameters:
level: 8
paths: [ src ]
11 changes: 10 additions & 1 deletion src/Exception/ExceptionMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ private function guardAgainstMissingResponse(RequestException $exception): Respo
return $response;
}

/**
* @param ResponseInterface $response
* @return array<mixed, mixed>
*/
private function guardAgainstMissingErrorCode(ResponseInterface $response): array
{
try {
Expand Down Expand Up @@ -88,7 +92,12 @@ private function guardAgainstMissingErrorCode(ResponseInterface $response): arra
}
}

private function mapErrorCodeToException($errorCode, $errorMessage)
/**
* @param int $errorCode
* @param string $errorMessage
* @return SchemaRegistryException
*/
private function mapErrorCodeToException($errorCode, $errorMessage): SchemaRegistryException
{
switch ($errorCode) {
case IncompatibleAvroSchemaException::errorCode():
Expand Down
4 changes: 4 additions & 0 deletions src/Registry/PromisingRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ private function makeRequest(RequestInterface $request, callable $onFulfilled, c
->then($onFulfilled, $this->rejectedCallback);
}

/**
* @param ResponseInterface $response
* @return array<mixed, mixed>
*/
private function getJsonFromResponseBody(ResponseInterface $response): array
{
$body = (string) $response->getBody();
Expand Down
21 changes: 19 additions & 2 deletions src/Requests/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ function changeSubjectCompatibilityLevelRequest(string $subjectName, string $lev
);
}

/**
* @param int|string $versionId
* @return string
*/
function validateVersionId($versionId): string
{
if (VERSION_LATEST !== $versionId) {
Expand Down Expand Up @@ -182,6 +186,10 @@ function prepareCompatibilityLevelForTransport(string $compatibilityLevel): stri
return \GuzzleHttp\json_encode(['compatibility' => $compatibilityLevel]);
}

/**
* @param int|string $schemaId
* @return string
*/
function validateSchemaId($schemaId): string
{
Assert::that($schemaId)
Expand All @@ -191,7 +199,11 @@ function validateSchemaId($schemaId): string
return (string) $schemaId;
}

function deleteSubjectRequest(string $subjectName)
/**
* @param string $subjectName
* @return RequestInterface
*/
function deleteSubjectRequest(string $subjectName): RequestInterface
{
return new Request(
'DELETE',
Expand All @@ -200,7 +212,12 @@ function deleteSubjectRequest(string $subjectName)
);
}

function deleteSubjectVersionRequest(string $subjectName, string $versionId)
/**
* @param string $subjectName
* @param string $versionId
* @return RequestInterface
*/
function deleteSubjectVersionRequest(string $subjectName, string $versionId): RequestInterface
{
return new Request(
'DELETE',
Expand Down

0 comments on commit 4b5b788

Please sign in to comment.