Skip to content

Commit fe73002

Browse files
committed
fix(laravel): duplicated property names
1 parent 61301d9 commit fe73002

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Metadata/Property/Factory/ClassLevelAttributePropertyNameCollectionFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ public function create(string $resourceClass, array $options = []): PropertyName
3333
return $parentPropertyNameCollection ?? new PropertyNameCollection();
3434
}
3535

36-
$properties = $parentPropertyNameCollection ? iterator_to_array($parentPropertyNameCollection) : [];
36+
$properties = $parentPropertyNameCollection ? array_flip(iterator_to_array($parentPropertyNameCollection)) : [];
3737

3838
$refl = new \ReflectionClass($resourceClass);
3939
$attributes = $refl->getAttributes(ApiProperty::class);
4040
foreach ($attributes as $attribute) {
4141
$instance = $attribute->newInstance();
4242
if ($property = $instance->getProperty()) {
43-
$properties[] = $property;
43+
$properties[$property] = true;
4444
}
4545
}
4646

47-
return new PropertyNameCollection($properties);
47+
return new PropertyNameCollection(array_keys($properties));
4848
}
4949
}

0 commit comments

Comments
 (0)