Skip to content

Commit a682582

Browse files
chore: solve SF 7.3 deprecations
1 parent a85d7aa commit a682582

11 files changed

+149
-149
lines changed

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

Lines changed: 60 additions & 60 deletions
Large diffs are not rendered by default.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ public static function createProvider(): \Generator
8787
new Email(['mode' => Email::VALIDATION_MODE_HTML5]),
8888
],
8989
'phone' => new Optional([
90-
new Type(['type' => 'string']),
90+
new Type(type: 'string'),
9191
new Regex(pattern: '/^[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\s\.\/0-9]*$/'),
9292
]),
9393
'age' => new Optional([
94-
new Type(['type' => 'int']),
94+
new Type(type: 'int'),
9595
new GreaterThan(0),
9696
]),
9797
'social' => new Collection([

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function testSupports(Constraint $constraint, ApiProperty $propertyMetada
4343

4444
public static function supportsProvider(): \Generator
4545
{
46-
yield 'supported' => [new Count(['min' => 1]), new ApiProperty(), true];
46+
yield 'supported' => [new Count(min: 1), new ApiProperty(), true];
4747
yield 'not supported' => [new Positive(), new ApiProperty(), false];
4848
}
4949

@@ -55,8 +55,8 @@ public function testCreate(Count $constraint, ApiProperty $propertyMetadata, arr
5555

5656
public static function createProvider(): \Generator
5757
{
58-
yield 'min items' => [new Count(['min' => 1]), new ApiProperty(), ['minItems' => 1]];
59-
yield 'max items' => [new Count(['max' => 10]), new ApiProperty(), ['maxItems' => 10]];
60-
yield 'min/max items' => [new Count(['min' => 1, 'max' => 10]), new ApiProperty(), ['minItems' => 1, 'maxItems' => 10]];
58+
yield 'min items' => [new Count(min: 1), new ApiProperty(), ['minItems' => 1]];
59+
yield 'max items' => [new Count(max: 10), new ApiProperty(), ['maxItems' => 10]];
60+
yield 'min/max items' => [new Count(min: 1, max: 10), new ApiProperty(), ['minItems' => 1, 'maxItems' => 10]];
6161
}
6262
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ public static function createProvider(): \Generator
7575
if (class_exists(Ulid::class)) {
7676
yield 'ulid' => [new Ulid(), new ApiProperty(), ['format' => 'ulid']];
7777
}
78-
yield 'ipv4' => [new Ip(['version' => '4']), new ApiProperty(), ['format' => 'ipv4']];
79-
yield 'ipv6' => [new Ip(['version' => '6']), new ApiProperty(), ['format' => 'ipv6']];
78+
yield 'ipv4' => [new Ip(version: '4'), new ApiProperty(), ['format' => 'ipv4']];
79+
yield 'ipv6' => [new Ip(version: '6'), new ApiProperty(), ['format' => 'ipv6']];
8080
yield 'not supported' => [new Positive(), new ApiProperty(), []];
8181
}
8282
}

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,34 +56,34 @@ public function testSupportsWithNativeType(Constraint $constraint, ApiProperty $
5656

5757
public static function supportsProvider(): \Generator
5858
{
59-
yield 'supported int/float with union types' => [new GreaterThanOrEqual(['value' => 10]), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT), new LegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]), true];
60-
yield 'supported int' => [new GreaterThanOrEqual(['value' => 10]), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT)]), true];
61-
yield 'supported float' => [new GreaterThanOrEqual(['value' => 10.99]), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]), true];
59+
yield 'supported int/float with union types' => [new GreaterThanOrEqual(value: 10), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT), new LegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]), true];
60+
yield 'supported int' => [new GreaterThanOrEqual(value: 10), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT)]), true];
61+
yield 'supported float' => [new GreaterThanOrEqual(value: 10.99), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]), true];
6262
yield 'supported positive or zero' => [new PositiveOrZero(), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT)]), true];
6363
yield 'not supported positive' => [new Positive(), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT)]), false];
64-
yield 'not supported property path' => [new GreaterThanOrEqual(['propertyPath' => 'greaterThanMe']), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT)]), false];
64+
yield 'not supported property path' => [new GreaterThanOrEqual(propertyPath: 'greaterThanMe'), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT)]), false];
6565
}
6666

