Skip to content

Commit 56382ed

Browse files
committed
fix legacy
1 parent 38b95b7 commit 56382ed

7 files changed

+8
-8
lines changed

src/Core/Bridge/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaChoiceRestriction.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function create(Constraint $constraint, PropertyMetadata $propertyMetadat
5252

5353
$restriction['type'] = 'array';
5454

55-
$type = $propertyMetadata->getBuiltinTypes()[0] ?? null;
55+
$type = $propertyMetadata->getType() ?? null;
5656
if ($type) {
5757
$restriction['items'] = ['type' => Type::BUILTIN_TYPE_STRING === $type->getBuiltinType() ? 'string' : 'number', 'enum' => $choices];
5858
}
@@ -73,6 +73,6 @@ public function create(Constraint $constraint, PropertyMetadata $propertyMetadat
7373
*/
7474
public function supports(Constraint $constraint, PropertyMetadata $propertyMetadata): bool
7575
{
76-
return $constraint instanceof Choice && null !== ($type = $propertyMetadata->getBuiltinTypes()[0] ?? null) && \in_array($type->getBuiltinType(), [Type::BUILTIN_TYPE_STRING, Type::BUILTIN_TYPE_INT, Type::BUILTIN_TYPE_FLOAT], true);
76+
return $constraint instanceof Choice && null !== ($type = $propertyMetadata->getType() ?? null) && \in_array($type->getBuiltinType(), [Type::BUILTIN_TYPE_STRING, Type::BUILTIN_TYPE_INT, Type::BUILTIN_TYPE_FLOAT], true);
7777
}
7878
}

src/Core/Bridge/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaGreaterThanOrEqualRestriction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ public function create(Constraint $constraint, PropertyMetadata $propertyMetadat
4040
*/
4141
public function supports(Constraint $constraint, PropertyMetadata $propertyMetadata): bool
4242
{
43-
return $constraint instanceof GreaterThanOrEqual && is_numeric($constraint->value) && ($type = $propertyMetadata->getBuiltinTypes()[0] ?? null) && \in_array($type->getBuiltinType(), [Type::BUILTIN_TYPE_INT, Type::BUILTIN_TYPE_FLOAT], true);
43+
return $constraint instanceof GreaterThanOrEqual && is_numeric($constraint->value) && ($type = $propertyMetadata->getType() ?? null) && \in_array($type->getBuiltinType(), [Type::BUILTIN_TYPE_INT, Type::BUILTIN_TYPE_FLOAT], true);
4444
}
4545
}

src/Core/Bridge/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaGreaterThanRestriction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ public function create(Constraint $constraint, PropertyMetadata $propertyMetadat
4141
*/
4242
public function supports(Constraint $constraint, PropertyMetadata $propertyMetadata): bool
4343
{
44-
return $constraint instanceof GreaterThan && is_numeric($constraint->value) && null !== ($type = $propertyMetadata->getBuiltinTypes()[0] ?? null) && \in_array($type->getBuiltinType(), [Type::BUILTIN_TYPE_INT, Type::BUILTIN_TYPE_FLOAT], true);
44+
return $constraint instanceof GreaterThan && is_numeric($constraint->value) && null !== ($type = $propertyMetadata->getType() ?? null) && \in_array($type->getBuiltinType(), [Type::BUILTIN_TYPE_INT, Type::BUILTIN_TYPE_FLOAT], true);
4545
}
4646
}

src/Core/Bridge/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaLessThanOrEqualRestriction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ public function create(Constraint $constraint, PropertyMetadata $propertyMetadat
4040
*/
4141
public function supports(Constraint $constraint, PropertyMetadata $propertyMetadata): bool
4242
{
43-
return $constraint instanceof LessThanOrEqual && is_numeric($constraint->value) && null !== ($type = $propertyMetadata->getBuiltinTypes()[0] ?? null) && \in_array($type->getBuiltinType(), [Type::BUILTIN_TYPE_INT, Type::BUILTIN_TYPE_FLOAT], true);
43+
return $constraint instanceof LessThanOrEqual && is_numeric($constraint->value) && null !== ($type = $propertyMetadata->getType() ?? null) && \in_array($type->getBuiltinType(), [Type::BUILTIN_TYPE_INT, Type::BUILTIN_TYPE_FLOAT], true);
4444
}
4545
}

src/Core/Bridge/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaLessThanRestriction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ public function create(Constraint $constraint, PropertyMetadata $propertyMetadat
4141
*/
4242
public function supports(Constraint $constraint, PropertyMetadata $propertyMetadata): bool
4343
{
44-
return $constraint instanceof LessThan && is_numeric($constraint->value) && null !== ($type = $propertyMetadata->getBuiltinTypes()[0] ?? null) && \in_array($type->getBuiltinType(), [Type::BUILTIN_TYPE_INT, Type::BUILTIN_TYPE_FLOAT], true);
44+
return $constraint instanceof LessThan && is_numeric($constraint->value) && null !== ($type = $propertyMetadata->getType() ?? null) && \in_array($type->getBuiltinType(), [Type::BUILTIN_TYPE_INT, Type::BUILTIN_TYPE_FLOAT], true);
4545
}
4646
}

src/Core/Bridge/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaRangeRestriction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ public function create(Constraint $constraint, PropertyMetadata $propertyMetadat
4646
*/
4747
public function supports(Constraint $constraint, PropertyMetadata $propertyMetadata): bool
4848
{
49-
return $constraint instanceof Range && null !== ($type = $propertyMetadata->getBuiltinTypes()[0] ?? null) && \in_array($type->getBuiltinType(), [Type::BUILTIN_TYPE_INT, Type::BUILTIN_TYPE_FLOAT], true);
49+
return $constraint instanceof Range && null !== ($type = $propertyMetadata->getType() ?? null) && \in_array($type->getBuiltinType(), [Type::BUILTIN_TYPE_INT, Type::BUILTIN_TYPE_FLOAT], true);
5050
}
5151
}

src/Metadata/Resource/Factory/LegacyResourceMetadataResourceMetadataCollectionFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
use ApiPlatform\Core\Api\OperationType;
1717
use ApiPlatform\Core\Bridge\Symfony\Routing\RouteNameGenerator;
18-
use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
1918
use ApiPlatform\Core\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
2019
use ApiPlatform\Core\Metadata\Resource\Factory\ResourceMetadataFactoryInterface;
2120
use ApiPlatform\Core\Metadata\Resource\ResourceMetadata;
@@ -28,6 +27,7 @@
2827
use ApiPlatform\Metadata\Link;
2928
use ApiPlatform\Metadata\Operation;
3029
use ApiPlatform\Metadata\Operations;
30+
use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
3131
use ApiPlatform\Metadata\Resource\DeprecationMetadataTrait;
3232
use ApiPlatform\Metadata\Resource\ResourceMetadataCollection;
3333

0 commit comments

Comments
 (0)