8000 [Validator] Remove DateTime support in date/time validators · symfony/symfony@37c1cbb · GitHub
[go: up one dir, main page]

Skip to content

Commit 37c1cbb

Browse files
committed
[Validator] Remove DateTime support in date/time validators
1 parent 9cc2a4e commit 37c1cbb

File tree

6 files changed

+0
-84
lines changed

6 files changed

+0
-84
lines changed

src/Symfony/Component/Validator/Constraints/DateTimeValidator.php

Lines changed: 0 additions & 6 deletions
< 10000 td data-grid-cell-id="diff-ba78b4eb5423513a276ec1e79483a17df990282a45baa40ed0d143a1c99df9fa-40-36-2" data-line-anchor="diff-ba78b4eb5423513a276ec1e79483a17df990282a45baa40ed0d143a1c99df9faL40" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-deletionLine-bgColor, var(--diffBlob-deletion-bgColor-line));padding-right:24px" tabindex="-1" valign="top" class="focusable-grid-cell diff-text-cell left-side-diff-cell border-right left-side">-
return;
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@ public function validate($value, Constraint $constraint)
3434
return;
3535
}
3636

37-
if ($value instanceof \DateTimeInterface) {
38-
@trigger_error(sprintf('Validating a \\DateTimeInterface with "%s" is deprecated since version 4.2. Use "%s" instead or remove the constraint if the underlying model is already type hinted to \\DateTimeInterface.', DateTime::class, Type::class), E_USER_DEPRECATED);
39-
40
41-
}
42-
4337
if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
4438
throw new UnexpectedValueException($value, 'string');
4539
}

src/Symfony/Component/Validator/Constraints/DateValidator.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ public function validate($value, Constraint $constraint)
5252
return;
5353
}
5454

55-
if ($value instanceof \DateTimeInterface) {
56-
@trigger_error(sprintf('Validating a \\DateTimeInterface with "%s" is deprecated since version 4.2. Use "%s" instead or remove the constraint if the underlying model is already type hinted to \\DateTimeInterface.', Date::class, Type::class), E_USER_DEPRECATED);
57-
58-
return;
59-
}
60-
6155
if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
6256
throw new UnexpectedValueException($value, 'string');
6357
}

src/Symfony/Component/Validator/Constraints/TimeValidator.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ public function validate($value, Constraint $constraint)
5252
return;
5353
}
5454

55-
if ($value instanceof \DateTimeInterface) {
56-
@trigger_error(sprintf('Validating a \\DateTimeInterface with "%s" is deprecated since version 4.2. Use "%s" instead or remove the constraint if the underlying model is already type hinted to \\DateTimeInterface.', Time::class, Type::class), E_USER_DEPRECATED);
57-
58-
return;
59-
}
60-
6155
if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
6256
throw new UnexpectedValueException($value, 'string');
6357
}

src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,6 @@ public function testEmptyStringIsValid()
3636
$this->assertNoViolation();
3737
}
3838

39-
/**
40-
* @group legacy
41-
* @expectedDeprecation Validating a \DateTimeInterface with "Symfony\Component\Validator\Constraints\DateTime" is deprecated since version 4.2. Use "Symfony\Component\Validator\Constraints\Type" instead or remove the constraint if the underlying model is already type hinted to \DateTimeInterface.
42-
*/
43-
public function testDateTimeClassIsValid()
44-
{
45-
$this->validator->validate(new \DateTime(), new DateTime());
46-
47-
$this->assertNoViolation();
48-
}
49-
50-
/**
51-
* @group legacy
52-
* @expectedDeprecation Validating a \DateTimeInterface with "Symfony\Component\Validator\Constraints\DateTime" is deprecated since version 4.2. Use "Symfony\Component\Validator\Constraints\Type" instead or remove the constraint if the underlying model is already type hinted to \DateTimeInterface.
53-
*/
54-
public function testDateTimeImmutableClassIsValid()
55-
{
56-
$this->validator->validate(new \DateTimeImmutable(), new DateTime());
57-
58-
$this->assertNoViolation();
59-
}
60-
6139
/**
6240
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
6341
*/

src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,6 @@ public function testEmptyStringIsValid()
3636
$this->assertNoViolation();
3737
}
3838

39-
/**
40-
* @group legacy
41-
* @expectedDeprecation Validating a \DateTimeInterface with "Symfony\Component\Validator\Constraints\Date" is deprecated since version 4.2. Use "Symfony\Component\Validator\Constraints\Type" instead or remove the constraint if the underlying model is already type hinted to \DateTimeInterface.
42-
*/
43-
public function testDateTimeClassIsValid()
44-
{
45-
$this->validator->validate(new \DateTime(), new Date());
46-
47-
$this->assertNoViolation();
48-
}
49-
50-
/**
51-
* @group legacy
52-
* @expectedDeprecation Validating a \DateTimeInterface with "Symfony\Component\Validator\Constraints\Date" is deprecated since version 4.2. Use "Symfony\Component\Validator\Constraints\Type" instead or remove the constraint if the underlying model is already type hinted to \DateTimeInterface.
53-
*/
54-
public function testDateTimeImmutableClassIsValid()
55-
{
56-
$this->validator->validate(new \DateTimeImmutable(), new Date());
57-
58-
$this->assertNoViolation();
59-
}
60-
6139
/**
6240
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
6341
*/

src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,6 @@ public function testEmptyStringIsValid()
3636
$this->assertNoViolation();
3737
}
38 106C5 38

39-
/**
40-
* @group legacy
41-
* @expectedDeprecation Validating a \DateTimeInterface with "Symfony\Component\Validator\Constraints\Time" is deprecated since version 4.2. Use "Symfony\Component\Validator\Constraints\Type" instead or remove the constraint if the underlying model is already type hinted to \DateTimeInterface.
42-
*/
43-
public function testDateTimeClassIsValid()
44-
{
45-
$this->validator->validate(new \DateTime(), new Time());
46-
47-
$this->assertNoViolation();
48-
}
49-
5039
/**
5140
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
5241
*/
@@ -103,15 +92,4 @@ public function getInvalidTimes()
10392
['00:00:60', Time::INVALID_TIME_ERROR],
10493
];
10594
}
106-
107-
/**
108-
* @group legacy
109-
* @expectedDeprecation Validating a \DateTimeInterface with "Symfony\Component\Validator\Constraints\Time" is deprecated since version 4.2. Use "Symfony\Component\Validator\Constraints\Type" instead or remove the constraint if the underlying model is already type hinted to \DateTimeInterface.
110-
*/
111-
public function testDateTimeImmutableIsValid()
112-
{
113-
$this->validator->validate(new \DateTimeImmutable(), new Time());
114-
115-
$this->assertNoViolation();
116-
}
11795
}

0 commit comments

Comments
 (0)
0