6767
public static function supportsProviderWithNativeType(): \Generator
6868
{
69-
yield 'native type: supported int/float with union types' => [new GreaterThanOrEqual(['value' => 10]), (new ApiProperty())->withNativeType(Type::union(Type::int(), Type::float())), true];
70-
yield 'native type: supported int' => [new GreaterThanOrEqual(['value' => 10]), (new ApiProperty())->withNativeType(Type::int()), true];
71-
yield 'native type: supported float' => [new GreaterThanOrEqual(['value' => 10.99]), (new ApiProperty())->withNativeType(Type::float()), true];
69+
yield 'native type: supported int/float with union types' => [new GreaterThanOrEqual(value: 10), (new ApiProperty())->withNativeType(Type::union(Type::int(), Type::float())), true];
70+
yield 'native type: supported int' => [new GreaterThanOrEqual(value: 10), (new ApiProperty())->withNativeType(Type::int()), true];
71+
yield 'native type: supported float' => [new GreaterThanOrEqual(value: 10.99), (new ApiProperty())->withNativeType(Type::float()), true];
7272
yield 'native type: supported positive or zero' => [new PositiveOrZero(), (new ApiProperty())->withNativeType(Type::int()), true];
7373
yield 'native type: not supported positive' => [new Positive(), (new ApiProperty())->withNativeType(Type::int()), false];
74-
yield 'native type: not supported property path' => [new GreaterThanOrEqual(['propertyPath' => 'greaterThanMe']), (new ApiProperty())->withNativeType(Type::int()), false];
74+
yield 'native type: not supported property path' => [new GreaterThanOrEqual(propertyPath: 'greaterThanMe'), (new ApiProperty())->withNativeType(Type::int()), false];
7575
}
7676

7777
#[IgnoreDeprecations]
7878
public function testCreate(): void
7979
{
80-
self::assertEquals(['minimum' => 10], $this->propertySchemaGreaterThanOrEqualRestriction->create(new GreaterThanOrEqual(['value' => 10]), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT)])));
80+
self::assertEquals(['minimum' => 10], $this->propertySchemaGreaterThanOrEqualRestriction->create(new GreaterThanOrEqual(value: 10), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT)])));
8181
}
8282

8383
public function testCreateWithNativeType(): void
8484
{
85-
self::assertEquals(['minimum' => 10], $this->propertySchemaGreaterThanOrEqualRestriction->create(new GreaterThanOrEqual(['value' => 10]), (new ApiProperty())->withNativeType(Type::int())));
85+
self::assertEquals(['minimum' => 10], $this->propertySchemaGreaterThanOrEqualRestriction->create(new GreaterThanOrEqual(value: 10), (new ApiProperty())->withNativeType(Type::int())));
8686
self::assertEquals(['minimum' => 0], $this->propertySchemaGreaterThanOrEqualRestriction->create(new PositiveOrZero(), (new ApiProperty())->withNativeType(Type::int())));
87-
self::assertEquals(['minimum' => 10.99], $this->propertySchemaGreaterThanOrEqualRestriction->create(new GreaterThanOrEqual(['value' => 10.99]), (new ApiProperty())->withNativeType(Type::float())));
87+
self::assertEquals(['minimum' => 10.99], $this->propertySchemaGreaterThanOrEqualRestriction->create(new GreaterThanOrEqual(value: 10.99), (new ApiProperty())->withNativeType(Type::float())));
8888
}
8989
}

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,22 @@ public function testSupportsWithNativeType(Constraint $constraint, ApiProperty $
5656

5757
public static function supportsProvider(): \Generator
5858
{
59-
yield 'supported int/float with union types' => [new GreaterThan(['value' => 10]), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT), new LegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]), true];
60-
yield 'supported int' => [new GreaterThan(['value' => 10]), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT)]), true];
61-
yield 'supported float' => [new GreaterThan(['value' => 10.99]), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]), true];
59+
yield 'supported int/float with union types' => [new GreaterThan(value: 10), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT), new LegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]), true];
60+
yield 'supported int' => [new GreaterThan(value: 10), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT)]), true];
61+
yield 'supported float' => [new GreaterThan(value: 10.99), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]), true];
6262
yield 'supported positive' => [new Positive(), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT)]), true];
6363
yield 'not supported positive or zero' => [new PositiveOrZero(), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT)]), false];
64-
yield 'not supported property path' => [new GreaterThan(['propertyPath' => 'greaterThanMe']), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT)]), false];
64+
yield 'not supported property path' => [new GreaterThan(propertyPath: 'greaterThanMe'), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT)]), false];
6565
}
6666

