Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Default to empty string as content type #132

Merged
merged 1 commit into from
Feb 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ For a full diff see [`0.9.0...master`](https://github.com/localheinz/json-normal

* Allowing injection of a `UriRetriever` into the `SchemaNormalizer`, and defaulting to a `ChainUriRetriever` which composes `FileGetContents` and `Curl` URI retrievers ([#104](https://github.com/localheinz/json-normalizer/pull/104)), by [@localheinz](https://github.com/localheinz)
* Dropped `null` default values of constructor arguments of `AutoFormatNormalizer`, `FixedFormatNormalizer`, `Formatter`, `IndentNormalizer` to expose hard dependencies ([#109](https://github.com/localheinz/json-normalizer/pull/109)), by [@localheinz](https://github.com/localheinz)
* Dropped nullable return type declaration from `ChainUriRetriever::getContentType()`, defaulting to an empty `string` when `ChainUriRetriever::retrieve()` wasn't invoked yet ([#132](https://github.com/localheinz/json-normalizer/pull/132)), by [@localheinz](https://github.com/localheinz)

## [`0.9.0`](https://github.com/localheinz/json-normalizer/releases/tag/0.9.0)

Expand Down
2 changes: 0 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ parameters:
- RuntimeException
ignoreErrors:
- '#Method Localheinz\\Json\\Normalizer\\Json::__construct\(\) has parameter \$decoded with no typehint specified.#'
- '#Method Localheinz\\Json\\Normalizer\\JsonSchema\\Uri\\Retrievers\\ChainUriRetriever::getContentType\(\) has a nullable return type declaration.#'
- '#Method Localheinz\\Json\\Normalizer\\SchemaNormalizer::resolveSchema\(\) has parameter \$data with no typehint specified.#'
- '#Return type \(string\|null\) of method Localheinz\\Json\\Normalizer\\JsonSchema\\Uri\\Retrievers\\ChainUriRetriever::getContentType\(\) should be covariant with return type \(string\) of method JsonSchema\\Uri\\Retrievers\\UriRetrieverInterface::getContentType\(\)#'
paths:
- src
- test
Expand Down
6 changes: 3 additions & 3 deletions src/JsonSchema/Uri/Retrievers/ChainUriRetriever.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ final class ChainUriRetriever implements Uri\Retrievers\UriRetrieverInterface
private $retrievers;

/**
* @var null|string
* @var string
*/
private $contentType;
private $contentType = '';

/**
* @param Uri\Retrievers\UriRetrieverInterface ...$retrievers
Expand Down Expand Up @@ -63,7 +63,7 @@ public function retrieve($uri)
));
}

public function getContentType(): ?string
public function getContentType(): string
{
return $this->contentType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function testDefaults(): void

$uriRetriever = new ChainUriRetriever($retriever);

self::assertNull($uriRetriever->getContentType());
self::assertSame('', $uriRetriever->getContentType());
}

public function testRetrieveThrowsResourceNotFoundExceptionWhenNoneOfTheRetrieversWhereAbleToRetrieveUri(): void
Expand Down