Skip to content

Commit 8b12c8e

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: [Intl] promote warnings to value errors on PHP 8 Fix CS DateTime validator support for trailing data Remove some leftover for HHVM support Simplify code Fix tests on 5.6 [Debug] Skip a test that was meant for HHVM. [Console] Silence warnings on sapi_windows_cp_set() call guard $argv + $token against null, preventing unnecessary exceptions
2 parents 9775375 + c71d8ab commit 8b12c8e

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Constraints/DateTimeValidator.php

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

56+
if ('+' === substr($constraint->format, -1)) {
57+
$errors['warnings'] = array_filter($errors['warnings'], function ($warning) {
58+
return 'Trailing data' !== $warning;
59+
});
60+
}
61+
5662
foreach ($errors['warnings'] as $warning) {
5763
if ('The parsed date was invalid' === $warning) {
5864
$this->context->buildViolation($constraint->message)

Tests/Constraints/DateTimeValidatorTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,12 @@ public function getInvalidDateTimes()
114114
['Y-m-d H:i:s', '2010-01-01 00:00:60', DateTime::INVALID_TIME_ERROR],
115115
];
116116
}
117+
118+
public function testDateTimeWithTrailingData()
119+
{
120+
$this->validator->validate('1995-05-10 00:00:00', new DateTime([
121+
'format' => 'Y-m-d+',
122+
]));
123+
$this->assertNoViolation();
124+
}
117125
}

0 commit comments

Comments
 (0)