6767
public static function supportsProviderWithNativeType(): \Generator
6868
{
69-
yield 'native type: supported int/float with union types' => [new GreaterThan(['value' => 10]), (new ApiProperty())->withNativeType(Type::union(Type::int(), Type::float())), true];
70-
yield 'native type: supported int' => [new GreaterThan(['value' => 10]), (new ApiProperty())->withNativeType(Type::int()), true];
71-
yield 'native type: supported float' => [new GreaterThan(['value' => 10.99]), (new ApiProperty())->withNativeType(Type::float()), true];
69+
yield 'native type: supported int/float with union types' => [new GreaterThan(value: 10), (new ApiProperty())->withNativeType(Type::union(Type::int(), Type::float())), true];
70+
yield 'native type: supported int' => [new GreaterThan(value: 10), (new ApiProperty())->withNativeType(Type::int()), true];
71+
yield 'native type: supported float' => [new GreaterThan(value: 10.99), (new ApiProperty())->withNativeType(Type::float()), true];
7272
yield 'native type: supported positive' => [new Positive(), (new ApiProperty())->withNativeType(Type::int()), true];
7373
yield 'native type: not supported positive or zero' => [new PositiveOrZero(), (new ApiProperty())->withNativeType(Type::int()), false];
74-
yield 'native type: not supported property path' => [new GreaterThan(['propertyPath' => 'greaterThanMe']), (new ApiProperty())->withNativeType(Type::int()), false];
74+
yield 'native type: not supported property path' => [new GreaterThan(propertyPath: 'greaterThanMe'), (new ApiProperty())->withNativeType(Type::int()), false];
7575
}
7676

7777
#[IgnoreDeprecations]
@@ -80,15 +80,15 @@ public function testCreate(): void
8080
self::assertEquals([
8181
'exclusiveMinimum' => 10,
8282
'minimum' => 10,
83-
], $this->propertySchemaGreaterThanRestriction->create(new GreaterThan(['value' => 10]), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT)])));
83+
], $this->propertySchemaGreaterThanRestriction->create(new GreaterThan(value: 10), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT)])));
8484
}
8585

8686
public function testCreateWithNativeType(): void
8787
{
8888
self::assertEquals([
8989
'exclusiveMinimum' => 10,
9090
'minimum' => 10,
91-
], $this->propertySchemaGreaterThanRestriction->create(new GreaterThan(['value' => 10]), (new ApiProperty())->withNativeType(Type::int())));
91+
], $this->propertySchemaGreaterThanRestriction->create(new GreaterThan(value: 10), (new ApiProperty())->withNativeType(Type::int())));
9292

9393
self::assertEquals([
9494
'exclusiveMinimum' => 0,
@@ -98,6 +98,6 @@ public function testCreateWithNativeType(): void
9898
self::assertEquals([
9999
'exclusiveMinimum' => 10.99,
100100
'minimum' => 10.99,
101-
], $this->propertySchemaGreaterThanRestriction->create(new GreaterThan(['value' => 10.99]), (new ApiProperty())->withNativeType(Type::float())));
101+
], $this->propertySchemaGreaterThanRestriction->create(new GreaterThan(value: 10.99), (new ApiProperty())->withNativeType(Type::float())));
102102
}
103103
}

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,34 +56,34 @@ public function testSupportsWithNativeType(Constraint $constraint, ApiProperty $
5656

5757
public static function supportsProvider(): \Generator
5858
{
59-
yield 'supported int/float with union types' => [new LessThanOrEqual(['value' => 10]), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT), new LegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]), true];
60-
yield 'supported int' => [new LessThanOrEqual(['value' => 10]), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT)]), true];
61-
yield 'supported float' => [new LessThanOrEqual(['value' => 10.99]), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]), true];
59+
yield 'supported int/float with union types' => [new LessThanOrEqual(value: 10), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT), new LegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]), true];
60+
yield 'supported int' => [new LessThanOrEqual(value: 10), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT)]), true];
61+
yield 'supported float' => [new LessThanOrEqual(value: 10.99), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]), true];
6262
yield 'supported negative or zero' => [new NegativeOrZero(), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT)]), true];
6363
yield 'not supported negative' => [new Negative(), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT)]), false];
64-
yield 'not supported property path' => [new LessThanOrEqual(['propertyPath' => 'greaterThanMe']), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT)]), false];
64+
yield 'not supported property path' => [new LessThanOrEqual(propertyPath: 'greaterThanMe'), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT)]), false];
6565
}
6666

