8000 Fix checking result of DateTime::getLastErrors · ausi/symfony@39cd15b · GitHub
[go: up one dir, main page]

Skip to content

Commit 39cd15b

Browse files
Fix checking result of DateTime::getLastErrors
1 parent 2a1da92 commit 39cd15b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function reverseTransform($value)
121121
$outputTz = new \DateTimeZone($this->outputTimezone);
122122
$dateTime = \DateTime::createFromFormat($this->parseFormat, $value, $outputTz);
123123

124-
$lastErrors = \DateTime::getLastErrors();
124+
$lastErrors = \DateTime::getLastErrors() ?: ['error_count' => 0, 'warning_count' => 0];
125125

126126
if (0 < $lastErrors['warning_count'] || 0 < $lastErrors['error_count']) {
127127
throw new TransformationFailedException(implode(', ', array_merge(array_values($lastErrors['warnings']), array_values($lastErrors['errors']))));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function validate($value, Constraint $constraint)
4848

4949
\DateTime::createFromFormat($constraint->format, $value);
5050

51-
$errors = \DateTime::getLastErrors();
51+
$errors = \DateTime::getLastErrors() ?: ['error_count' => 0, 'warnings' => []];
5252

5353
if (0 < $errors['error_count']) {
5454
$this->context->buildViolation($constraint->message)

0 commit comments

Comments
 (0)
0