From fb0d7beaaf53fec5c293f99175b618ebadd66631 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 18 Sep 2020 11:45:13 +0200 Subject: [PATCH] catch ValueError thrown on PHP 8 --- .../Component/Validator/Constraints/TimezoneValidator.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Validator/Constraints/TimezoneValidator.php b/src/Symfony/Component/Validator/Constraints/TimezoneValidator.php index cf52239d0c..ab6b4eed62 100644 --- a/src/Symfony/Component/Validator/Constraints/TimezoneValidator.php +++ b/src/Symfony/Component/Validator/Constraints/TimezoneValidator.php @@ -78,7 +78,11 @@ class TimezoneValidator extends ConstraintValidator private static function getPhpTimezones(int $zone, string $countryCode = null): array { if (null !== $countryCode) { - return @\DateTimeZone::listIdentifiers($zone, $countryCode) ?: []; + try { + return @\DateTimeZone::listIdentifiers($zone, $countryCode) ?: []; + } catch (\ValueError $e) { + return []; + } } return \DateTimeZone::listIdentifiers($zone);