Skip to content

Commit

Permalink
fix(metadata): support merging all properties of ApiProperty (#4420)
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Sep 6, 2021
1 parent 5e2eb4d commit 11fa1e7
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions src/Metadata/Property/Factory/AttributePropertyMetadataFactory.php
Expand Up @@ -102,21 +102,14 @@ private function createMetadata(ApiProperty $attribute, ApiProperty $propertyMet
return $attribute;
}

foreach ([
['get', 'Description'],
['is', 'Readable'],
['is', 'Writable'],
['is', 'ReadableLink'],
['is', 'WritableLink'],
['is', 'Required'],
['is', 'Identifier'],
['get', 'Default'],
['get', 'Example'],
['get', 'Types'],
// TODO: do we need to copy more properties?
] as $property) {
if (null !== $val = $attribute->{$property[0].$property[1]}()) {
$propertyMetadata->{"with{$property[1]}"}($val);
foreach (get_class_methods(ApiProperty::class) as $method) {
if (
'getAttribute' !== $method &&
'isChildInherited' !== $method &&
preg_match('/^(?:get|is)(.*)/', $method, $matches) &&
null !== $val = $attribute->{$method}()
) {
$propertyMetadata->{"with{$matches[1]}"}($val);
}
}

Expand Down

0 comments on commit 11fa1e7

Please sign in to comment.