Skip to content

Commit 8e22ee2

Browse files
authored
Merge 2e32c6a into a20bb89
2 parents a20bb89 + 2e32c6a commit 8e22ee2

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/Annotation/AttributesHydratorTrait.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ trait AttributesHydratorTrait
3737
/**
3838
* @var array
3939
*/
40-
public $attributes = [];
40+
public $attributes = null;
4141

4242
/**
4343
* @throws InvalidArgumentException
@@ -55,7 +55,16 @@ private function hydrateAttributes(array $values): void
5555
throw new InvalidArgumentException(sprintf('Unknown property "%s" on annotation "%s".', $key, self::class));
5656
}
5757

58-
(new \ReflectionProperty($this, $key))->isPublic() ? $this->{$key} = $value : $this->attributes += [Inflector::tableize($key) => $value];
58+
if ((new \ReflectionProperty($this, $key))->isPublic()) {
59+
$this->{$key} = $value;
60+
continue;
61+
}
62+
63+
if (!is_array($this->attributes)) {
64+
$this->attributes = [];
65+
}
66+
67+
$this->attributes += [Inflector::tableize($key) => $value];
5968
}
6069
}
6170
}

src/Metadata/Resource/Factory/AnnotationResourceMetadataFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private function createMetadata(ApiResource $annotation, ResourceMetadata $paren
8585
$annotation->iri,
8686
$annotation->itemOperations,
8787
$annotation->collectionOperations,
88-
$annotation->attributes ?: null,
88+
$annotation->attributes,
8989
$annotation->subresourceOperations,
9090
$annotation->graphql
9191
);

0 commit comments

Comments
 (0)