Skip to content

Commit

Permalink
Merge pull request #132 from localheinz/fix/content-type
Browse files Browse the repository at this point in the history
Fix: Default to empty string as content type
  • Loading branch information
localheinz committed Feb 22, 2019
2 parents 74194c7 + b9ffb51 commit fda4072
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
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

0 comments on commit fda4072

Please sign in to comment.