Skip to content

Commit 127457b

Browse files
Merge branch '2.3' into 2.7
* 2.3: [DoctrineBridge] Fix required guess of boolean fields [DI] don't use array_map to resolve services Remove dead code in the PropertyPath constructor [Process] Inherit env vars by default in PhpProcess [HttpFoundation] Fixes /0 subnet handling in IpUtils [Form] Simplify DateTimeToStringTransformer Avoid unneeded catch and re-throw of the same exception. [HttpKernel] Remove a duplicate test for the EsiFragmentRenderer Conflicts: src/Symfony/Component/Process/Process.php src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php
2 parents 855a483 + 27249cf commit 127457b

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

Extension/Core/DataTransformer/DateTimeToStringTransformer.php

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function __construct($inputTimezone = null, $outputTimezone = null, $form
8686
* Transforms a DateTime object into a date string with the configured format
8787
* and timezone.
8888
*
89-
* @param \DateTime|\DateTimeInterface $dateTime A DateTime object
89+
* @param \DateTime|\DateTimeInterface $value A DateTime object
9090
*
9191
* @return string A value as produced by PHP's date() function
9292
*
@@ -138,21 +138,21 @@ public function reverseTransform($value)
138138
throw new TransformationFailedException('Expected a string.');
139139
}
140140

141-
try {
142-
$outputTz = new \DateTimeZone($this->outputTimezone);
143-
$dateTime = \DateTime::createFromFormat($this->parseFormat, $value, $outputTz);
141+
$outputTz = new \DateTimeZone($this->outputTimezone);
142+
$dateTime = \DateTime::createFromFormat($this->parseFormat, $value, $outputTz);
144143

145-
$lastErrors = \DateTime::getLastErrors();
144+
$lastErrors = \DateTime::getLastErrors();
146145

147-
if (0 < $lastErrors['warning_count'] || 0 < $lastErrors['error_count']) {
148-
throw new TransformationFailedException(
149-
implode(', ', array_merge(
150-
array_values($lastErrors['warnings']),
151-
array_values($lastErrors['errors'])
152-
))
153-
);
154-
}
146+
if (0 < $lastErrors['warning_count'] || 0 < $lastErrors['error_count']) {
147+
throw new TransformationFailedException(
148+
implode(', ', array_merge(
149+
array_values($lastErrors['warnings']),
150+
array_values($lastErrors['errors'])
151+
))
152+
);
153+
}
155154

155+
try {
156156
// On PHP versions < 5.3.7 we need to emulate the pipe operator
157157
// and reset parts not given in the format to their equivalent
158158
// of the UNIX base timestamp.
@@ -220,8 +220,6 @@ public function reverseTransform($value)
220220
if ($this->inputTimezone !== $this->outputTimezone) {
221221
$dateTime->setTimezone(new \DateTimeZone($this->inputTimezone));
222222
}
223-
} catch (TransformationFailedException $e) {
224-
throw $e;
225223
} catch (\Exception $e) {
226224
throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e);
227225
}

0 commit comments

Comments
 (0)