Skip to content

Commit d3b98b5

Browse files
chore: symfony deprecations (#7277)
1 parent 8c00094 commit d3b98b5

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/Metadata/ApiProperty.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,10 @@ public function getBuiltinTypes(): ?array
513513
{
514514
trigger_deprecation('api-platform/metadata', '4.2', 'The "%s()" method is deprecated, use "%s::getNativeType()" instead.', __METHOD__, self::class);
515515

516+
if (null === $this->builtinTypes && null !== $this->nativeType) {
517+
$this->builtinTypes = PropertyInfoToTypeInfoHelper::convertTypeToLegacyTypes($this->nativeType) ?? [];
518+
}
519+
516520
return $this->builtinTypes;
517521
}
518522

@@ -541,7 +545,6 @@ public function withNativeType(?Type $nativeType): self
541545
{
542546
$self = clone $this;
543547
$self->nativeType = $nativeType;
544-
$self->builtinTypes = PropertyInfoToTypeInfoHelper::convertTypeToLegacyTypes($nativeType) ?? [];
545548

546549
return $self;
547550
}

src/Serializer/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
],
2424
"require": {
2525
"php": ">=8.2",
26-
"api-platform/metadata": "^4.1.11",
26+
"api-platform/metadata": "^4.1.16",
2727
"api-platform/state": "^4.1.11",
2828
"symfony/property-access": "^6.4 || ^7.0",
2929
"symfony/property-info": "^6.4 || ^7.1",

src/Symfony/Tests/Validator/Metadata/Property/Restriction/PropertySchemaFormatTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ public function testSupports(Constraint $constraint, ApiProperty $propertyMetada
4646
public static function supportsProvider(): \Generator
4747
{
4848
yield 'email' => [new Email(), new ApiProperty(), true];
49-
yield 'url' => [new Url(), new ApiProperty(), true];
49+
if (property_exists(Url::class, 'requireTld')) {
50+
yield 'url' => [new Url(requireTld: true), new ApiProperty(), true];
51+
} else {
52+
yield 'url' => [new Url(), new ApiProperty(), true];
53+
}
5054
if (class_exists(Hostname::class)) {
5155
yield 'hostname' => [new Hostname(), new ApiProperty(), true];
5256
}
@@ -67,7 +71,11 @@ public function testCreate(Constraint $constraint, ApiProperty $propertyMetadata
6771
public static function createProvider(): \Generator
6872
{
6973
yield 'email' => [new Email(), new ApiProperty(), ['format' => 'email']];
70-
yield 'url' => [new Url(), new ApiProperty(), ['format' => 'uri']];
74+
if (property_exists(Url::class, 'requireTld')) {
75+
yield 'url' => [new Url(requireTld: true), new ApiProperty(), ['format' => 'uri']];
76+
} else {
77+
yield 'url' => [new Url(), new ApiProperty(), ['format' => 'uri']];
78+
}
7179
if (class_exists(Hostname::class)) {
7280
yield 'hostname' => [new Hostname(), new ApiProperty(), ['format' => 'hostname']];
7381
}

0 commit comments

Comments
 (0)