diff --git a/.travis.yml b/.travis.yml index 59e3899..b2a600d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ php: - '7.1' - '7.2' - '7.3' + - '7.4' before_script: - composer install diff --git a/CHANGELOG.md b/CHANGELOG.md index 9185eeb..d565111 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [2.1.1] - 2019-12-19 +### Fixed +- ResourceIdentifier does not allow multiple meta members (#99) + ## [2.1.0] - 2019-02-25 ### Fixed - Relationship without data property (#92) @@ -18,6 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Added - v2 initial release -[Unreleased]: https://github.com/json-api-php/json-api/compare/2.1.0...HEAD +[Unreleased]: https://github.com/json-api-php/json-api/compare/2.1.1...HEAD +[2.2.0]: https://github.com/json-api-php/json-api/compare/2.1.0...2.1.1 [2.1.0]: https://github.com/json-api-php/json-api/compare/2.0.1...2.1.0 [2.0.1]: https://github.com/json-api-php/json-api/compare/2.0.0...2.0.1 diff --git a/src/ResourceIdentifier.php b/src/ResourceIdentifier.php index 2974492..dff34f8 100644 --- a/src/ResourceIdentifier.php +++ b/src/ResourceIdentifier.php @@ -16,7 +16,7 @@ final class ResourceIdentifier implements PrimaryData */ private $id; - public function __construct(string $type, string $id, Meta $meta = null) + public function __construct(string $type, string $id, Meta ...$metas) { if (isValidName($type) === false) { throw new \DomainException("Invalid type value: $type"); @@ -26,7 +26,7 @@ public function __construct(string $type, string $id, Meta $meta = null) 'type' => $type, 'id' => $id, ]; - if ($meta) { + foreach ($metas as $meta) { $meta->attachTo($this->obj); } $this->type = $type; diff --git a/test/DataDocument/SingleResourceIdentifierTest.php b/test/DataDocument/SingleResourceIdentifierTest.php index 92a91d5..1d12a77 100644 --- a/test/DataDocument/SingleResourceIdentifierTest.php +++ b/test/DataDocument/SingleResourceIdentifierTest.php @@ -36,7 +36,10 @@ public function testExtendedDocument() "data": { "type": "apples", "id": "1", - "meta": {"apple_meta": "foo"} + "meta": { + "apple_meta": "foo", + "bar": [42] + } }, "links": { "self": "/apples/1" @@ -51,7 +54,8 @@ public function testExtendedDocument() new ResourceIdentifier( 'apples', '1', - new Meta('apple_meta', 'foo') + new Meta('apple_meta', 'foo'), + new Meta('bar', [42]) ), new SelfLink('/apples/1'), new JsonApi(),