Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Metadata/ApiProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,10 @@
{
trigger_deprecation('api-platform/metadata', '4.2', 'The "%s()" method is deprecated, use "%s::getNativeType()" instead.', __METHOD__, self::class);

if (null === $this->builtinTypes && null !== $this->nativeType) {
$this->builtinTypes = PropertyInfoToTypeInfoHelper::convertTypeToLegacyTypes($this->nativeType) ?? [];

Check warning on line 517 in src/Metadata/ApiProperty.php

View check run for this annotation

Codecov / codecov/patch

src/Metadata/ApiProperty.php#L516-L517

Added lines #L516 - L517 were not covered by tests
}

return $this->builtinTypes;
}

Expand Down Expand Up @@ -541,7 +545,6 @@
{
$self = clone $this;
$self->nativeType = $nativeType;
$self->builtinTypes = PropertyInfoToTypeInfoHelper::convertTypeToLegacyTypes($nativeType) ?? [];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using withNativeType was triggering the symfony deprecation.

Instead we should hydrate the buildinTypes only if necessary, which means, only if getBuildinTypes is called.

This solve the deprecations.


return $self;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Serializer/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
],
"require": {
"php": ">=8.2",
"api-platform/metadata": "^4.1.11",
"api-platform/metadata": "^4.1.16",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AccessDeniedException was introduced in 4.1.16.
b2b5f99

"api-platform/state": "^4.1.11",
"symfony/property-access": "^6.4 || ^7.0",
"symfony/property-info": "^6.4 || ^7.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@
public static function supportsProvider(): \Generator
{
yield 'email' => [new Email(), new ApiProperty(), true];
yield 'url' => [new Url(), new ApiProperty(), true];
if (property_exists(Url::class, 'requireTld')) {
yield 'url' => [new Url(requireTld: true), new ApiProperty(), true];

Check warning on line 50 in src/Symfony/Tests/Validator/Metadata/Property/Restriction/PropertySchemaFormatTest.php

View check run for this annotation

Codecov / codecov/patch

src/Symfony/Tests/Validator/Metadata/Property/Restriction/PropertySchemaFormatTest.php#L49-L50

Added lines #L49 - L50 were not covered by tests
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not passing requireTld imply a deprecation for sf > 7.1 ; but the property only exists since 7.1

} else {
yield 'url' => [new Url(), new ApiProperty(), true];

Check warning on line 52 in src/Symfony/Tests/Validator/Metadata/Property/Restriction/PropertySchemaFormatTest.php

View check run for this annotation

Codecov / codecov/patch

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

Added line #L52 was not covered by tests
}
if (class_exists(Hostname::class)) {
yield 'hostname' => [new Hostname(), new ApiProperty(), true];
}
Expand All @@ -67,7 +71,11 @@
public static function createProvider(): \Generator
{
yield 'email' => [new Email(), new ApiProperty(), ['format' => 'email']];
yield 'url' => [new Url(), new ApiProperty(), ['format' => 'uri']];
if (property_exists(Url::class, 'requireTld')) {
yield 'url' => [new Url(requireTld: true), new ApiProperty(), ['format' => 'uri']];

Check warning on line 75 in src/Symfony/Tests/Validator/Metadata/Property/Restriction/PropertySchemaFormatTest.php

View check run for this annotation

Codecov / codecov/patch

src/Symfony/Tests/Validator/Metadata/Property/Restriction/PropertySchemaFormatTest.php#L74-L75

Added lines #L74 - L75 were not covered by tests
} else {
yield 'url' => [new Url(), new ApiProperty(), ['format' => 'uri']];

Check warning on line 77 in src/Symfony/Tests/Validator/Metadata/Property/Restriction/PropertySchemaFormatTest.php

View check run for this annotation

Codecov / codecov/patch

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

Added line #L77 was not covered by tests
}
if (class_exists(Hostname::class)) {
yield 'hostname' => [new Hostname(), new ApiProperty(), ['format' => 'hostname']];
}
Expand Down
Loading