6767
public static function supportsProviderWithNativeType(): \Generator
6868
{
69-
yield 'native type: supported int/float with union types' => [new LessThanOrEqual(['value' => 10]), (new ApiProperty())->withNativeType(Type::union(Type::int(), Type::float())), true];
70-
yield 'native type: supported int' => [new LessThanOrEqual(['value' => 10]), (new ApiProperty())->withNativeType(Type::int()), true];
71-
yield 'native type: supported float' => [new LessThanOrEqual(['value' => 10.99]), (new ApiProperty())->withNativeType(Type::float()), true];
69+
yield 'native type: supported int/float with union types' => [new LessThanOrEqual(value: 10), (new ApiProperty())->withNativeType(Type::union(Type::int(), Type::float())), true];
70+
yield 'native type: supported int' => [new LessThanOrEqual(value: 10), (new ApiProperty())->withNativeType(Type::int()), true];
71+
yield 'native type: supported float' => [new LessThanOrEqual(value: 10.99), (new ApiProperty())->withNativeType(Type::float()), true];
7272
yield 'native type: supported negative or zero' => [new NegativeOrZero(), (new ApiProperty())->withNativeType(Type::int()), true];
7373
yield 'native type: not supported negative' => [new Negative(), (new ApiProperty())->withNativeType(Type::int()), false];
74-
yield 'native type: not supported property path' => [new LessThanOrEqual(['propertyPath' => 'greaterThanMe']), (new ApiProperty())->withNativeType(Type::int()), false];
74+
yield 'native type: not supported property path' => [new LessThanOrEqual(propertyPath: 'greaterThanMe'), (new ApiProperty())->withNativeType(Type::int()), false];
7575
}
7676

7777
#[IgnoreDeprecations]
7878
public function testCreate(): void
7979
{
80-
self::assertEquals(['maximum' => 10], $this->propertySchemaLessThanOrEqualRestriction->create(new LessThanOrEqual(['value' => 10]), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT)])));
80+
self::assertEquals(['maximum' => 10], $this->propertySchemaLessThanOrEqualRestriction->create(new LessThanOrEqual(value: 10), (new ApiProperty())->withBuiltinTypes([new LegacyType(LegacyType::BUILTIN_TYPE_INT)])));
8181
}
8282

8383
public function testCreateWithNativeType(): void
8484
{
85-
self::assertEquals(['maximum' => 10], $this->propertySchemaLessThanOrEqualRestriction->create(new LessThanOrEqual(['value' => 10]), (new ApiProperty())->withNativeType(Type::int())));
85+
self::assertEquals(['maximum' => 10], $this->propertySchemaLessThanOrEqualRestriction->create(new LessThanOrEqual(value: 10), (new ApiProperty())->withNativeType(Type::int())));
8686
self::assertEquals(['maximum' => 0], $this->propertySchemaLessThanOrEqualRestriction->create(new NegativeOrZero(), (new ApiProperty())->withNativeType(Type::int())));
87-
self::assertEquals(['maximum' => 10.99], $this->propertySchemaLessThanOrEqualRestriction->create(new LessThanOrEqual(['value' => 10.99]), (new ApiProperty())->withNativeType(Type::float())));
87+
self::assertEquals(['maximum' => 10.99], $this->propertySchemaLessThanOrEqualRestriction->create(new LessThanOrEqual(value: 10.99), (new ApiProperty())->withNativeType(Type::float())));
8888
}
8989
}

0 commit comments

Comments
 (0)