Skip to content

Commit 11fa1e7

Browse files
authored
fix(metadata): support merging all properties of ApiProperty (api-platform#4420)
1 parent 5e2eb4d commit 11fa1e7

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

src/Metadata/Property/Factory/AttributePropertyMetadataFactory.php

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,14 @@ private function createMetadata(ApiProperty $attribute, ApiProperty $propertyMet
102102
return $attribute;
103103
}
104104

105-
foreach ([
106-
['get', 'Description'],
107-
['is', 'Readable'],
108-
['is', 'Writable'],
109-
['is', 'ReadableLink'],
110-
['is', 'WritableLink'],
111-
['is', 'Required'],
112-
['is', 'Identifier'],
113-
['get', 'Default'],
114-
['get', 'Example'],
115-
['get', 'Types'],
116-
// TODO: do we need to copy more properties?
117-
] as $property) {
118-
if (null !== $val = $attribute->{$property[0].$property[1]}()) {
119-
$propertyMetadata->{"with{$property[1]}"}($val);
105+
foreach (get_class_methods(ApiProperty::class) as $method) {
106+
if (
107+
'getAttribute' !== $method &&
108+
'isChildInherited' !== $method &&
109+
preg_match('/^(?:get|is)(.*)/', $method, $matches) &&
110+
null !== $val = $attribute->{$method}()
111+
) {
112+
$propertyMetadata->{"with{$matches[1]}"}($val);
120113
}
121114
}
122115

0 commit comments

Comments
 (0)