Skip to content

Commit 627b91f

Browse files
committed
fix(symfony): make properties field object-like for property schema collection restriction
1 parent eb53218 commit 627b91f

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaCollectionRestriction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function create(Constraint $constraint, ApiProperty $propertyMetadata): a
4040
{
4141
$restriction = [
4242
'type' => 'object',
43-
'properties' => [],
43+
'properties' => new \ArrayObject(),
4444
'additionalProperties' => $constraint->allowExtraFields,
4545
];
4646
$required = [];

tests/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaCollectionRestrictionTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function testCreate(Constraint $constraint, ApiProperty $propertyMetadata
7575

7676
public static function createProvider(): \Generator
7777
{
78-
yield 'empty' => [new Collection([]), new ApiProperty(), ['type' => 'object', 'properties' => [], 'additionalProperties' => false]];
78+
yield 'empty' => [new Collection([]), new ApiProperty(), ['type' => 'object', 'properties' => new \ArrayObject(), 'additionalProperties' => false]];
7979

8080
$fields = [
8181
'name' => new Required([
@@ -100,13 +100,13 @@ public static function createProvider(): \Generator
100100
],
101101
]),
102102
];
103-
$properties = [
103+
$properties = new \ArrayObject([
104104
'name' => new \ArrayObject(),
105105
'email' => ['minLength' => 2, 'maxLength' => 255, 'format' => 'email'],
106106
'phone' => ['pattern' => '^([+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\s\./0-9]*)$'],
107107
'age' => ['exclusiveMinimum' => 0],
108-
'social' => ['type' => 'object', 'properties' => ['githubUsername' => new \ArrayObject()], 'additionalProperties' => false, 'required' => ['githubUsername']],
109-
];
108+
'social' => ['type' => 'object', 'properties' => new \ArrayObject(['githubUsername' => new \ArrayObject()]), 'additionalProperties' => false, 'required' => ['githubUsername']],
109+
]);
110110
$required = ['name', 'email', 'social'];
111111

112112
yield 'with fields' => [

tests/Symfony/Validator/Metadata/Property/ValidatorPropertyMetadataFactoryTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ public function testCreateWithPropertyCollectionRestriction(): void
622622

623623
$this->assertEquals([
624624
'type' => 'object',
625-
'properties' => [
625+
'properties' => new \ArrayObject([
626626
'name' => new \ArrayObject(),
627627
'email' => ['format' => 'email', 'minLength' => 2, 'maxLength' => 255],
628628
'phone' => ['pattern' => '^([+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\s\./0-9]*)$'],
@@ -631,13 +631,13 @@ public function testCreateWithPropertyCollectionRestriction(): void
631631
],
632632
'social' => [
633633
'type' => 'object',
634-
'properties' => [
634+
'properties' => new \ArrayObject([
635635
'githubUsername' => new \ArrayObject(),
636-
],
636+
]),
637637
'additionalProperties' => false,
638638
'required' => ['githubUsername'],
639639
],
640-
],
640+
]),
641641
'additionalProperties' => true,
642642
'required' => ['name', 'email', 'social'],
643643
], $schema);

0 commit comments

Comments
 (0)