Skip to content

Commit 5f47c15

Browse files
authored
Relationship with no "data" member. Fixed #92 (#93)
1 parent 668ec0c commit 5f47c15

19 files changed

+132
-24
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
language: php
22
php:
33
- '7.1'
4+
- '7.2'
5+
- '7.3'
46

57
before_script:
68
- composer install

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [Unreleased]
88

9+
## [2.1.0] - 2019-02-25
10+
### Fixed
11+
- Relationship without data property (#92)
12+
913
## [2.0.1] - 2018-12-31
1014
### Changed
1115
- Downgraded min required php version to 7.1
@@ -14,5 +18,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1418
### Added
1519
- v2 initial release
1620

17-
[Unreleased]: https://github.com/json-api-php/json-api/compare/2.0.1...HEAD
21+
[Unreleased]: https://github.com/json-api-php/json-api/compare/2.1.0...HEAD
22+
[2.1.0]: https://github.com/json-api-php/json-api/compare/2.0.1...2.1.0
1823
[2.0.1]: https://github.com/json-api-php/json-api/compare/2.0.0...2.0.1

phpunit.xml.dist

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
bootstrap="vendor/autoload.php"
44
stopOnFailure="false"
55
verbose="true"
6-
colors="true"
7-
syntaxCheck="true">
6+
colors="true">
87
<testsuites>
98
<testsuite name="Main">
109
<directory>./test</directory>

src/EmptyRelationship.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace JsonApiPhp\JsonApi;
4+
5+
use JsonApiPhp\JsonApi\Internal\RelationshipMember;
6+
use JsonApiPhp\JsonApi\Internal\ResourceField;
7+
use JsonApiPhp\JsonApi\Internal\ResourceFieldTrait;
8+
9+
/**
10+
* A relationship with no data
11+
*/
12+
class EmptyRelationship implements ResourceField
13+
{
14+
use ResourceFieldTrait;
15+
16+
private $obj;
17+
18+
public function __construct(string $name, RelationshipMember $member, RelationshipMember ...$members)
19+
{
20+
$this->name = $name;
21+
$this->obj = combine($member, ...$members);
22+
}
23+
24+
/**
25+
* @param object $o
26+
*/
27+
public function attachTo($o): void
28+
{
29+
child($o, 'relationships')->{$this->name} = $this->obj;
30+
}
31+
}

src/Error/SourceParameter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace JsonApiPhp\JsonApi\Error;
44

5-
use JsonApiPhp\JsonApi\Internal\ErrorMember;
65
use function JsonApiPhp\JsonApi\child;
6+
use JsonApiPhp\JsonApi\Internal\ErrorMember;
77

88
final class SourceParameter implements ErrorMember
99
{

src/Error/SourcePointer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace JsonApiPhp\JsonApi\Error;
44

5-
use JsonApiPhp\JsonApi\Internal\ErrorMember;
65
use function JsonApiPhp\JsonApi\child;
6+
use JsonApiPhp\JsonApi\Internal\ErrorMember;
77

88
final class SourcePointer implements ErrorMember
99
{

src/Internal/RelationshipMember.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace JsonApiPhp\JsonApi\Internal;
4+
5+
/**
6+
* @internal
7+
*/
8+
interface RelationshipMember extends ToOneMember, ToManyMember
9+
{
10+
}

src/Internal/ToManyMember.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace JsonApiPhp\JsonApi\Internal;
44

5-
interface ToManyMember extends ToOneMember
5+
/**
6+
* @internal
7+
*/
8+
interface ToManyMember extends Attachable
69
{
710
}

src/Link/AboutLink.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace JsonApiPhp\JsonApi\Link;
44

5+
use function JsonApiPhp\JsonApi\child;
56
use JsonApiPhp\JsonApi\Internal\ErrorMember;
67
use JsonApiPhp\JsonApi\Internal\LinkTrait;
7-
use function JsonApiPhp\JsonApi\child;
88

99
final class AboutLink implements ErrorMember
1010
{

src/Link/FirstLink.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace JsonApiPhp\JsonApi\Link;
44

5+
use function JsonApiPhp\JsonApi\child;
56
use JsonApiPhp\JsonApi\Internal\LinkTrait;
67
use JsonApiPhp\JsonApi\Internal\PaginationLink;
7-
use function JsonApiPhp\JsonApi\child;
88

99
final class FirstLink implements PaginationLink
1010
{

0 commit comments

Comments
 (0)