File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -265,5 +265,34 @@ control on your time-sensitive code's behavior.
265
265
266
266
The :class: `Symfony\\ Component\\ Clock\\ Test\\ ClockSensitiveTrait ` was introduced in Symfony 6.3.
267
267
268
+ Exceptions Management
269
+ ---------------------
270
+
271
+ The Clock component takes full advantage of `the new DateTime exceptions `_
272
+ introduced in PHP 8.3: ``DateMalformedStringException `` and
273
+ ``DateInvalidTimeZoneException ``. These exceptions will be thrown
274
+ respectively when a invalid string is passed to a clock (e.g. when
275
+ creating a clock or modifying a ``MockClock ``) and when an invalid timezone is
276
+ used::
277
+
278
+ $userInput = 'invalid timezone';
279
+
280
+ try {
281
+ $clock = Clock::get()->withTimeZone($userInput);
282
+ } catch (\DateInvalidTimeZoneException $exception) {
283
+ // ...
284
+ }
285
+
286
+ Thanks to the `symfony/polyfill-php83 `_ dependency required by the Clock
287
+ component, you don't even need to run PHP 8.3 to enjoy these new explicit
288
+ and consistent exceptions when using the Clock component.
289
+
290
+ .. versionadded :: 6.4
291
+
292
+ The support for ``DateMalformedStringException `` and
293
+ ``DateInvalidTimeZoneException `` was introduced in Symfony 6.4.
294
+
268
295
.. _`PSR-20` : https://www.php-fig.org/psr/psr-20/
269
296
.. _`accepted by the DateTime constructor` : https://www.php.net/manual/en/datetime.formats.php
297
+ .. _`the new DateTime exceptions` : https://wiki.php.net/rfc/datetime-exceptions
298
+ .. _`symfony/polyfill-php83` : https://github.com/symfony/polyfill-php83
You can’t perform that action at this time.
0 commit comments