Skip to content

Commit 368e6bd

Browse files
fix: deprecations
1 parent 828b62a commit 368e6bd

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
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/Symfony/Tests/Fixtures/DummyIriWithValidationEntity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class DummyIriWithValidationEntity
2424
{
25-
#[Assert\Url()]
25+
#[Assert\Url(requireTld: true)]
2626
public $dummyUrl;
2727

2828
#[Assert\Email]

src/Symfony/Tests/Fixtures/DummyValidatedEntity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class DummyValidatedEntity
7575
/**
7676
* @var string A dummy url
7777
*/
78-
#[Assert\Url()]
78+
#[Assert\Url(requireTld: true)]
7979
public $dummyUrl;
8080

8181
/**

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ 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+
yield 'url' => [new Url(requireTld: true), new ApiProperty(), true];
5050
if (class_exists(Hostname::class)) {
5151
yield 'hostname' => [new Hostname(), new ApiProperty(), true];
5252
}
@@ -67,7 +67,7 @@ public function testCreate(Constraint $constraint, ApiProperty $propertyMetadata
6767
public static function createProvider(): \Generator
6868
{
6969
yield 'email' => [new Email(), new ApiProperty(), ['format' => 'email']];
70-
yield 'url' => [new Url(), new ApiProperty(), ['format' => 'uri']];
70+
yield 'url' => [new Url(requireTld: true), new ApiProperty(), ['format' => 'uri']];
7171
if (class_exists(Hostname::class)) {
7272
yield 'hostname' => [new Hostname(), new ApiProperty(), ['format' => 'hostname']];
7373
}

0 commit comments

Comments
 (0)