Skip to content

Commit da796b9

Browse files
authored
fix(metadata): allow serializer attribute object in ApiProperty::$serialize (#6946)
1 parent de2d298 commit da796b9

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/Metadata/ApiProperty.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*
2727
* @author Kévin Dunglas <[email protected]>
2828
*/
29-
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::TARGET_PARAMETER | \Attribute::TARGET_CLASS_CONSTANT | \Attribute::TARGET_CLASS)]
29+
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::TARGET_PARAMETER | \Attribute::TARGET_CLASS_CONSTANT | \Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
3030
final class ApiProperty
3131
{
3232
private ?array $types;
@@ -219,7 +219,7 @@ public function __construct(
219219
private array $extraProperties = [],
220220
) {
221221
$this->types = \is_string($types) ? (array) $types : $types;
222-
$this->serialize = \is_array($serialize) ? $serialize : (array) $serialize;
222+
$this->serialize = \is_array($serialize) ? $serialize : [$serialize];
223223
}
224224

225225
public function getProperty(): ?string

src/Serializer/Mapping/Loader/PropertyMetadataLoader.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public function __construct(private readonly PropertyNameCollectionFactoryInterf
4040

4141
public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool
4242
{
43-
$attributesMetadata = $classMetadata->getAttributesMetadata();
4443
// It's very weird to grab Eloquent's properties in that case as they're never serialized
4544
// the Serializer makes a call on the abstract class, let's save some unneeded work with a condition
4645
if (Model::class === $classMetadata->getName()) {

0 commit comments

Comments
 (0)